* [PATCH] initramfs-framework: add opt-in root-only udev trigger @ 2026-08-12 9:28 Wenwen Fu 2026-08-18 8:47 ` Paul Barker 2026-08-18 10:17 ` [PATCH v2] " Wenwen Fu 0 siblings, 2 replies; 4+ messages in thread From: Wenwen Fu @ 2026-08-12 9:28 UTC (permalink / raw) To: openembedded-core; +Cc: Wenwen Fu The initramfs udev module replays add events for the complete device tree and waits for every resulting event. An initramfs that only mounts a root partition does not need to coldplug unrelated devices. Add an opt-in initramfs.udev-root-only kernel parameter. When root uses PARTLABEL or PARTUUID, trigger only the matching block device. For PARTLABEL roots, match the PARTNAME property exposed by udev. Keep the existing full trigger as the default so current users and other initramfs modules retain their existing behaviour. If the requested root cannot be matched safely, or a targeted trigger fails, fall back to the original full coldplug. Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com> --- .../initrdscripts/initramfs-framework/udev | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev index 4898b89246..7fa26ef807 100644 --- a/meta/recipes-core/initrdscripts/initramfs-framework/udev +++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev @@ -35,6 +35,29 @@ udev_enabled() { return 0 } +udev_trigger_root_device() { + case "${bootparam_root:-}" in + PARTLABEL=?*) + root_match="PARTNAME=${bootparam_root#PARTLABEL=}" + ;; + PARTUUID=?*) + root_match="PARTUUID=${bootparam_root#PARTUUID=}" + ;; + *) + return 1 + ;; + esac + + root_devices=$(udevadm trigger --dry-run --verbose \ + --subsystem-match=block "--property-match=$root_match") || return 1 + + # udevadm succeeds even when no devices match, so check its dry-run output. + [ -n "$root_devices" ] || return 1 + + udevadm trigger --subsystem-match=block \ + "--property-match=$root_match" --action=add +} + udev_run() { add_module_pre_hook "udev_shutdown_hook_handler" @@ -45,6 +68,11 @@ udev_run() { sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; } $_UDEV_DAEMON --daemon - udevadm trigger --action=add + if [ "${bootparam_initramfs_udev_root_only:-}" = "1" ] && + udev_trigger_root_device; then + debug "Triggered udev for root partition only" + else + udevadm trigger --action=add + fi udevadm settle } -- 2.43.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] initramfs-framework: add opt-in root-only udev trigger 2026-08-12 9:28 [PATCH] initramfs-framework: add opt-in root-only udev trigger Wenwen Fu @ 2026-08-18 8:47 ` Paul Barker 2026-08-18 10:01 ` Wenwen Fu 2026-08-18 10:17 ` [PATCH v2] " Wenwen Fu 1 sibling, 1 reply; 4+ messages in thread From: Paul Barker @ 2026-08-18 8:47 UTC (permalink / raw) To: Wenwen Fu, openembedded-core Hi, Thanks for the patch, I have a couple of feedback comments. On Wed, 2026-08-12 at 17:28 +0800, Wenwen Fu wrote: > The initramfs udev module replays add events for the complete device tree > and waits for every resulting event. An initramfs that only mounts a root > partition does not need to coldplug unrelated devices. > > Add an opt-in initramfs.udev-root-only kernel parameter. When root uses > PARTLABEL or PARTUUID, trigger only the matching block device. For > PARTLABEL roots, match the PARTNAME property exposed by udev. Keep the > existing full trigger as the default so current users and other initramfs > modules retain their existing behaviour. > > If the requested root cannot be matched safely, or a targeted trigger > fails, fall back to the original full coldplug. This explains the mechanism, but not why we would want the option to avoid the current behaviour. Does the current behaviour cause problems, is it too slow, etc? > > Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com> > --- > .../initrdscripts/initramfs-framework/udev | 30 ++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > > diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev > index 4898b89246..7fa26ef807 100644 > --- a/meta/recipes-core/initrdscripts/initramfs-framework/udev > +++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev > @@ -35,6 +35,29 @@ udev_enabled() { > return 0 > } > > +udev_trigger_root_device() { > + case "${bootparam_root:-}" in > + PARTLABEL=?*) > + root_match="PARTNAME=${bootparam_root#PARTLABEL=}" > + ;; > + PARTUUID=?*) > + root_match="PARTUUID=${bootparam_root#PARTUUID=}" > + ;; > + *) > + return 1 > + ;; > + esac > + > + root_devices=$(udevadm trigger --dry-run --verbose \ > + --subsystem-match=block "--property-match=$root_match") || return 1 > + > + # udevadm succeeds even when no devices match, so check its dry-run output. > + [ -n "$root_devices" ] || return 1 > + > + udevadm trigger --subsystem-match=block \ > + "--property-match=$root_match" --action=add The commit message says that there is a fallback to the original full coldplug if the targeted trigger fails, but the return status of this command is ignored. > +} > + > udev_run() { > add_module_pre_hook "udev_shutdown_hook_handler" > > @@ -45,6 +68,11 @@ udev_run() { > sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; } > > $_UDEV_DAEMON --daemon > - udevadm trigger --action=add > + if [ "${bootparam_initramfs_udev_root_only:-}" = "1" ] && I don't think this enabling condition isn't explained clearly in the commit message. > + udev_trigger_root_device; then > + debug "Triggered udev for root partition only" > + else > + udevadm trigger --action=add > + fi > udevadm settle > } Best regards, -- Paul Barker ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] initramfs-framework: add opt-in root-only udev trigger 2026-08-18 8:47 ` Paul Barker @ 2026-08-18 10:01 ` Wenwen Fu 0 siblings, 0 replies; 4+ messages in thread From: Wenwen Fu @ 2026-08-18 10:01 UTC (permalink / raw) To: Paul Barker, openembedded-core@lists.openembedded.org [-- Attachment #1: Type: text/plain, Size: 5176 bytes --] Hi Paul, Thanks for the review. The motivation is to reduce initramfs boot latency. On the Qualcomm RB3 Gen 2 Core Kit, the full coldplug initializes unrelated devices, and udevadm settle waits for their events although only the root partition is needed. I measured the following average boot times with this configuration: Device: Qualcomm RB3 Gen 2 Core Kit MACHINE: rb3gen2-core-kit Kernel: Linux 6.18 KAS configuration: ci/rb3gen2-core-kit.yml:ci/qcom-distro.yml:ci/performance.yml Image: initramfs-rootfs-image Root: PARTLABEL=rootfs Default full coldplug With path root-only enabled Improvement udev trigger + settle 981.6 ms 109.8 ms 871.8 ms (88.8%) /init to rootfs EXT4 mount 1340.2 ms 441.1 ms 899.1 ms (67.1%) This reduces the udev trigger and settle time by 871.8 ms and the time to mount the root filesystem by 899.1 ms, corresponding to improvements of 88.8% and 67.1%, respectively. The measurements cover three boots with the full trigger and two boots with the root-only trigger. For the targeted trigger, udev_trigger_root_device() returns the status of its final udevadm command, so failure already makes the condition false and executes the full trigger. However, I agree this is not obvious, so I will make the error handling explicit in v2. I will also clarify that the optimization is enabled with: initramfs.udev-root-only=1 I will address these points in v2. Best regards, Wenwen ________________________________ From: Paul Barker <paul@pbarker.dev> Sent: Tuesday, August 18, 2026 16:47 To: Wenwen Fu <wenwfu@qti.qualcomm.com>; openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> Subject: Re: [PATCH] initramfs-framework: add opt-in root-only udev trigger WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros. Hi, Thanks for the patch, I have a couple of feedback comments. On Wed, 2026-08-12 at 17:28 +0800, Wenwen Fu wrote: > The initramfs udev module replays add events for the complete device tree > and waits for every resulting event. An initramfs that only mounts a root > partition does not need to coldplug unrelated devices. > > Add an opt-in initramfs.udev-root-only kernel parameter. When root uses > PARTLABEL or PARTUUID, trigger only the matching block device. For > PARTLABEL roots, match the PARTNAME property exposed by udev. Keep the > existing full trigger as the default so current users and other initramfs > modules retain their existing behaviour. > > If the requested root cannot be matched safely, or a targeted trigger > fails, fall back to the original full coldplug. This explains the mechanism, but not why we would want the option to avoid the current behaviour. Does the current behaviour cause problems, is it too slow, etc? > > Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com> > --- > .../initrdscripts/initramfs-framework/udev | 30 ++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > > diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev > index 4898b89246..7fa26ef807 100644 > --- a/meta/recipes-core/initrdscripts/initramfs-framework/udev > +++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev > @@ -35,6 +35,29 @@ udev_enabled() { > return 0 > } > > +udev_trigger_root_device() { > + case "${bootparam_root:-}" in > + PARTLABEL=?*) > + root_match="PARTNAME=${bootparam_root#PARTLABEL=}" > + ;; > + PARTUUID=?*) > + root_match="PARTUUID=${bootparam_root#PARTUUID=}" > + ;; > + *) > + return 1 > + ;; > + esac > + > + root_devices=$(udevadm trigger --dry-run --verbose \ > + --subsystem-match=block "--property-match=$root_match") || return 1 > + > + # udevadm succeeds even when no devices match, so check its dry-run output. > + [ -n "$root_devices" ] || return 1 > + > + udevadm trigger --subsystem-match=block \ > + "--property-match=$root_match" --action=add The commit message says that there is a fallback to the original full coldplug if the targeted trigger fails, but the return status of this command is ignored. > +} > + > udev_run() { > add_module_pre_hook "udev_shutdown_hook_handler" > > @@ -45,6 +68,11 @@ udev_run() { > sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; } > > $_UDEV_DAEMON --daemon > - udevadm trigger --action=add > + if [ "${bootparam_initramfs_udev_root_only:-}" = "1" ] && I don't think this enabling condition isn't explained clearly in the commit message. > + udev_trigger_root_device; then > + debug "Triggered udev for root partition only" > + else > + udevadm trigger --action=add > + fi > udevadm settle > } Best regards, -- Paul Barker [-- Attachment #2: Type: text/html, Size: 19489 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] initramfs-framework: add opt-in root-only udev trigger 2026-08-12 9:28 [PATCH] initramfs-framework: add opt-in root-only udev trigger Wenwen Fu 2026-08-18 8:47 ` Paul Barker @ 2026-08-18 10:17 ` Wenwen Fu 1 sibling, 0 replies; 4+ messages in thread From: Wenwen Fu @ 2026-08-18 10:17 UTC (permalink / raw) To: openembedded-core; +Cc: Wenwen Fu The initramfs udev module replays add events for the complete device tree and waits for every resulting event. This can significantly delay mounting the root filesystem when unrelated devices take time to initialize. On a Qualcomm RB3 Gen 2 Core Kit (MACHINE=rb3gen2-core-kit) running Linux 6.18, using initramfs-rootfs-image with root=PARTLABEL=rootfs, the following average times were measured: Full coldplug Root-only udev trigger + settle 981.6 ms 109.8 ms /init to rootfs EXT4 mount 1340.2 ms 441.1 ms The root-only trigger reduced these times by 88.8% and 67.1%, respectively. The values are averages of three full-coldplug boots and two root-only boots. Add the opt-in initramfs.udev-root-only=1 kernel parameter. When root uses PARTLABEL or PARTUUID, trigger only the matching block device. For PARTLABEL roots, match the PARTNAME property exposed by udev. Keep the existing full trigger as the default so current users and other initramfs modules retain their existing behaviour. If the root device cannot be matched safely or the targeted trigger fails, fall back to the original full coldplug. Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com> --- Changes in v2: - Explain the boot-time motivation and include performance measurements. - Clarify that initramfs.udev-root-only=1 enables the optimization. - Make targeted-trigger error handling explicit. --- .../initrdscripts/initramfs-framework/udev | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev index 4898b89246..8f67e78a7c 100644 --- a/meta/recipes-core/initrdscripts/initramfs-framework/udev +++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev @@ -35,6 +35,31 @@ udev_enabled() { return 0 } +udev_trigger_root_device() { + case "${bootparam_root:-}" in + PARTLABEL=?*) + root_match="PARTNAME=${bootparam_root#PARTLABEL=}" + ;; + PARTUUID=?*) + root_match="PARTUUID=${bootparam_root#PARTUUID=}" + ;; + *) + return 1 + ;; + esac + + root_devices=$(udevadm trigger --dry-run --verbose \ + --subsystem-match=block "--property-match=$root_match") || return 1 + + # udevadm succeeds even when no devices match, so check its dry-run output. + [ -n "$root_devices" ] || return 1 + + udevadm trigger --subsystem-match=block \ + "--property-match=$root_match" --action=add || return 1 + + return 0 +} + udev_run() { add_module_pre_hook "udev_shutdown_hook_handler" @@ -45,6 +70,11 @@ udev_run() { sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; } $_UDEV_DAEMON --daemon - udevadm trigger --action=add + if [ "${bootparam_initramfs_udev_root_only:-}" = "1" ] && + udev_trigger_root_device; then + debug "Triggered udev for root partition only" + else + udevadm trigger --action=add + fi udevadm settle } -- 2.43.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-18 12:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-12 9:28 [PATCH] initramfs-framework: add opt-in root-only udev trigger Wenwen Fu 2026-08-18 8:47 ` Paul Barker 2026-08-18 10:01 ` Wenwen Fu 2026-08-18 10:17 ` [PATCH v2] " Wenwen Fu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox