什麼討厭的 systemd-udevd 讓我的 CPU 過載?

什麼討厭的 systemd-udevd 讓我的 CPU 過載?

Top會給我以下資訊:(PID 28055 的 94% CPU 負載)

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                            
28055 root      39  19 1295192 1,167g   3120 R  93,8  7,5  65:49.38 systemd-udevd   

當我這樣做時,strace -p 28055我會得到以下幾行無限重複:

getrandom("\246\306\216<\340\244a\256|\34\352\257\334\223\227\304", 16, GRND_NONBLOCK) = 16
getrandom("j\216\331 \361|X\241\333\270\260\202\377\224\3537", 16, GRND_NONBLOCK) = 16
getrandom("\36\301\27vkE\351\16\336\23\314\366y\t\272\307", 16, GRND_NONBLOCK) = 16
getrandom("U\234\235\2763\3257\37\314q\301\272i\301W\t", 16, GRND_NONBLOCK) = 16
getrandom("\223\27\244\26\365\251\335\263\233.\347\3\263]\205\4", 16, GRND_NONBLOCK) = 16
getrandom("\366,{+Tt\t\27\16z\257N^\235r,", 16, GRND_NONBLOCK) = 16
epoll_wait(10, [{EPOLLIN, {u32=798983008, u64=94889511453536}}], 11, 0) = 1
clock_gettime(CLOCK_BOOTTIME, {7011, 470364038}) = 0
epoll_wait(10, [{EPOLLIN, {u32=798983008, u64=94889511453536}}], 11, 0) = 1
clock_gettime(CLOCK_BOOTTIME, {7011, 470404228}) = 0
recvmsg(4, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000001}, msg_iov(1)=[{"change@/devices/pci0000:00/0000:"..., 8192}], msg_controllen=32, [{cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, {pid=0, uid=0, gid=0}}], msg_flags=0}, 0) = 299

udevadm monitor將給出這些行,它也會無限重複:

KERNEL[66275.112602] change   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)

我不知道問題出在哪裡。有什麼建議可以繼續檢查這個問題嗎?謝謝...

Ubuntu 16.04,64 位,4.13.0-37-通用

PS:問題從 StackOverflow 移至此處。論壇上其他類似問題的報告並沒有給出任何真正的解決方案。

PS2:在第一條評論後新增了命令輸出。起初我省略了它們,因為我不相信它們與第一個問題有任何联系,但現在我不再確定。因此,這裡有一些更多的測試:

journalctl

Mar 20 10:58:36 cosy kernel: sd 4:0:0:0: ioctl_internal_command return code = 8000002
Mar 20 10:58:36 cosy kernel: sd 4:0:0:0: Sense Key : Aborted Command [current]
Mar 20 10:58:36 cosy kernel: sd 4:0:0:0: Add. Sense: No additional sense information
Mar 20 10:58:36 cosy systemd-udevd[382]: inotify_add_watch(9, /dev/sdb1, 10) failed: No such file or directory

(上面的輸出會無限重複)

dmesg

[72070.670913]  sdb: sdb1
[72070.745597] sd 4:0:0:0: ioctl_internal_command return code = 8000002
[72070.745600] sd 4:0:0:0: Sense Key : Aborted Command [current] 
[72070.745601] sd 4:0:0:0: Add. Sense: No additional sense information
[72070.747604] sdb: detected capacity change from 681574400 to 0
[72070.991468] sd 4:0:0:0: ioctl_internal_command return code = 8000002

/lib/systemd/systemd-udevd -D

adding watch on '/dev/sdb'
created db file '/run/udev/data/b8:16' for '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0/host4/target4:0:0/4:0:0:0/block/sdb'
passed device to netlink monitor 0x556a9c04b5d0
seq 4896728 processed
passed 282 byte device to netlink monitor 0x556a9c051740seq 4896729 running

removing watch on '/dev/sdb1'
value '[dmi/id]sys_vendor' is 'System manufacturer'
value '[dmi/id]sys_vendor' is 'System manufacturer'
no reference left, remove '/dev/disk/by-id/usb-BUFFALO_HD-HXU3_00000204B9AC-0:0-part1'
no reference left, remove '/dev/disk/by-label/UTIL_HDHXU3'
no reference left, remove '/dev/disk/by-path/pci-0000:00:1d.0-usb-0:1.4:1.0-scsi-0:0:0:0-part1'
no reference left, remove '/dev/disk/by-uuid/6BA5-31BF'
passed device to netlink monitor 0x556a9c04b5d0
seq 4896729 processed
passed 263 byte device to netlink monitor 0x556a9c051740
^Cseq 4896730 running
removing watch on '/dev/sdb'
value '[dmi/id]sys_vendor' is 'System manufacturer'
value '[dmi/id]sys_vendor' is 'System manufacturer'
IMPORT builtin 'usb_id' /lib/udev/rules.d/60-persistent-storage.rules:41
/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0: if_class 8 protocol 6
LINK 'disk/by-id/usb-BUFFALO_HD-HXU3_00000204B9AC-0:0' /lib/udev/rules.d/60-persistent-storage.rules:46
IMPORT builtin 'path_id' /lib/udev/rules.d/60-persistent-storage.rules:64
LINK 'disk/by-path/pci-0000:00:1d.0-usb-0:1.4:1.0-scsi-0:0:0:0' /lib/udev/rules.d/60-persistent-storage.rules:65
IMPORT builtin 'blkid' /lib/udev/rules.d/60-persistent-storage.rules:76
probe /dev/sdb raid offset=0
handling device node '/dev/sdb', devnum=b8:16, mode=0600, uid=0, gid=0
preserve already existing symlink '/dev/block/8:16' to '../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fusb-BUFFALO_HD-HXU3_00000204B9AC-0:0'
creating link '/dev/disk/by-id/usb-BUFFALO_HD-HXU3_00000204B9AC-0:0' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-id/usb-BUFFALO_HD-HXU3_00000204B9AC-0:0' to '../../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-path\x2fpci-0000:00:1d.0-usb-0:1.4:1.0-scsi-0:0:0:0'
creating link '/dev/disk/by-path/pci-0000:00:1d.0-usb-0:1.4:1.0-scsi-0:0:0:0' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-path/pci-0000:00:1d.0-usb-0:1.4:1.0-scsi-0:0:0:0' to '../../sdb'
created db file '/run/udev/data/b8:16' for '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0/host4/target4:0:0/4:0:0:0/block/sdb'

現在我猜它與 USB 外部硬碟有關。但我也需要它...

答案1

對於我的戴爾筆記型電腦,此問題是由觸控板引起的。

$ udevadm monitor
Eyl 03 22:02:58 Inspiron systemd-udevd[380]: Process 'hid2hci
--method=dell --devpath=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6.2/2-1.6.2:1.0' failed with exit code 1.

$ cat /sys/bus/usb/devices/2-1/2-1.6/2-1.6.2/id*
8162 413c

$ lsusb -d 413c:8162
Bus 002 Device 006:  ID 413c:8162 Dell Computer Corp. Integrated Touchpad [Synaptics]

停止systemd-udevd

sudo systemctl stop systemd-udevd systemd-udevd-control.socket systemd-udevd-kernel.socket

欲了解更多資訊:

相關內容