Ubuntu 20.04 gnome-shell CPU 使用率持续 20%

Ubuntu 20.04 gnome-shell CPU 使用率持续 20%

刚刚升级到 ubuntu 20.04 gnome-shell 的 CPU 使用率持续保持在 20% 左右。

有什么帮助吗?以下是一些详细信息:

top - 15:01:14 up 48 min,  1 user,  load average: 0.16, 0.63, 0.76
Tasks: 397 total,   1 running, 396 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.2 us,  0.3 sy,  0.0 ni, 97.3 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :  32015.4 total,  17153.7 free,   2707.2 used,  12154.5 buff/cache
MiB Swap:  32668.0 total,  32668.0 free,      0.0 used.  28748.7 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                   
   2709 alan      20   0 4588528 550700 124664 S  21.2   1.7   8:55.91 gnome-shell

查看它在做什么,它似乎花费大部分时间来统计不存在的文件:

strace -C -p 2709

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 54.40    0.233348           2     95108     90024 stat
 10.72    0.045978           3     12340     10326 recvmsg
  7.39    0.031684           4      7780           getpid
  7.20    0.030878           5      5875           poll
  3.84    0.016474           5      2796           writev
  3.38    0.014505          15       942           ioctl
  2.53    0.010840           2      4340      1550 openat
  1.89    0.008100           2      3100           getdents64
  1.81    0.007768           3      2198           read
  1.33    0.005718           1      2869           close
  1.32    0.005682           4      1301        90 futex
  1.17    0.005004           1      2790           fstat
  1.01    0.004339           3      1244           sched_yield
  0.63    0.002720           5       538           write
  0.58    0.002469           3       764           mprotect
  0.43    0.001845           3       511           mmap
  0.36    0.001540           2       640           munmap
  0.00    0.000021           4         5           recvfrom
  0.00    0.000013           1        11           clock_nanosleep
  0.00    0.000003           3         1           restart_syscall
  0.00    0.000001           0         4           getrusage
------ ----------- ----------- --------- --------- ----------------
100.00    0.428930                145157    101990 total

以下是 strace 的一些输出(已编辑):

...
stat("/home/alan/.local/share/icons/hicolor/16x16@2/apps", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/apps", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emotes", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emotes", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/emotes", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
...
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
ioctl(12, _IOC(_IOC_READ|_IOC_WRITE, 0x46, 0x2a, 0x20), 0x7ffc14b2d780) = 0
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\31\0\v\0\367\212\240\2\0\0\0\0! \0\0\367\212\240\2\336\1\0\0006\r\0\0\0\0\0\0"..., iov_len=44}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 44
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\206\20\2\0.\0\340\0\206\t\5\0000\0\340\0\4\0\0\0\0\0\0\0\236\3\0\0\206\3\4\0"..., iov_len=44}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 44
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="T\1&\0360\0\340\0\0\0\0\0\236\3\0\0\0\0\0\0\236\3\0\0:\t#\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=27, events=POLLIN}, {fd=28, events=POLLIN}, {fd=29, events=POLLIN}, {fd=31, events=POLLIN}, {fd=32, events=POLLIN}, {fd=34, events=POLLIN}, {fd=35, events=POLLIN}, {fd=41, events=POLLIN}, {fd=46, events=POLLIN}, {fd=50, events=POLLIN}, {fd=88, events=POLLIN}], 13, 0) = 0 (Timeout)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\31\0\v\0\367\212\240\2\0\0\0\0! \0\0\367\212\240\2\337\1\0\0006\r\0\0\0\0\0\0"..., iov_len=44}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 44
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=27, events=POLLIN}, {fd=28, events=POLLIN}, {fd=29, events=POLLIN}, {fd=31, events=POLLIN}, {fd=32, events=POLLIN}, {fd=34, events=POLLIN}, {fd=35, events=POLLIN}, {fd=41, events=POLLIN}, {fd=46, events=POLLIN}, {fd=50, events=POLLIN}, {fd=88, events=POLLIN}], 13, 74) = 1 ([{fd=31, revents=POLLIN}])
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\34\0'\36\367\212\240\2\241\1\0\0<\t#\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 64
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\24\0\6\0\367\212\240\2\241\1\0\0\6\0\0\0\0\0\0\0\377\377\377\377", iov_len=24}], 1) = 24
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="+\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
poll([{fd=31, events=POLLIN}], 1, -1)   = 1 ([{fd=31, revents=POLLIN}])
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="T\1'\36\377\t\340\0\0\0\0\0007\r\0\0\0\0\0\0007\r\0\0?\t#\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 176
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\201\10\3\0\367\212\240\2\2\0\0\0", iov_len=12}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 12
poll([{fd=31, events=POLLIN}], 1, -1)   = 1 ([{fd=31, revents=POLLIN}])
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\3*\36\2\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 40
write(4, "\1\0\0\0\0\0\0\0", 8)         = 8
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\217\3\4\0\0\n\340\0\0\0\0\0\0\0\0\0", iov_len=16}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 16
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)

请求的扩展数据:

alan@server:~ -[] $ ls -al ~/.local/share/gnome-shell/extensions
total 12
drwxrwxr-x 3 alan alan 4096 May 25  2019 .
drwx------ 3 alan alan 4096 Jun 23 17:10 ..
drwxrwxr-x 3 alan alan 4096 May 25  2019 [email protected]
alan@server:~ -[] $ ls -al /usr/share/gnome-shell/extensions
total 20
drwxr-xr-x 5 root root 4096 Jun 17 18:38 .
drwxr-xr-x 7 root root 4096 Jun 17 18:39 ..
drwxr-xr-x 2 root root 4096 Jun 17 18:38 desktop-icons@csoriano
drwxr-xr-x 3 root root 4096 Jun 17 18:36 [email protected]
drwxr-xr-x 3 root root 4096 Jun 17 18:36 [email protected]

