Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add udevadm settle call after triggering uevents

This also adds a fun little timer to show how long udev processing took.
catch it if you can!
  • Loading branch information...
commit c49b196dfb0eec04faea3b229a4c372497c4b281 1 parent 80d378e
Dave Reisner authored
Showing with 17 additions and 3 deletions.
  1. +17 −3 init.c
20 init.c
View
@@ -11,6 +11,7 @@
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/vfs.h>
#include <sys/wait.h>
@@ -424,15 +425,28 @@ static void load_extra_modules(void) { /* {{{ */
} /* }}} */
static void trigger_udev_events(void) { /* {{{ */
- char *argv[] = { "/sbin/udevadm", "trigger", "--action=add", NULL };
+ char *trigger_argv[] = { "/sbin/udevadm", "trigger", "--action=add", NULL };
+ char *settle_argv[] = { "/sbin/udevadm", "settle", "--timeout=10", NULL };
+ struct timeval tv[2];
+ long time_ms = 0; /* processing time in ms */
/* don't assume we have udev available */
if (access(UDEVADM, X_OK) != 0) {
return;
}
- msg("triggering udev events...\n");
- forkexecwait(argv);
+ msg("triggering uevents...\n");
+
+ gettimeofday(&tv[0], NULL);
+ forkexecwait(trigger_argv);
+ forkexecwait(settle_argv);
+ gettimeofday(&tv[1], NULL);
+
+ time_ms += (tv[1].tv_sec - tv[0].tv_sec) * 1000; /* s => ms */
+ time_ms += (tv[1].tv_usec - tv[0].tv_usec) / 1000; /* us => ms */
+
+ msg("finished udev processing in %ldms\n", time_ms);
+
} /* }}} */
static void disable_hooks(void) { /* {{{ */
Please sign in to comment.
Something went wrong with that request. Please try again.