Score:2

High CPU usage by dbus-daemon and systemd-udevd relating to home partition

cn flag

I'm running Ubuntu 20.04.5 LTS and using the gnome-classic desktop (because I'm stuck in my ways). I've always noticed a few minutes of high CPU from dbus-daemon when I initially log in, but it always then settles down to an acceptable level. Over the last couple of days, however, dbus-daemon and system-udevd have accounted for a constant 50% of CPU and haven't settled whilst the laptop has been running, causing the fan to run constantly.

I ran dbus-monitor --system which gave a very fast spooling run of messages, like the excerpt below:

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"
   ]

Running udevadm monitor gave a similar, although not quite as fast flow of messages, like this:

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 is clearly to blame for some reason. dm-2 is my home partition:

~$ 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

My understanding of dbus and udev is limited to say the least, but a bit of googling lead me to this post which suggested I create a file /etc/udev/rulesd/90-fixdm.rules which contained

ACTION=="add|change", KERNEL=="dm-*", OPTIONS:="nowatch"

This did indeed instantly calm the two processes and gave me my CPU cycles back (and stopped the laptop fan from constantly running). However, the next day the laptop failed to boot, hanging at a "waiting for /dev/mapper/swap" job that was never starting. One panicked use of a Live-Ubuntu stick to remove the file from /etc/udev/rulesd/90-fixdm.rules later and I'm back to square one - the laptop boots again, but the high CPU usage from dbus-daemon and system-udevd has returned.

What might have changed to cause this new behaviour, and what can I do to remedy the problem?

Thanks.

Score:3
cn flag

It looks like I've managed to fix the issue.

A friend pointed me towards this question about the MMP feature of EXT4. Checking the device in question with tune2fs -l /dev/dm-2 | grep -i mmp showed that this (and no other) filesystems did have MMP enabled:

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

I can't think that I have any need for the MMP functionality, so I tried logging out and doing a console log-in as root so that I could unmount /home, but even with it unmounted I wasn't able to remove the mmp flag as it always stated the device was in use (as far as I could tell, it wasn't). I had to reboot in recovery mode and drop to a root shell, and only then was I able to remove the MMP flag with:

# umount /dev/dm-2
# tune2fs -O ^mmp /dev/dm-2

I then rebooted and logged in as normal and I am now running without the high CPU usage of dbus-daemon and systemd-udevd and running udevadm monitor no longer gives the endless flow of messages.

I will just mention that since this answer to the above related question mentions that it's an issue with newer versions of udisks2, but suggests it has been fixed that my 20.04.05LTS installation appears to have version 2.8.4-1ubuntu2, and similarly a comment under that answer suggests that 2.9.2-2+deb11u1 also still has the same issue.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.