我正在运行 Ubuntu 20.04.5 LTS 并使用 gnome-classic 桌面(因为我被困住了)。每次我首次登录时,我总是注意到 dbus-daemon 的 CPU 占用率会高出几分钟,但之后总会稳定在可接受的水平。然而,在过去的几天里,dbus-daemon 和 system-udevd 一直占用 50% 的 CPU,并且在笔记本电脑运行时一直没有稳定下来,导致风扇不断运转。
我运行了该程序dbus-monitor --system
,它给出了非常快速的消息假脱机运行,如下面的摘录:
signal time=1676894325.355898 sender=org.freedesktop.DBus -> destination=:1.245 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
string ":1.245"
signal time=1676894325.365912 sender=:1.1 -> destination=(null destination) serial=4880989 path=/org/freedesktop/systemd1/unit/sys_2ddevices_2dvirtual_2dblock_2ddm_5cx2d2_2edevice; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "org.freedesktop.systemd1.Device"
array [
dict entry(
string "SysFSPath"
variant string "/sys/devices/virtual/block/dm-2"
)
]
array [
]
signal time=1676894325.366042 sender=:1.1 -> destination=(null destination) serial=4880990 path=/org/freedesktop/systemd1/unit/sys_2ddevices_2dvirtual_2dblock_2ddm_5cx2d2_2edevice; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "org.freedesktop.systemd1.Unit"
array [
dict entry(
string "ActiveState"
variant string "active"
)
dict entry(
string "SubState"
variant string "plugged"
)
dict entry(
string "StateChangeTimestamp"
variant uint64 1676892339266329
)
dict entry(
string "StateChangeTimestampMonotonic"
variant uint64 19734942
)
dict entry(
string "InactiveExitTimestamp"
variant uint64 1676892339266329
)
dict entry(
string "InactiveExitTimestampMonotonic"
variant uint64 19734942
)
dict entry(
string "ActiveEnterTimestamp"
variant uint64 1676892339266329
)
dict entry(
string "ActiveEnterTimestampMonotonic"
variant uint64 19734942
)
dict entry(
string "ActiveExitTimestamp"
variant uint64 0
)
dict entry(
string "ActiveExitTimestampMonotonic"
variant uint64 0
)
dict entry(
string "InactiveEnterTimestamp"
variant uint64 0
)
dict entry(
string "InactiveEnterTimestampMonotonic"
variant uint64 0
)
dict entry(
string "Job"
variant struct {
uint32 0
object path "/"
}
)
dict entry(
string "ConditionResult"
variant boolean false
)
dict entry(
string "AssertResult"
variant boolean false
)
dict entry(
string "ConditionTimestamp"
variant uint64 0
)
dict entry(
string "ConditionTimestampMonotonic"
variant uint64 0
)
dict entry(
string "AssertTimestamp"
variant uint64 0
)
dict entry(
string "AssertTimestampMonotonic"
variant uint64 0
)
dict entry(
string "InvocationID"
variant array of bytes [
4c 6f ff 28 3e 58 4e 6e 81 82 b3 1c 0c 83 82 3b
]
)
]
array [
string "Conditions"
string "Asserts"
]
signal time=1676894325.366191 sender=:1.1 -> destination=(null destination) serial=4880991 path=/org/freedesktop/systemd1/unit/dev_2ddm_5cx2d2_2edevice; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "org.freedesktop.systemd1.Device"
array [
dict entry(
string "SysFSPath"
variant string "/sys/devices/virtual/block/dm-2"
)
]
array [
]
signal time=1676894325.366431 sender=:1.1 -> destination=(null destination) serial=4880992 path=/org/freedesktop/systemd1/unit/dev_2ddm_5cx2d2_2edevice; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "org.freedesktop.systemd1.Unit"
array [
dict entry(
string "ActiveState"
variant string "active"
)
dict entry(
string "SubState"
variant string "plugged"
)
dict entry(
string "StateChangeTimestamp"
variant uint64 1676892339266328
)
dict entry(
string "StateChangeTimestampMonotonic"
variant uint64 19734941
)
dict entry(
string "InactiveExitTimestamp"
variant uint64 1676892339266328
)
dict entry(
string "InactiveExitTimestampMonotonic"
variant uint64 19734941
)
dict entry(
string "ActiveEnterTimestamp"
variant uint64 1676892339266328
)
dict entry(
string "ActiveEnterTimestampMonotonic"
variant uint64 19734941
)
dict entry(
string "ActiveExitTimestamp"
variant uint64 0
)
dict entry(
string "ActiveExitTimestampMonotonic"
variant uint64 0
)
dict entry(
string "InactiveEnterTimestamp"
variant uint64 0
)
dict entry(
string "InactiveEnterTimestampMonotonic"
variant uint64 0
)
dict entry(
string "Job"
variant struct {
uint32 0
object path "/"
}
)
dict entry(
string "ConditionResult"
variant boolean false
)
dict entry(
string "AssertResult"
variant boolean false
)
dict entry(
string "ConditionTimestamp"
variant uint64 0
)
dict entry(
string "ConditionTimestampMonotonic"
variant uint64 0
)
dict entry(
string "AssertTimestamp"
variant uint64 0
)
dict entry(
string "AssertTimestampMonotonic"
variant uint64 0
)
dict entry(
string "InvocationID"
variant array of bytes [
0c b8 d1 90 42 3e 45 b6 88 f3 71 6e 66 1e 83 c5
]
)
]
array [
string "Conditions"
string "Asserts"
]
跑步也udevadm monitor
给出了类似的信息流,尽管速度没有那么快,就像这样:
KERNEL[2188.932041] change /devices/virtual/block/dm-2 (block)
UDEV [2188.940914] change /devices/virtual/block/dm-2 (block)
KERNEL[2188.945441] change /devices/virtual/block/dm-2 (block)
UDEV [2188.957689] change /devices/virtual/block/dm-2 (block)
KERNEL[2188.961225] change /devices/virtual/block/dm-2 (block)
UDEV [2188.969813] change /devices/virtual/block/dm-2 (block)
KERNEL[2188.974779] change /devices/virtual/block/dm-2 (block)
dm-2
显然是由于某种原因造成的。 dm-2
是我的主分区:
~$ ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 236 Feb 20 11:25 control
lrwxrwxrwx 1 root root 7 Feb 20 12:02 home -> ../dm-2
lrwxrwxrwx 1 root root 7 Feb 20 11:25 sda3_crypt -> ../dm-0
lrwxrwxrwx 1 root root 7 Feb 20 11:25 swap -> ../dm-1
我对 dbus 和 udev 的理解至少可以说是有限的,但通过谷歌搜索,我发现这个帖子建议我创建一个/etc/udev/rulesd/90-fixdm.rules
包含以下内容的文件
ACTION=="add|change", KERNEL=="dm-*", OPTIONS:="nowatch"
这确实立即平息了这两个进程,并让我的 CPU 周期恢复正常(并停止了笔记本电脑风扇的持续运转)。然而,第二天笔记本电脑无法启动,挂在“等待 /dev/mapper/swap”作业上,而该作业从未启动。后来我慌乱地使用 Live-Ubuntu 棒删除了文件,/etc/udev/rulesd/90-fixdm.rules
我又回到了原点 - 笔记本电脑再次启动,但 CPU 使用率高的问题dbus-daemon
又system-udevd
出现了。
可能发生了什么变化导致了这种新行为?我该怎么做才能解决这个问题?
谢谢。
答案1
看起来我已经成功解决了这个问题。
一位朋友向我推荐这个问题关于 EXT4 的 MMP 功能。检查相关设备后tune2fs -l /dev/dm-2 | grep -i mmp
发现,该文件系统(而非其他文件系统)启用了 MMP:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit mmp flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
我认为我不需要 MMP 功能,因此我尝试注销并以 root 身份进行控制台登录,以便可以卸载/home
,但即使卸载了它,我也无法删除 mmp 标志,因为它始终显示该设备正在使用中(据我所知,事实并非如此)。我必须在恢复模式下重新启动并进入 root shell,然后我才能使用以下命令删除 MMP 标志:
# umount /dev/dm-2
# tune2fs -O ^mmp /dev/dm-2
然后我重新启动并正常登录,现在我运行时不再有 dbus-daemon 和 systemd-udevd 的高 CPU 使用率,并且运行时udevadm monitor
不再产生无休止的消息流。
我只想说,因为这个答案上述相关问题提到这是较新版本的问题udisks2
,但表明已修复我的20.04.05LTS安装似乎有版本2.8.4-1ubuntu2
,同样该答案下的评论表明2.9.2-2+deb11u1
仍然存在同样的问题。