和完整的顶部(快照)

Tasks: 405 total,   1 running, 404 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.5 us,  0.4 sy,  0.0 ni, 96.8 id,  0.1 wa,  0.0 hi,  0.2 si,  0.0 st
MiB Mem :  32015.4 total,  16744.1 free,   3038.5 used,  12232.8 buff/cache
MiB Swap:  32668.0 total,  32668.0 free,      0.0 used.  28377.6 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                       
   2709 alan      20   0 4596140 562652 135088 S  20.9   1.7  33:46.03 gnome-shell                                                                                   
   9822 alan      20   0 4735696 201332  96160 S   3.3   0.6   8:56.20 chrome                                                                                        
   9839 alan      20   0 4793876 197464  89324 S   3.3   0.6   6:19.33 chrome                                                                                        
   2497 root      20   0  197440  68520  47796 S   2.7   0.2   1:43.00 Xorg                                                                                          
   3213 alan      20   0  966064  58144  39524 S   2.3   0.2   1:24.41 gnome-terminal-                                                                               
   9732 alan      20   0 4794584 167996  87708 S   2.3   0.5   4:12.00 chrome                                                                                        
   2973 alan      20   0  417144  31224  24820 S   2.0   0.1   3:49.59 indicator-multi                                                                               
  11800 alan      20   0 4688644 136292  87092 S   1.7   0.4   2:21.77 chrome                                                                                        
   6196 alan      20   0  784460 261128 132512 S   1.3   0.8   3:20.76 chrome                                                                                        
   1434 root     -51   0       0      0      0 S   0.7   0.0   0:51.84 irq/50-nvidia                                                                                 
   6236 alan      20   0  896856 255080  91376 S   0.7   0.8   5:10.00 chrome                                                                                        
      1 root      20   0  168276  12092   8272 S   0.3   0.0   0:03.31 systemd                                                                                       
   1100 systemd+  20   0   24576  13672   9252 S   0.3   0.0   0:01.81 systemd-resolve                                                                               
   1436 root      20   0       0      0      0 S   0.3   0.0   0:08.46 nv_queue                                                                                      
   2411 alan      20   0    9356   6668   4192 S   0.3   0.0   0:32.45 dbus-daemon                                                                                   
   2972 alan      20   0  454696  33432  27780 S   0.3   0.1   0:44.40 indicator-netsp                                                                               
   3030 alan      20   0 7109676 247340  82260 S   0.3   0.8   0:24.37 dropbox                                                                                       
   6238 alan      20   0  356452  97728  66520 S   0.3   0.3   0:37.41 chrome                                                                                        
  11691 root      20   0       0      0      0 I   0.3   0.0   0:00.19 kworker/10:0-events                                                                           
  11832 alan      20   0 4626144 103308  73416 S   0.3   0.3   0:07.15 chrome                                                                                        
  15438 alan      20   0   12396   4344   3396 R   0.3   0.0   0:00.06 top                                                                                           
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kthreadd                                                                                      
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                                                                        
      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp                                                                                    
      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-kblockd                                                                          
      9 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_percpu_wq                                                                                  
     10 root      20   0       0      0      0 S   0.0   0.0   0:00.26 ksoftirqd/0                                                                                   
     11 root      20   0       0      0      0 I   0.0   0.0   0:07.61 rcu_sched                                                                                     
     12 root      rt   0       0      0      0 S   0.0   0.0   0:00.04 migration/0                                                                                   
     13 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/0                                                                                 
     14 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0                                                                                       
     15 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/1                                                                                       
     16 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/1                                                                                 
     17 root      rt   0       0      0      0 S   0.0   0.0   0:00.25 migration/1                                                                                   
     18 root      20   0       0      0      0 S   0.0   0.0   0:00.09 ksoftirqd/1                                                                                   
     20 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/1:0H-kblockd                                                                          
     21 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/2                                                                                       
     22 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/2                                                                                 
     23 root      rt   0       0      0      0 S   0.0   0.0   0:00.25 migration/2                                                                                   

答案1

为了防止有人遇到类似的问题,我在 GNOME Shell 中 CPU 使用率一直达到 80%,因此我在 20.04 版本中关闭了各种扩展进行测试。

事实证明,我在右上角的侧栏中有一个性能监视器(系统负载监视器)——一旦退出,一切都恢复正常。如果有人对如何诊断有什么建议,我很乐意测试。

答案2

这似乎是一个大问题,我没有加载任何扩展并且它在空闲时占用了 40% 的 CPU。

在此处输入图片描述

但是我禁用了 Wayland,它就降到 1% 以下了。

在此处输入图片描述

我使用这个禁用了它:https://askubuntu.com/a/968265/78252

如果你想永久执行此操作,请编辑

/etc/gdm3/custom.conf 并取消注释该行

通过删除前面的 # 来 #WaylandEnable=false。

保存文件,然后重新启动时,您将永远不会看到询问使用哪个会话的齿轮。

答案3

我遇到了类似的问题,并通过使用该tweaks程序并禁用动画解决了它。

这使得空转负载从恒定的 60% 降低至零。

答案4

类似的问题让我想到了这里。我发现在后台打开蓝牙设置窗口,开启蓝牙无线电,gnome-shell 的 CPU 时间保持在 40% 左右,对我来说是 +/- 5%。配对不会改变 CPU 使用率,所以这似乎不是持续扫描的结果。关闭设置窗口或更改为蓝牙以外的其他设置,如 WiFi 或鼠标设置,CPU 使用率会立即降至 0% 左右。

相关内容