You are not logged in.

#1 2011-07-19 17:22:01

apefish
Member
From: Vancouver
Registered: 2010-07-13
Posts: 47

UDev growing huge and eating cpu

I copied the udev automount rule from the wiki page.
It works, but when it mounts a usb drive, udev starts using a lot of cpu (100% sometimes)
and it makes a few copies of itself and uses alot of memory. I unplugged the drive
to see if that would stop it; it's sortof stopped growing, but the 5 udev instances are collectively
using 171 Mb and ~40% cpu right now.
Here's the output of top right now showing the friendly udevs:

  251 root      20   0 50336  47m  680 S   12  4.8  17:00.27 udevd                                                                                                                                                                
32218 root      20   0 33964  31m  436 S    0  3.2   0:00.44 udevd                                                                                                                                                                
29229 root      20   0 33400  31m  448 S   16  3.1   3:35.89 udevd                                                                                                                                                                
11486 root      20   0 33400  31m  404 S    0  3.1   0:00.51 udevd                                                                                                                                                                
 2634 root      20   0 33400  31m  380 S    0  3.1   0:00.58 udevd   

Here's the rule I used

 KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="%k"

# Global mount options
ACTION=="add", ENV{mount_options}="noatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -m 777 -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit
LABEL="media_by_label_auto_mount_end"

The drive is a 1GB usb flash, no history of trouble. My computer is an eee 1101HA 1Gb ram, 1333 Mhz cpu, if that helps.
Does anyone know why this is happening?

PS: The two udevs that were sucking cpu just died, the other three are using 93Mb and no cpu.

EDIT: This problem, or something like it seems to have been around for a while
I found lots of discussion in 2009, but still mentions of it in 2011.

https://bbs.archlinux.org/viewtopic.php?id=78946&p=3

I can't find any mention of a usable fix.

Last edited by apefish (2011-07-19 17:56:52)

Offline

#2 2011-07-19 18:25:07

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: UDev growing huge and eating cpu

What happens if you delete the rule and use a program like devmon or udiskie instead?

Offline

#3 2011-07-19 20:15:31

apefish
Member
From: Vancouver
Registered: 2010-07-13
Posts: 47

Re: UDev growing huge and eating cpu

diskie and devmon require a lot more installs and configs, so I'll approach that slowly.

EDIT: cut some incorrect stuff

I looked into it more, it actually has nothing to do with the udev rule. I did some tests:

With a fresh boot and no custom rules, udev expands constantly after I plug in the device,
Taking 10 mins to reach 16M memory use, with no sign of stopping (it got to 170M earlier).
CPU usage of the expanding process goes up proportionally as well (to 26 in this case, 100% before)
child processes uses CPU constantly at ~13%. 8 minutes after i unplug the device, everything
finally settles down (it's not a memory leak).

Here's the interesting data points:

19:45 Fresh boot with empty /etc/udev/rules.d. 3 udev processes:

    248 root      20   0  2288 1004  680 S    0  0.1   0:00.25 udevd
    276 root      20   0  2188  696  436 S    0  0.1   0:00.00 udevd
    277 root      20   0  2188  664  408 S    0  0.1   0:00.00 udevd

19:48 plugged in drive, udev forks:

    248  root      20   0  2684 1300  680 S    2  0.1   0:00.63 udevd
    276  root      20   0  2188  724  448 S   13  0.1   0:02.68 udevd
    277  root      20   0  2188  708  448 S    0  0.1   0:00.01 udevd
    2480 root      20   0  2284  740  412 S    0  0.1   0:00.00 udevd
    2503 root      20   0  2256  748  420 S    0  0.1   0:00.00 udevd
    2504 root      20   0  2284  768  436 S    0  0.1   0:00.00 udevd
    2505 root      20   0  2260  776  444 S    0  0.1   0:00.00 udevd
    2509 root      20   0  2284  660  336 S    0  0.1   0:00.00 udevd

19:58 pid=248 reaches 16M, time to unplug drive.

    248 root      20   0 18128  16m  680 S   26  1.6   1:29.32 udevd
    276 root      20   0  2188  724  448 S   12  0.1   1:17.28 udevd
    277 root      20   0  2188  708  448 S    0  0.1   0:00.01 udevd
    2480 root      20   0  2284  740  412 S    0  0.1   0:00.00 udevd
    2503 root      20   0  2256  748  420 S    0  0.1   0:00.00 udevd
    2504 root      20   0  2284  768  436 S    0  0.1   0:00.00 udevd
    2505 root      20   0  2260  776  444 S    0  0.1   0:00.00 udevd
    2509 root      20   0  2284  660  336 S    0  0.1   0:00.00 udevd

20:03 pid=248 cpu use has gone down alot, 276 still chewing cpu at high rate:

    248 root      20   0 18392  16m  680 S    2  1.7   2:01.65 udevd
    276 root      20   0  2188  732  456 S   16  0.1   2:02.90 udevd
    277 root      20   0  2188  720  460 S    0  0.1   0:00.01 udevd
    2480 root      20   0  2284  756  428 S    0  0.1   0:00.00 udevd
    2503 root      20   0  2256  748  420 S    0  0.1   0:00.00 udevd
    2504 root      20   0  2284  768  436 S    0  0.1   0:00.00 udevd
    2505 root      20   0  2260  776  444 S    0  0.1   0:00.00 udevd
    2509 root      20   0  2284  660  336 S    0  0.1   0:00.00 udevd

20:05 5 udevs die, pid=248 goes back to 1M and 0% cpu:

    248 root      20   0  2264 1012  680 S    0  0.1   2:02.18 udevd
    2505 root      20   0  2260  776  444 S    0  0.1   0:00.00 udevd
    2509 root      20   0  2284  660  336 S    0  0.1   0:00.00 udevd

No change beyond this point.

Last edited by apefish (2011-07-20 02:25:44)

Offline

Board footer

Powered by FluxBB