Commit graph

79 commits

Author SHA1 Message Date
Kay Sievers adda4c682a udevd: make sure a worker finishes event handling before exiting
Persistent network rules write out new rules files. When rules change,
we need to kill all workers to update the in-memory copy of the rules.
We need to make sure, that a worker finshes its work for all device
messages it has accepted, before it exits after a SIGTERM from the main
process.
2009-07-11 18:21:26 +02:00
Kay Sievers a073cfa844 udevd: detach event from worker if we kill a worker
Jul  8 09:36:41 udevd[663]: worker [5491] did not accept message, kill it
Jul  8 09:36:41 udevd[663]: worker [5491] unexpectedly returned with 0
Jul  8 09:36:41 udevd[663]: worker [5551] unexpectedly returned with 0
Jul  8 09:36:41 kernel: [  156.832086] <6>udevd[663]: segfault at 4 ip 00959fbc sp bfbe7b78 error 6 in udevd[94f000+1c000]

https://bugs.launchpad.net/ubuntu/+source/udev/+bug/396957
2009-07-08 14:13:20 +02:00
Kay Sievers 6133f3432f cleanup ./configure installation directory options 2009-06-17 02:25:07 +02:00
Kay Sievers 9060b066d9 move syslog wrapper to libudev 2009-06-09 22:47:48 +02:00
Kay Sievers 12bc9c54f2 udevd: log info for created/killed workers 2009-06-09 18:31:14 +02:00
Kay Sievers 45798927f8 udevd: print error if worker dies unexpectedly 2009-06-08 17:16:48 +02:00
Kay Sievers 9290143d2d udevd: close netlink socket in worker and set cloexec 2009-06-04 02:49:42 +02:00
Kay Sievers 1e03b754ae udevd: convert to event worker processes
Event processes now get re-used after they handled an event. This reduces
pressure on the CPU significantly because cloned event processes no longer
cause page faults in the main daemon. After the events have settled, the
no longer needed worker processes get killed.
2009-06-04 01:44:04 +02:00
Kay Sievers 82c785e5dc udevd: remove check for dev_t, DEVPATH_OLD takes care of that 2009-05-29 18:54:03 +02:00
Alan Jenkins f503f6b22f udevd: implement a more efficient queue file format
Directory lookups show up in profiling. The queue files are responsible
for a large proportion of file-related system calls in udev coldplug.

Instead of creating a file for each event, append their details to a
log file.  The file is periodically rebuilt (garbage-collected) to
prevent it from growing indefinitely.

This single queue file replaces both the queue directory and the
uevent_seqnum file. On desktop systems the file tends not to grow
beyond one page. So it should also save a small amount of memory in
tmpfs.

Tests on a running EeePC indicate average savings of 5% *udevd* cpu time
as measured by oprofile. __link_path_walk is reduced from 1.5% to
1.3%. It is not completely clear where the rest of the gains come from.

In tests running ~400 events, the queue file is rebuilt about 5 times.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-05-21 22:22:37 +02:00
Alan Jenkins f9b3f88f71 udevd: remove tiny bit of dead code 2009-05-21 18:31:43 +02:00
Kay Sievers ce449f89d6 keep the ifdef'd udevd testing/profiling hack 2009-05-21 01:20:18 +02:00
Kay Sievers e6c1a2bde7 use openat(), unlinkat(), fstatat() 2009-05-20 18:58:52 +02:00
Kay Sievers 065db05221 use more efficient string copying 2009-05-20 17:57:52 +02:00
Kay Sievers 619b97ff2b remove asmlinkage 2009-05-05 02:39:16 +02:00
Kay Sievers e3196993f1 remove all PHYSDEVPATH handling and warning about 2009-05-04 22:08:05 +02:00
Kay Sievers a00bdfa16b udevd: revert initial device node creation 2009-05-02 05:23:02 +02:00
Kay Sievers 540f46698d udevd: at startup create /dev/null, /dev/console, /dev/kmsg 2009-04-19 03:25:04 +02:00
Kay Sievers b44b7f8841 udevd: log error for too old kernels or CONFIG_SYSFS_DEPRECATED 2009-04-16 22:34:26 +02:00
Kay Sievers f2b937440c "UDEV_MONITOR_KERNEL/UDEV" -> "kernel/udev" 2009-03-29 20:08:52 +02:00
Kay Sievers 116254097a send monitor events back to netlink socket
Instead of of our own private monitor socket, we send the
processed event back to our netlink socket, to the multicast
group 2 -- so any number of users can listen to udev events,
just like they can listen to kernel emitted events on group 1.
2009-03-29 04:24:39 +02:00
Scott James Remnant bb38678e3c udevadm: settle - synchronise with the udev daemon
There's still a slight race condition when using udevadm settle, if the
udev daemon has a pending inotify event but hasn't yet generated the
"change" uevent for it, the kernel and udev sequence numbers will match
and settle will exit.

Now udevadm settle will send a control message to udevd, which will
respond by sending SIGUSR1 back to the waiting udevadm settle once it
has completed the main loop iteration in which it received the control
message.

If there were no pending inotify events, this will simply wake up the
udev daemon and allow settle to continue.  If there are pending inotify
events, they are handled first in the main loop so when settle is
continued they will have been turned into uevents and the kernel
sequence number will have been incremented.

Since the inotify event is pending for udevd when the close() system
call returns (it's queued as part of the kernel handling for that system
call), and since the kernel sequence number is incremented by writing to
the uevent file (as udevd does), this solves the race.

