斯特雷斯

斯特雷斯

当我在 KDE 中运行一些程序并且不执行任何操作时,我仍然有 Xorg 和plasmashell,每个程序占用了大约 11% 的 CPU 核心。kwin_x11另外需要 6%。与其他后台作业一起,我进入了空闲状态下系统总负载的 12% 区域。这意味着我的笔记本电脑的风扇永远不会降到最低水平。

当显然没有发生任何事情时,我如何找出导致此负载的原因?

斯特雷斯

Xorg 上的 strace

我以 root 身份连接straceXorg让它运行大约三秒钟。这次我检索到了 8273 行输出。这似乎是以下块的重复:

strace: Process 1255 attached
strace: [ Process PID=1255 runs in x32 mode. ]
strace: [ Process PID=1255 runs in 64 bit mode. ]
writev(58, [{iov_base="Z\3Mg\37+\7\2\"+\7\2\2\235z\0\0\0\0\0008\4\200\7\200\7\0\0008\4\200\7", iov_len=32}], 1) = 32
ioctl(24, DRM_IOCTL_I915_GEM_EXECBUFFER2, 0x7ffd622230e0) = 0
ioctl(24, DRM_IOCTL_I915_GEM_THROTTLE or DRM_IOCTL_RADEON_CP_RESUME, 0) = 0
ioctl(24, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd62223034) = 0
ioctl(24, DRM_IOCTL_I915_GEM_BUSY, 0x7ffd62222fd0) = 0
ioctl(24, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd62223040) = 0
getpid()                                = 1255
epoll_wait(3, [{EPOLLIN, {u32=48152672, u64=48152672}}], 256, 630) = 1
setitimer(ITIMER_REAL, {it_interval={tv_sec=0, tv_usec=5000}, it_value={tv_sec=0, tv_usec=5000}}, NULL) = 0
recvmsg(56, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\224\2\6\0\347_\305\1\16\0\300\1\0\0\0\0\200\0078\4\0\36  \224\4\4\0\347_\305\1"..., iov_len=16384}], msg_iovlen=1, msg_control=[{cmsg_len=24, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[106, 107]}], msg_controllen=24, msg_flags=0}, 0) = 40
ioctl(24, DRM_IOCTL_PRIME_FD_TO_HANDLE, 0x7ffd62223f3c) = 0
lseek(106, 0, SEEK_END)                 = 8388608
ioctl(24, DRM_IOCTL_I915_GEM_GET_TILING, 0x7ffd62223f70) = 0
getpid()                                = 1255
close(106)                              = 0
fcntl(107, F_DUPFD_CLOEXEC, 2048)       = -1 EINVAL (Invalid argument)
mmap(NULL, 4, PROT_READ|PROT_WRITE, MAP_SHARED, 107, 0) = 0x7fca1cb29000
recvmsg(56, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
setitimer(ITIMER_REAL, {it_interval={tv_sec=0, tv_usec=0}, it_value={tv_sec=0, tv_usec=0}}, NULL) = 0
epoll_wait(3, [{EPOLLIN, {u32=48152672, u64=48152672}}], 256, 627) = 1
setitimer(ITIMER_REAL, {it_interval={tv_sec=0, tv_usec=5000}, it_value={tv_sec=0, tv_usec=5000}}, NULL) = 0
recvmsg(56, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\223\1\22\0\16\0\300\1\347_\305\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=16384}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 80
ioctl(24, DRM_IOCTL_WAIT_VBLANK, 0x7ffd62224110) = 0
ioctl(24, DRM_IOCTL_WAIT_VBLANK, 0x7ffd62224050) = 0
ioctl(24, DRM_IOCTL_WAIT_VBLANK, 0x7ffd622240f0) = 0
writev(56, [{iov_base="\1 \313\322\0\0\0\0\1\1\0\0\0\0\0\0008\4\200\7\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=32}], 1) = 32
recvmsg(56, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
setitimer(ITIMER_REAL, {it_interval={tv_sec=0, tv_usec=0}, it_value={tv_sec=0, tv_usec=0}}, NULL) = 0
epoll_wait(3, [{EPOLLIN, {u32=48175088, u64=48175088}}, {EPOLLIN, {u32=59512640, u64=59512640}}, {EPOLLIN, {u32=39795904, u64=39795904}}], 256, 623) = 3
read(24, "\1\0\0\0 \0\0\0\21\334\10\0\0\0\0\0c\37\0\0\346\36\t\0\232u\4\0\0\0\0\0", 1024) = 32
ioctl(24, DRM_IOCTL_GEM_CLOSE, 0x7ffd62222928) = 0

在下面,我对输出进行了排序,并且只采用了唯一的行(2341)。然后我删除了仅在数字或字符串参数上有所不同的行,以便人们可以对正在发生的事情有一个概述:

close(106)                              = 0
close(107)                              = 0
epoll_wait(3, [], 256, 0)               = 0
epoll_wait(3, [{EPOLLIN, {u32=39795904, u64=39795904}}], 256, 0) = 1
epoll_wait(3, [{EPOLLIN, {u32=39795904, u64=39795904}}, {EPOLLIN, {u32=44232592, u64=44232592}}], 256, 299613) = 2
epoll_wait(3, [{EPOLLIN, {u32=39795904, u64=39795904}}, {EPOLLIN, {u32=44232592, u64=44232592}}, {EPOLLIN, {u32=48152672, u64=48152672}}], 256, 0) = 3
epoll_wait(3, [{EPOLLIN, {u32=44232592, u64=44232592}}, {EPOLLIN, {u32=39795904, u64=39795904}}, {EPOLLIN, {u32=59512640, u64=59512640}}, {EPOLLIN, {u32=48167840, u64=48167840}}, {EPOLLIN, {u32=48298384, u64=48298384}}, {EPOLLIN, {u32=48175088, u64=48175088}}], 256, 0) = 6
fcntl(107, F_DUPFD_CLOEXEC, 2048)       = -1 EINVAL (Invalid argument)
getpid()                                = 1255
ioctl(24, DRM_IOCTL_GEM_CLOSE, 0x7ffd62222928) = 0
ioctl(24, DRM_IOCTL_I915_GEM_BUSY, 0x7ffd62222fd0) = 0
ioctl(24, DRM_IOCTL_I915_GEM_CREATE, 0x7ffd62223800) = 0
ioctl(24, DRM_IOCTL_I915_GEM_EXECBUFFER2, 0x7ffd622230e0) = 0
ioctl(24, DRM_IOCTL_I915_GEM_GET_TILING, 0x7ffd62223f70) = 0
ioctl(24, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd62222b84) = 0
ioctl(24, DRM_IOCTL_I915_GEM_PWRITE, 0x7ffd62223820) = 0
ioctl(24, DRM_IOCTL_I915_GEM_SET_DOMAIN, 0x7ffd622237f4) = 0
ioctl(24, DRM_IOCTL_I915_GEM_THROTTLE or DRM_IOCTL_RADEON_CP_RESUME, 0) = 0
ioctl(24, DRM_IOCTL_I915_GEM_THROTTLE or DRM_IOCTL_RADEON_CP_RESUME, 0) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
ioctl(24, DRM_IOCTL_MODE_DIRTYFB, 0x7ffd622240b0) = 0
ioctl(24, DRM_IOCTL_MODE_SETGAMMA, 0x7ffd62224250) = 0
ioctl(24, DRM_IOCTL_PRIME_FD_TO_HANDLE, 0x7ffd62223f3c) = 0
ioctl(24, DRM_IOCTL_WAIT_VBLANK, 0x7ffd62224050) = 0
ioctl(24, DRM_IOCTL_WAIT_VBLANKstrace: Process 1255 detached
lseek(106, 0, SEEK_END)                 = 10485760
mmap(NULL, 4, PROT_READ|PROT_WRITE, MAP_SHARED, 107, 0) = 0x7fca1cb29000
mremap(0x7fca1604b000, 126976, 20480, MREMAP_MAYMOVE) = 0x7fca1604b000
munmap(0x7fca16219000, 524288)          = 0
read(24, "\1\0\0\0 \0\0\0000\334\10\0\0\0\0\0d\37\0\0\207L\4\0@X\7\0\0\0\0\0", 1024) = 32
read(27, "\0", 40)                      = 1
recvmsg(101, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(101, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="+\0\1\0", iov_len=16384}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 4
recvmsg(101, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\22\0\n\0\6\0\0\6'\0\0\0\37\0\0\0\10\21\4\0\20\0\0\0~/home/m"..., iov_len=16384}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 68
recvmsg(56, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(56, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\16\0\2\0!\0\300\1", iov_len=16384}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 8
recvmsg(56, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\16\0\2\0\6\0\0\6(\0\4\0\6\0\0\6\1\1\0\0\0\0\0\0", iov_len=16384}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 24
recvmsg(56, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\223\1\22\0\243-\304\1Y`\305\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=16384}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 72
recvmsg(56, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\224\2\6\0z`\305\1\16\0\300\1\0\0\0\0\200\0078\4\0\36  \224\4\4\0z`\305\1"..., iov_len=16384}], msg_iovlen=1, msg_control=[{cmsg_len=24, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[106, 107]}], msg_controllen=24, msg_flags=0}, 0) = 40
rt_sigreturn({mask=[]})                 = 0
setitimer(ITIMER_REAL, {it_interval={tv_sec=0, tv_usec=0}, it_value={tv_sec=0, tv_usec=0}}, NULL) = 0
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
strace: Process 1255 attached
strace: [ Process PID=1255 runs in 64 bit mode. ]
strace: [ Process PID=1255 runs in x32 mode. ]
writev(101, [{iov_base="\0026\353\7\241\250z\0\1\1\0\0\6\0\0\6\0\0\0\0\24\n4\1\224\2\27\1\4\0\1\0", iov_len=32}], 1) = 32
writev(56, [{iov_base="4d4058d4-7455-406b-b370-76d3c09f"..., iov_len=36}], 1) = 36
writev(56, [{iov_base="~/home/mu : bash \342\200\224 Konsole", iov_len=28}], 1) = 28
writev(56, [{iov_base="konsole\0konsole\0", iov_len=16}], 1) = 16
writev(56, [{iov_base="org.kde.konsole", iov_len=15}, {iov_base="\0", iov_len=1}], 2) = 16
writev(58, [{iov_base="~/home/mu : bash \342\200\224 Konsole", iov_len=28}], 1) = 28
writev(58, [{iov_base="k\246z\0", iov_len=4}], 1) = 4

Plasshell 上的 strace

负载也很高plasmashell,开头strace是这样的:

strace: Process 7633 attached
futex(0x7ffd1144c0f8, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x556189417398, FUTEX_WAKE_PRIVATE, 1) = 0
munmap(0x7f9c94603000, 4)               = 0
ioctl(16, DRM_IOCTL_GEM_CLOSE, 0x7ffd1144bfc8) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c094) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c084) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c094) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{iov_base="6\0\2\0\315\5\350\1\206\21\2\0\316\5\350\1\223\3\4\0\314\5\350\1kf\344\1\0\0\0\0"..., iov_len=64}], 1) = 64
futex(0x5561894173e8, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x556189417398, FUTEX_WAKE_PRIVATE, 1) = 1
poll([{fd=3, events=POLLIN}], 1, -1)    = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\0\336_\0\0\0\0\0\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) = 64
futex(0x5561894173ec, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x556189417398, FUTEX_WAKE_PRIVATE, 1) = 1
memfd_create("xshmfence", MFD_CLOEXEC|MFD_ALLOW_SEALING) = 31
ftruncate(31, 4)                        = 0
mmap(NULL, 4, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0) = 0x7f9c94603000
ioctl(16, DRM_IOCTL_I915_GEM_BUSY, 0x7ffd1144bd70) = 0
ioctl(16, DRM_IOCTL_I915_GEM_CREATE, 0x7ffd1144bde0) = 0
ioctl(16, DRM_IOCTL_I915_GEM_SET_TILING, 0x7ffd1144bd30) = 0
ioctl(16, DRM_IOCTL_I915_GEM_SET_DOMAIN, 0x7ffd1144bdd4) = 0
ioctl(16, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffd1144bf1c) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
sendmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\224\2\6\0\320\5\350\1\16\0\340\1\0\0\0\0\200\0078\4\0\36  \224\4\4\0\320\5\350\1"..., iov_len=40}], msg_iovlen=1, msg_control=[{cmsg_len=24, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[34, 31]}], msg_controllen=24, msg_flags=0}, 0) = 40
close(34)                               = 0
close(31)                               = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144bda0) = 0
ioctl(16, DRM_IOCTL_I915_GEM_SET_TILING, 0x7ffd1144bcf0) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144bd10) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144bda0) = 0
ioctl(16, DRM_IOCTL_I915_GEM_SET_TILING, 0x7ffd1144bcf0) = 0
getpid()                                = 7633
getpid()                                = 7633
ioctl(16, DRM_IOCTL_I915_GEM_EXECBUFFER2, 0x7ffd1144c380) = 0
ioctl(16, DRM_IOCTL_I915_GEM_WAIT or DRM_IOCTL_RADEON_GEM_OP, 0x7ffd1144c330) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c2f4) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c2d4) = 0
ioctl(16, DRM_IOCTL_I915_GEM_BUSY, 0x7ffd1144c270) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c2e0) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{iov_base="\223\1\22\0\16\0\340\1\320\5\350\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=72}], 1) = 72
getpid()                                = 7633
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{iov_base="\16\0\2\0kf\344\1", iov_len=8}], 1) = 8
futex(0x556189417398, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x556189417398, FUTEX_WAKE_PRIVATE, 1) = 0
munmap(0x7f9c94603000, 4)               = 0
ioctl(16, DRM_IOCTL_GEM_CLOSE, 0x7ffd1144bfc8) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c094) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c084) = 0
ioctl(16, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffd1144c094) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{iov_base="6\0\2\0\320\5\350\1\206\21\2\0\321\5\350\1\223\3\4\0\317\5\350\1\16\0\340\1\0\0\0\0"..., iov_len=64}], 1) = 64
futex(0x7ffd1144bf48, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x556189417398, FUTEX_WAKE_PRIVATE, 1) = 0
memfd_create("xshmfence", MFD_CLOEXEC|MFD_ALLOW_SEALING) = 31
ftruncate(31, 4)                        = 0
mmap(NULL, 4, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0) = 0x7f9c94603000
ioctl(16, DRM_IOCTL_I915_GEM_CREATE, 0x7ffd1144bde0) = 0
ioctl(16, DRM_IOCTL_I915_GEM_SET_TILING, 0x7ffd1144bd30) = 0

Plasmashell 在大约三秒内显示了 16008 行,它对输入的响应速度非常慢。

xrandr --当前

xrandr --current这是当 Plasmashell 占用整个 CPU 核心时的输出:

Screen 0: minimum 320 x 200, current 3000 x 1920, maximum 8192 x 8192
LVDS-1 connected (normal left inverted right x axis y axis)
   1366x768      60.02 +
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
VGA-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 connected 1080x1920+1920+0 left (normal left inverted right x axis y axis) 509mm x 286mm
   1920x1080     60.00*+
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   640x480       75.00    59.94  
   720x400       70.08  
HDMI-2 disconnected (normal left inverted right x axis y axis)
HDMI-3 disconnected (normal left inverted right x axis y axis)
DP-2 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 509mm x 286mm
   1920x1080     60.00*+
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   640x480       75.00    59.94  
   720x400       70.08  
DP-3 disconnected (normal left inverted right x axis y axis)

相关内容