While testing with lots (~20000) of fake block devices with scsi_debug, I found that systemd was quite slow at processing the udev events. The queue of the udev monitor netlink socket grew to several megabytes. The queue length can be observed with: watch "grep -E '^(\S+\s+){2}1\s+' /proc/net/netlink"
strace showed that apart from processing the events from netlink as expected, systemd was also spending a lot of time re-setting its inotify watches: epoll_wait(4, {{EPOLLIN, {u32=13412248, u64=13412248}}}, 1, 4294967295) = 1 ioctl(17, FIONREAD, [2048]) = 0 read(17, "\3\0\0\0\4\0\0\0\0\0\0\0\20\0\0\0sg279\0\0\0\0\0\0\0\0\0\0\0"..., 2048) = 2048 open("/dev/.systemd/ask-password", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 18 getdents(18, /* 2 entries */, 32768) = 48 getdents(18, /* 0 entries */, 32768) = 0 close(18) = 0 epoll_ctl(4, EPOLL_CTL_DEL, 17, NULL) = 0 close(17) = 0 inotify_init1(O_NONBLOCK|O_CLOEXEC) = 17 epoll_ctl(4, EPOLL_CTL_ADD, 17, {EPOLLIN, {u32=13412248, u64=13412248}}) = 0 inotify_add_watch(17, "/dev/.systemd/ask-password", IN_ATTRIB|IN_MOVED_TO|IN_CREATE|IN_DELETE_SELF|IN_MOVE_SELF) = 1 inotify_add_watch(17, "/dev/.systemd", IN_ATTRIB|IN_DELETE_SELF|IN_MOVE_SELF) = 2 inotify_add_watch(17, "/dev", IN_ATTRIB|IN_DELETE_SELF|IN_MOVE_SELF) = 3 inotify_add_watch(17, "/", IN_ATTRIB|IN_DELETE_SELF|IN_MOVE_SELF) = 4 The reason for this activity is that systemd receives inotify notifications for the /dev directory as udev creates the new device nodes there. But why should systemd be interested in these events? Should /dev/.systemd go away, an IN_DELETE_SELF|IN_MOVE_SELF watch on it ought to be fully sufficient for systemd to take note of the event. IN_ATTRIB seems to be an overkill. IN_ATTRIB was added in commit 782195a3c31a79428874a32e0264c0aa97a664f7: Author: Lennart Poettering <lenn...@poettering.net> Date: Mon Nov 15 00:47:29 2010 +0100 path: always look for IN_ATTRIB since deletion is signalled that way But I do not understand what deletion is the description referring to. --- src/path.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/path.c b/src/path.c index 77de32d..e1ec33b 100644 --- a/src/path.c +++ b/src/path.c @@ -223,7 +223,7 @@ static int path_watch_one(Path *p, PathSpec *s) { /* Trim the path at the last slash. Keep the slash if it's the root dir. */ slash[slash == k] = 0; - flags = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB; + flags = IN_DELETE_SELF|IN_MOVE_SELF; if (!exists) flags |= IN_CREATE | IN_MOVED_TO; _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel