[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tencent_4EBF99084F5A4A0D6C6AA5282D4FF23E6807@qq.com>
Date: Tue, 8 Apr 2025 00:22:34 +0800
From: zhoumin <teczm@...mail.com>
To: gregkh@...uxfoundation.org
Cc: dakr@...nel.org,
akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org,
rafael@...nel.org,
teczm@...mail.com,
viro@...iv.linux.org.uk
Subject: Re: [PATCH] kobject_uevent: add uevent_helper exist check
> > But I propose we should make call_usermodehelper_exec fail earlier, link
> > this:
> > --- a/lib/kobject_uevent.c
> > +++ b/lib/kobject_uevent.c
> > @@ -610,7 +610,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
> >
> > #ifdef CONFIG_UEVENT_HELPER
> > /* call uevent_helper, usually only enabled during early boot */
> > - if (uevent_helper[0] && !kobj_usermode_filter(kobj)) {
> > + if (uevent_helper[0] && !usermodehelper_disabled && !kobj_usermode_filter(kobj)) {
> > struct subprocess_info *info;
> >
> > retval = add_uevent_var(env, "HOME=/");
> Why? Will this actually change the speed of anything?
While the actual speed improvement may be minimal(may vary depending on
device performance and how many uevents are triggered before rootfs mount),
I just think executing add_uevent_var(), call_usermodehelper_setup(), and
call_usermodehelper_exec() is unnecessary in these cases. We can simply
return early. If you consider this change unnecessary, I'll respectfully
close this discussion and focus on other areas where more significant
improvements might be achieved.
---
Appendix: QEMU Test Logs
In my current QEMU test environment, this code path executes
2,127 times before rootfs mount. Sample events collected via debug logs:
pr_emerg("action:%s devpath:%s\n", action_string, devpath);
[ 0.263272] action:add devpath:/bus/faux
[ 0.264278] action:add devpath:/bus/faux/drivers/faux_driver
[ 0.267476] action:add devpath:/bus/platform
[ 0.267559] action:add devpath:/bus/auxiliary
[ 0.267669] action:add devpath:/bus/memory
[ 0.268789] action:add devpath:/devices/system/memory/memory8
[ 0.269501] action:add devpath:/devices/system/memory/memory9
[ 0.269664] action:add devpath:/devices/system/memory/memory10
[ 0.269793] action:add devpath:/devices/system/memory/memory11
[ 0.269889] action:add devpath:/devices/system/memory/memory12
[ 0.270008] action:add devpath:/devices/system/memory/memory13
[ 0.270108] action:add devpath:/devices/system/memory/memory14
[ 0.270208] action:add devpath:/devices/system/memory/memory15
[ 0.270297] action:add devpath:/devices/system/memory/memory16
[ 0.270409] action:add devpath:/devices/system/memory/memory17
...
[ 1.068185] action:add devpath:/devices/virtual/tty/tty58
[ 1.069597] action:add devpath:/devices/virtual/tty/tty59
[ 1.070887] action:add devpath:/devices/virtual/tty/tty60
[ 1.071801] action:add devpath:/devices/virtual/tty/tty61
[ 1.073554] action:add devpath:/devices/virtual/tty/tty62
[ 1.075086] action:add devpath:/devices/virtual/tty/tty63
...
[ 3.519928] action:add devpath:/devices/platform/gpio-keys/input/input0/event0
[ 3.521347] action:remove devpath:/devices/virtual/devlink/amba:9030000.pl061--platform:gpio-keys
[ 3.523161] action:bind devpath:/devices/platform/gpio-keys
[ 3.523831] action:add devpath:/bus/platform/drivers/gpio-keys
[ 3.529957] action:add devpath:/bus/amba/drivers/amba-proxy
Best regards,
zhoumin
Powered by blists - more mailing lists