[Feedback on issues] service-manager:dde 进程 QThread 99.9% CPU 空转
Tofloor
poster avatar
150******77
deepin
2026-09-22 02:35
Author

【标题】service-manager:dde 进程 QThread 99.9% CPU 空转(X11 socket 数据积压导致)

【系统环境】

  • 系统版本:[Version]
    SystemName=Deepin
    SystemName[zh_CN]=深度操作系统
    ProductType=Desktop
    ProductType[zh_CN]=桌面
    EditionName=Community
    EditionName[en_US]=Community
    EditionName[zh_CN]=社区版
    MajorVersion=25
    MinorVersion=25.2.2
    OsBuild=21138.103.100
  • 内核版本:Linux zxs-PC 6.18.48-amd64-desktop-rolling #25.01.01.35 SMP PREEMPT_DYNAMIC Mon Aug 31 10:31:28 CST 2026 x86_64 GNU/Linux
  • 架构:amd64
  • 软件包版本:
    ii dde-file-manager-services-plugins 6.6.3 amd64 deepin desktop-environment - deepin-service-manager plugins module
    ii dde-session 2.0.30 amd64 dde session module
    ii dde-session-shell 6.0.65 amd64 deepin desktop-environment - dde-session-shell module
    ii dde-session-ui 6.0.47 amd64 deepin desktop-environment - dde-session-ui module
    ii dde-shell 2.0.52 amd64 An wrapper for developed based on dde-shell plugin system
    ii deepin-service-manager 1.0.22 amd64 deepin desktop-environment - service manager frame
    ii deepin-service-plugin-network 2.0.98 amd64 the plugin of network service for deepin-service-manager
    ii jnetapplet 2.1.0 amd64 网络速度监控 dde-shell 任务栏插件
    ii libdde-shell:amd64 2.0.52 amd64 DDE Shell library
    ii libdde-shell-dev 2.0.52 amd64 DDE Shell devel library
    ii libdde-shell-dock:amd64 2.0.52 amd64 DDE Shell dock library
    ii libglib2.0-0:amd64 2.84.4-3deepin3 amd64 GLib library of C routines
    ii libglib2.0-bin 2.84.4-3deepin3 amd64 Programs for the GLib library
    ii libglib2.0-data 2.84.4-3deepin3 all Common files for GLib library

【问题现象】
开机约 5 分钟后,service-manager:dde(PID 5994)内一个 QThread(PID 6054)
持续 99.9% CPU,累计 CPU 时间几分钟不回落,导致整机发热、风扇狂转。
重启桌面会话后恢复,但下次开机复现。系统内存充足(48G,仅用约 3G),
非资源不足导致。

【复现步骤】

  1. 正常开机进入桌面
  2. 等待 3~5 分钟
  3. 执行 top -H -p $(pgrep -f service-manager | head -1)
    观察某 QThread 持续 99.9% CPU

【诊断证据】

  1. top -H:QThread(6054) R 状态 99.9%,TIME+ 3:55(开机仅5分钟)

  2. perf record 调用链显示:

    • 内核侧:ppoll → unix_poll + eventfd_poll 反复轮询
    • 用户态:QSocketNotifier::activated 反复触发,glib 主循环
      g_mutex_lock/unlock、g_source_ref、clock_gettime 高频执行
    • 即:一个 Qt 套接字通知器监听 UNIX socket,永远可读,循环不阻塞
  3. ss -xp 显示 service-manager 与 X Server(@/tmp/.X11-unix/X0)的
    多条连接存在未读数据积压,其中 fd 35 对应 socket RQ=17792 字节,
    其余 fd 32-37 也有 32~160 字节积压。

  4. strace 实锤空转线程(6054)ppoll([fd 15,32,35]) 每次都因 fd 35
    POLLIN 立即返回,0.87s 超时形同虚设 → busy loop。

【根因分析(供官方参考)】
service-manager 内某插件对 X11 连接注册了 QSocketNotifier,但对应
X 事件数据未被消费,X Server 侧持续有数据积压(17792 字节 ≈ 500+
个 X 事件),导致通知器风暴 + glib 主循环空转。疑似 dde-shell 或
service-manager 插件层的 X11 事件处理 bug。

下面是小U分析的结果

QSocketNotifier 调用链(提取结果)

plaintext

12 └→ 0x79cf9b8d2768 (Qt6Core 内部)

34

而真正关键的是这几行——调用链里反复出现的插件符号:

plaintext

1libplugin-dde-shortcut.so [.] ModifierKeyMonitor::handleEvents() ← ★ 核心嫌疑人

2libplugin-dde-shortcut.so [.] XRecordProcessReplies@plt ← ★ XRecord 处理

3libXtst.so.6.1.0 [.] XRecordProcessReplies

4libXtst.so.6.1.0 [.] XPending@plt

5libX11.so.6.4.0 [.] XPending

6libplugin-dde-shortcut.so [.] 0xc7ab8 / 0xc7aae / 0xc7a5a (插件内代码)

7

🔥 真凶确认:dde-shortcut 插件的 XRecord 监视

完整机制:

plaintext

1libplugin-dde-shortcut.so(service-manager 的快捷键插件)

2 └─ ModifierKeyMonitor 类

3 └─ 通过 XRecord 扩展(libXtst)连接 X Server

4 └─ 监听全部键盘/鼠标输入事件

5 └─ X Server 持续灌事件流(fd 35 积压 17792 字节)

6 └─ XPending 永远有数据 → QSocketNotifier 永远触发

7 └─ glib 主循环 99.9% 空转

8

根因:ModifierKeyMonitor::handleEvents() 消费 XRecord 事件流的逻辑有 bug(或某个状态下没读干净),导致 XRecord 连接永远可读 → 通知器风暴。这也完美解释了为什么对端是 X Server(@/tmp/.X11-unix/X0)—— XRecord 连接本身就是连 X 的。

📝 更新 bug 反馈:现在可以精确到模块了

把这条加进反馈正文(这是官方最需要的定位信息):

plaintext

1【真凶定位】

2perf 调用链显示 CPU 消耗集中在:

3 libplugin-dde-shortcut.so

4 └─ ModifierKeyMonitor::handleEvents()

5 └─ XRecordProcessReplies (libXtst XRecord 扩展)

6现象:XRecord 连接(fd 35,对端 X Server @/tmp/.X11-unix/X0)

7积压 17792 字节未消费,QSocketNotifier 风暴导致 glib 循环空转。

8疑似 ModifierKeyMonitor 的 XRecord 事件消费逻辑存在 busy-loop bug。

附上当时的sudo perf record -p 5994 -g -o /tmp/perf.data -- sleep 10的日志

perf_report_full.txt

Reply Favorite View the author
All Replies
avatar
𰻞𰻝面
deepin
2026-09-22 02:49
#1

为你点赞👍

agree

Reply View the author
avatar
pzm9012
Moderator
2026-09-22 08:53
#2
𰻞𰻝面:

为你点赞👍

agree

你在点赞什么confused

Reply View the author
avatar
𰻞𰻝面
deepin
2026-09-22 09:32
#3
pzm9012:

你在点赞什么confused

找到问题了

Reply View the author
avatar
150******77
deepin
2026-09-22 10:22
#4
pzm9012:

你在点赞什么confused

上次没去深入去挖原因,麻烦反馈给开发老师,谢谢

Reply View the author
avatar
昨夜的星辰
deepin
2026-09-22 10:30
#5

有没有安装第三方插件,楼主的这个问题重来没有遇到过,只见过吃内存的😂

image.png

Reply View the author
avatar
150******77
deepin
2026-09-22 10:48
#6
昨夜的星辰:

有没有安装第三方插件,楼主的这个问题重来没有遇到过,只见过吃内存的😂

image.png

ii dde-file-manager-services-plugins 6.6.3 amd64 deepin desktop-environment - deepin-service-manager plugins module
ii dde-session 2.0.30 amd64 dde session module
ii dde-session-shell 6.0.65 amd64 deepin desktop-environment - dde-session-shell module
ii dde-session-ui 6.0.47 amd64 deepin desktop-environment - dde-session-ui module
ii dde-shell 2.0.52 amd64 An wrapper for developed based on dde-shell plugin system
ii deepin-service-manager 1.0.22 amd64 deepin desktop-environment - service manager frame
ii deepin-service-plugin-network 2.0.98 amd64 the plugin of network service for deepin-service-manager
ii jnetapplet 2.1.0 amd64 网络速度监控 dde-shell 任务栏插件
ii libdde-shell:amd64 2.0.52 amd64 DDE Shell library
ii libdde-shell-dev 2.0.52 amd64 DDE Shell devel library
ii libdde-shell-dock:amd64 2.0.52 amd64 DDE Shell dock library
ii libglib2.0-0:amd64 2.84.4-3deepin3 amd64 GLib library of C routines
ii libglib2.0-bin 2.84.4-3deepin3 amd64 Programs for the GLib library
ii libglib2.0-data 2.84.4-3deepin3 all Common files for GLib library

Reply View the author
avatar
150******77
deepin
2026-09-22 10:50
#7
150******77:

ii dde-file-manager-services-plugins 6.6.3 amd64 deepin desktop-environment - deepin-service-manager plugins module
ii dde-session 2.0.30 amd64 dde session module
ii dde-session-shell 6.0.65 amd64 deepin desktop-environment - dde-session-shell module
ii dde-session-ui 6.0.47 amd64 deepin desktop-environment - dde-session-ui module
ii dde-shell 2.0.52 amd64 An wrapper for developed based on dde-shell plugin system
ii deepin-service-manager 1.0.22 amd64 deepin desktop-environment - service manager frame
ii deepin-service-plugin-network 2.0.98 amd64 the plugin of network service for deepin-service-manager
ii jnetapplet 2.1.0 amd64 网络速度监控 dde-shell 任务栏插件
ii libdde-shell:amd64 2.0.52 amd64 DDE Shell library
ii libdde-shell-dev 2.0.52 amd64 DDE Shell devel library
ii libdde-shell-dock:amd64 2.0.52 amd64 DDE Shell dock library
ii libglib2.0-0:amd64 2.84.4-3deepin3 amd64 GLib library of C routines
ii libglib2.0-bin 2.84.4-3deepin3 amd64 Programs for the GLib library
ii libglib2.0-data 2.84.4-3deepin3 all Common files for GLib library

还有显卡切换插件

Reply View the author
avatar
昨夜的星辰
deepin
2026-09-22 10:53
#8
150******77:

ii dde-file-manager-services-plugins 6.6.3 amd64 deepin desktop-environment - deepin-service-manager plugins module
ii dde-session 2.0.30 amd64 dde session module
ii dde-session-shell 6.0.65 amd64 deepin desktop-environment - dde-session-shell module
ii dde-session-ui 6.0.47 amd64 deepin desktop-environment - dde-session-ui module
ii dde-shell 2.0.52 amd64 An wrapper for developed based on dde-shell plugin system
ii deepin-service-manager 1.0.22 amd64 deepin desktop-environment - service manager frame
ii deepin-service-plugin-network 2.0.98 amd64 the plugin of network service for deepin-service-manager
ii jnetapplet 2.1.0 amd64 网络速度监控 dde-shell 任务栏插件
ii libdde-shell:amd64 2.0.52 amd64 DDE Shell library
ii libdde-shell-dev 2.0.52 amd64 DDE Shell devel library
ii libdde-shell-dock:amd64 2.0.52 amd64 DDE Shell dock library
ii libglib2.0-0:amd64 2.84.4-3deepin3 amd64 GLib library of C routines
ii libglib2.0-bin 2.84.4-3deepin3 amd64 Programs for the GLib library
ii libglib2.0-data 2.84.4-3deepin3 all Common files for GLib library

网络速度监控那个没用过,可以尝试一下去掉看看效果

显卡切换插件我用过,没问题的

Reply View the author
avatar
150******77
deepin
2026-09-24 10:23
#9
昨夜的星辰:

网络速度监控那个没用过,可以尝试一下去掉看看效果

显卡切换插件我用过,没问题的

卸了,重启了,没用

ii dde-file-manager-services-plugins 6.6.3 amd64 deepin desktop-environment - deepin-service-manager plugins module
ii dde-session 2.0.30 amd64 dde session module
ii dde-session-shell 6.0.65 amd64 deepin desktop-environment - dde-session-shell module
ii dde-session-ui 6.0.47 amd64 deepin desktop-environment - dde-session-ui module
ii dde-shell 2.0.52 amd64 An wrapper for developed based on dde-shell plugin system
ii deepin-service-manager 1.0.22 amd64 deepin desktop-environment - service manager frame
ii deepin-service-plugin-network 2.0.98 amd64 the plugin of network service for deepin-service-manager
ii libdde-shell:amd64 2.0.52 amd64 DDE Shell library
ii libdde-shell-dev 2.0.52 amd64 DDE Shell devel library
ii libdde-shell-dock:amd64 2.0.52 amd64 DDE Shell dock library
zxs@zxs-PC:~$ dpkg -l | grep -E "libqt6core|libglib2.0" | head -5
ii libglib2.0-0:amd64 2.84.4-3deepin3 amd64 GLib library of C routines
ii libglib2.0-bin 2.84.4-3deepin3 amd64 Programs for the GLib library
ii libglib2.0-data 2.84.4-3deepin3 all Common files for GLib library

Reply View the author
avatar
150******77
deepin
2026-09-24 10:27
#10

2perf 调用链显示 CPU 消耗集中在:

3 libplugin-dde-shortcut.so

4 └─ ModifierKeyMonitor::handleEvents()

5 └─ XRecordProcessReplies (libXtst XRecord 扩展)

6现象:XRecord 连接(fd 35,对端 X Server @/tmp/.X11-unix/X0)

7积压 17792 字节未消费,QSocketNotifier 风暴导致 glib 循环空转。

8疑似 ModifierKeyMonitor 的 XRecord 事件消费逻辑存在 busy-loop bug。这个是官方插件吧。

Reply View the author
avatar
昨夜的星辰
deepin
2026-09-24 19:08
#11
150******77:

卸了,重启了,没用

ii dde-file-manager-services-plugins 6.6.3 amd64 deepin desktop-environment - deepin-service-manager plugins module
ii dde-session 2.0.30 amd64 dde session module
ii dde-session-shell 6.0.65 amd64 deepin desktop-environment - dde-session-shell module
ii dde-session-ui 6.0.47 amd64 deepin desktop-environment - dde-session-ui module
ii dde-shell 2.0.52 amd64 An wrapper for developed based on dde-shell plugin system
ii deepin-service-manager 1.0.22 amd64 deepin desktop-environment - service manager frame
ii deepin-service-plugin-network 2.0.98 amd64 the plugin of network service for deepin-service-manager
ii libdde-shell:amd64 2.0.52 amd64 DDE Shell library
ii libdde-shell-dev 2.0.52 amd64 DDE Shell devel library
ii libdde-shell-dock:amd64 2.0.52 amd64 DDE Shell dock library
zxs@zxs-PC:~$ dpkg -l | grep -E "libqt6core|libglib2.0" | head -5
ii libglib2.0-0:amd64 2.84.4-3deepin3 amd64 GLib library of C routines
ii libglib2.0-bin 2.84.4-3deepin3 amd64 Programs for the GLib library
ii libglib2.0-data 2.84.4-3deepin3 all Common files for GLib library

命令输出略有不同

~$ dpkg -l | grep -E "libqt6core|libglib2.0" | head -5
ii  libglib2.0-0:amd64    2.84.4-3deepin3     amd64        GLib library of C routines
ii  libglib2.0-bin        2.84.4-3deepin3     amd64        Programs for the GLib library
ii  libglib2.0-data       2.84.4-3deepin3     all          Common files for GLib library
ii  libqt6core5compat6:amd64   6.8.0-0deepin1  amd64        Qt 6 Qt5Compat library
ii  libqt6core6:amd64          6.8.0+dfsg-0deepin31     amd64        Qt 6 core module

Reply View the author