]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-device-manager: Only consume one udev event at a time
authorHans de Goede <hdegoede@redhat.com>
Mon, 23 Mar 2020 16:38:18 +0000 (17:38 +0100)
committerHans de Goede <hdegoede@redhat.com>
Tue, 24 Mar 2020 23:00:06 +0000 (00:00 +0100)
Commit f9e376797a91 ("ply-device-manager: Consume all events in one go")
changed ply-device-manager to consume all pending udev events in one go
instead of consuming only 1 and then returning back to the mainloop.

The idea here was to avoid the overhead of returning back to the mainloop,
doing the poll again, seeing more events were pending and then re-enter
ply-device-manager.

In retrospect this is not a good idea. Systemd waits for oneshot units
like plymouth-switch-root.service to finish and this can block the boot.
Specifically plymouth-switch-root.service must complete before systemd in
the initrd will exec the systemd from the real rootfs. This means that
systemd inside the initrd waits for the:

ExecStart=-/usr/bin/plymouth update-root-fs --new-root-dir=/sysroot

Command to complete, if this command runs while we are consuming udev
events from the graphics card (which sends a change event per probed
connector during the initial probe), then plymouth will not send the ack
to the plymouth boot-client (completing the ExecStart) until all udev
events are consumed.

On my main workstation with i915 graphics and 2 HDMI connected FHD monitors,
this delays the actual switching of the root by 1.9 - 2.1 seconds,
because the re-enumaration of the connectors in the drm plugin takes
about 0.4 seconds per run.

Other upcoming changes will greatly reduce that 0.4 seconds, but still
returning to the main-loop after a single udev event so that we can
answer any waiting boot-clients ASAP is a good idea.

This reverts commit f9e376797a91ad5fbc1f8e8e4aea778f4f22397c.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/libply-splash-core/ply-device-manager.c

index 160b8cb4c66b5a22d3cbca8980d56f529214ae53..f65d7317ff884475d78189d4bcf918e066ac9f15 100644 (file)
@@ -415,7 +415,7 @@ on_drm_udev_add_or_change (ply_device_manager_t *manager,
         }
 }
 
-static bool
+static void
 on_udev_event (ply_device_manager_t *manager)
 {
         struct udev_device *device;
@@ -423,14 +423,14 @@ on_udev_event (ply_device_manager_t *manager)
 
         device = udev_monitor_receive_device (manager->udev_monitor);
         if (device == NULL)
-                return false;
+                return;
 
         action = udev_device_get_action (device);
 
         ply_trace ("got %s event for device %s", action, udev_device_get_sysname (device));
 
         if (action == NULL)
-                return false;
+                return;
 
         if (strcmp (action, "add") == 0 || strcmp (action, "change") == 0) {
                 const char *subsystem;
@@ -450,14 +450,6 @@ on_udev_event (ply_device_manager_t *manager)
         }
 
         udev_device_unref (device);
-        return true;
-}
-
-static void
-on_udev_event_loop (ply_device_manager_t *manager)
-{
-        /* Call on_udev_event until all events are consumed */
-        while (on_udev_event (manager)) {}
 }
 
 static void
@@ -487,7 +479,7 @@ watch_for_udev_events (ply_device_manager_t *manager)
                                                      fd,
                                                      PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
                                                      (ply_event_handler_t)
-                                                     on_udev_event_loop,
+                                                     on_udev_event,
                                                      NULL,
                                                      manager);
 }