When the settle continues, if there were pending inotify events that
udevd had not read, they are now pending uevents which settle can wait
for.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-03-12 10:02:37 +00:00
Kay Sievers 3d3a0a709a use the event udev_device to disable the watch on "remove" 2009-02-24 15:11:17 +01:00
Scott James Remnant 80be8c48c5 Look at more inotify events in the buffer than just the first. 2009-02-23 18:33:49 +00:00
Scott James Remnant b8e96d67a2 lookup the old watch handle; reload only if has a path 2009-02-23 17:59:01 +00:00
Scott James Remnant 9ce462721a Put a log message in a more sensible place. 2009-02-23 17:46:00 +00:00
Scott James Remnant 047f88bca3 Use the udevdb to speed up watch clearing.
Also return a udev_device when looking up by handle as well, so
everything works the same way.
2009-02-23 17:43:53 +00:00
Scott James Remnant 03e0170db3 Cleanup a little.
Move some of the checks into udev_watch_begin() and udev_watch_clear()
so we don't have to repeat them all the time.
2009-02-23 17:21:24 +00:00
Scott James Remnant 521b3a9211 Clear existing inotify watch before processing.
Likewise when re-processing an event, we want to drop the existing
inotify watch first to avoid side-effects.
2009-02-23 17:19:05 +00:00
Scott James Remnant 5ae82640c5 Don't add inotify watch until RUN rules processed.
The programs we RUN can open device nodes, and thus we can end up
chasing our own tail.
2009-02-23 17:17:20 +00:00
Kay Sievers 4aca304e48 use global "reload_config" flag 2009-02-11 21:56:35 +01:00
Scott James Remnant bd284db142 udevd: optionally watch device nodes with inotify
This allows you to re-process the rules if the content of the device
has been changed, most useful for block subsystem to cause vol_id to
be run again.
2009-02-11 17:38:56 +00:00
Kay Sievers 5db88229d1 udevd: add back SA_RESTART
<Keybuk> poll, select, ppoll, pselect, epoll, etc. are *explicitly* NOT restarted in case of signal
<kay> ok
2009-01-21 18:55:59 +01:00
Kay Sievers 6469c77216 split up long line 2009-01-21 15:11:38 +01:00
Kay Sievers 4b0faa2aa0 Merge commit '9032f119f07ad3b5116b3d4858816d851d4127de' 2009-01-21 14:43:22 +01:00
Kay Sievers 2c7b88c4a5 Merge commit '5f03ed8a56d308af72db8a48ab66ed68667af2c6'
Conflicts:
	udev/udevd.c
2009-01-21 14:42:30 +01:00
Olaf Kirch d1cc6562f3 reap children faster
udevd's event_queue_manager loop is pretty sensitive to the
delays of exiting child processes. I found that it helps boot
times if we try to reap children as quickly as possible.

This patch changes event_queue_manager to call sigchilds_waiting
if it finds a signal has been received.

Signed-off-by: Olaf Kirch <okir@suse.de>
2009-01-21 11:17:11 +01:00
Kay Sievers e9a77fd828 open-code pollfd setup 2009-01-21 11:09:27 +01:00
Scott James Remnant 9032f119f0 Expose delayed name resolution
udevd had the ability to delay name resolution until the event, but this
was never exposed.  Add a --resolve-names=late option to do so.
2009-01-20 21:36:09 +00:00
Scott James Remnant 5f03ed8a56 Allow user and group lookup to be disabled.
In certain cut-down situations such as an installer or inside the
initramfs, we simply don't have any kind of name service.  While we
could use rules without OWNER or GROUP, it's better to have the same
rules as a full system and have udevd ignore those parts of the rules.

Adds a --resolve-names=never switch to udevd that has this effect.
2009-01-20 21:33:02 +00:00
Olaf Kirch 3210a72ba3 udevd: use ppoll instead of signal pipes
udevd uses a rather old-fashioned way of handling signals
while waiting for input through select (ie by using an unnamed
pipe, to which the signal handler writes one byte for every signal
received). This is rather awkward and may potentially even block
if we receive more signals than the kernel's pipe buffer.

This patch replaces all of that with ppoll, which was designed
for this purpose.

It also removes the SA_RESTART flag from all installed signal
handlers, because otherwise the ppoll call would just be restarted
after handling eg a SIGCHLD.

Signed-off-by: Olaf Kirch <okir@suse.de>
2009-01-20 12:49:20 +01:00
Kay Sievers 64be143742 require non-SYSFS_DEPRECATED 2.6.20+ kernel 2008-12-29 06:04:09 +01:00
Kay Sievers c969f88062 udevd: fix cleanup of /dev/.udev/uevent_seqnum 2008-11-17 14:43:58 +01:00
Kay Sievers 95d61c2745 set errno = ENOSYS in inotify stub 2008-11-13 01:52:33 +01:00
Kay Sievers 78230c0dbe cleanup /dev/.udev/queue on startup and exit 2008-11-06 17:43:12 +01:00
Kay Sievers 00f98bd2b3 skip entire rule containing device naming keys, if no device can be named
If rules set NAME, SYMLINK, OWNER, GROUP, MODE, events without a device node
and remove events will skip the entire rule. The old parser did the same.
2008-11-01 19:12:20 +01:00
Kay Sievers 27691aa3ae write trace log to stderr 2008-10-31 16:22:55 +01:00
Kay Sievers 0bc74ea79f udevd: merge exec and run queue to minimize devpath string compares 2008-10-29 17:32:13 +01:00
Alan Jenkins e25fa4faf5 udevd: use a tighter loop for compare_devpath()
This crops up in my threaded udevd profiles from time to time.
It's not consistent - probably due to variations in the number
of concurrent events - but it can hit 4% user time and higher.

The change halves the user time spent in compare_devpath().

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-25 19:41:52 +02:00
Kay Sievers 54808d77a3 prefix udev-util.c functions with util_* 2008-10-18 20:12:55 +02:00