* [PATCH] kernel/params.c: defer most of param_sysfs_init() to late_initcall time
@ 2022-10-25 13:00 Rasmus Villemoes
2022-10-25 15:56 ` Luis Chamberlain
2022-10-25 22:13 ` [PATCH v2] " Rasmus Villemoes
0 siblings, 2 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2022-10-25 13:00 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Miroslav Benes, Christophe Leroy, Greg Kroah-Hartman,
Rasmus Villemoes, linux-kernel
param_sysfs_init(), and in particular param_sysfs_builtin() is rather
time-consuming; for my board, it currently takes about 30ms.
That amounts to about 3% of the time budget I have from U-Boot hands
over control to linux and linux must assume responsibility for keeping
the external watchdog happy.
We must still continue to initialize module_kset at subsys_initcall
time, since otherwise any request_module() would fail in
mod_sysfs_init(). However, the bulk of the work in
param_sysfs_builtin(), namely populating /sys/module/*/version and/or
/sys/module/*/parameters/ for builtin modules, can be deferred to
late_initcall time - there's no userspace yet anyway to observe
contents of /sys or the lack thereof.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
This is on top of
https://lore.kernel.org/lkml/20220929121039.702873-1-linux@rasmusvillemoes.dk/
which I think has been applied somewhere, but I can't yet find it in
linux-next.
kernel/params.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/kernel/params.c b/kernel/params.c
index 8d4e9a3f0df2..db524cf51231 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -953,7 +953,7 @@ struct kobj_type module_ktype = {
};
/*
- * param_sysfs_init - wrapper for built-in params support
+ * param_sysfs_init - create "module" kset
*/
static int __init param_sysfs_init(void)
{
@@ -964,11 +964,24 @@ static int __init param_sysfs_init(void)
return -ENOMEM;
}
+ return 0;
+}
+subsys_initcall(param_sysfs_init);
+
+/*
+ * param_sysfs_builtin_init - add sysfs version and parameter
+ * attributes for built-in modules
+ */
+static int __init param_sysfs_builtin_init(void)
+{
+ if (!module_kset)
+ return -ENOMEM;
+
version_sysfs_builtin();
param_sysfs_builtin();
return 0;
}
-subsys_initcall(param_sysfs_init);
+late_initcall(param_sysfs_builtin_init);
#endif /* CONFIG_SYSFS */
--
2.37.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kernel/params.c: defer most of param_sysfs_init() to late_initcall time
2022-10-25 13:00 [PATCH] kernel/params.c: defer most of param_sysfs_init() to late_initcall time Rasmus Villemoes
@ 2022-10-25 15:56 ` Luis Chamberlain
2022-10-25 22:13 ` [PATCH v2] " Rasmus Villemoes
1 sibling, 0 replies; 4+ messages in thread
From: Luis Chamberlain @ 2022-10-25 15:56 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Miroslav Benes, Christophe Leroy, Greg Kroah-Hartman, linux-kernel
On Tue, Oct 25, 2022 at 03:00:02PM +0200, Rasmus Villemoes wrote:
> param_sysfs_init(), and in particular param_sysfs_builtin() is rather
> time-consuming; for my board, it currently takes about 30ms.
>
> That amounts to about 3% of the time budget I have from U-Boot hands
> over control to linux and linux must assume responsibility for keeping
> the external watchdog happy.
>
> We must still continue to initialize module_kset at subsys_initcall
> time, since otherwise any request_module() would fail in
> mod_sysfs_init().
It would be good to document this through a comment.
> However, the bulk of the work in
> param_sysfs_builtin(), namely populating /sys/module/*/version and/or
> /sys/module/*/parameters/ for builtin modules, can be deferred to
> late_initcall time - there's no userspace yet anyway to observe
> contents of /sys or the lack thereof.
>
Other than that, this looks good and looks cautious enough.
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Happy to take this in through moduels and give this a spin on linux-next
to see what blows up early. Can you send a v2 with a small code comment for
the above?
Luis
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] kernel/params.c: defer most of param_sysfs_init() to late_initcall time
2022-10-25 13:00 [PATCH] kernel/params.c: defer most of param_sysfs_init() to late_initcall time Rasmus Villemoes
2022-10-25 15:56 ` Luis Chamberlain
@ 2022-10-25 22:13 ` Rasmus Villemoes
2022-10-25 23:06 ` Luis Chamberlain
1 sibling, 1 reply; 4+ messages in thread
From: Rasmus Villemoes @ 2022-10-25 22:13 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Miroslav Benes, Christophe Leroy, Greg Kroah-Hartman,
Rasmus Villemoes, linux-kernel
param_sysfs_init(), and in particular param_sysfs_builtin() is rather
time-consuming; for my board, it currently takes about 30ms.
That amounts to about 3% of the time budget I have from U-Boot hands
over control to linux and linux must assume responsibility for keeping
the external watchdog happy.
We must still continue to initialize module_kset at subsys_initcall
time, since otherwise any request_module() would fail in
mod_sysfs_init(). However, the bulk of the work in
param_sysfs_builtin(), namely populating /sys/module/*/version and/or
/sys/module/*/parameters/ for builtin modules, can be deferred to
late_initcall time - there's no userspace yet anyway to observe
contents of /sys or the lack thereof.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
kernel/params.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/kernel/params.c b/kernel/params.c
index 8d4e9a3f0df2..a06f80c56f19 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -953,7 +953,11 @@ struct kobj_type module_ktype = {
};
/*
- * param_sysfs_init - wrapper for built-in params support
+ * param_sysfs_init - create "module" kset
+ *
+ * This must be done before the initramfs is unpacked and
+ * request_module() thus becomes possible, because otherwise the
+ * module load would fail in mod_sysfs_init.
*/
static int __init param_sysfs_init(void)
{
@@ -964,11 +968,24 @@ static int __init param_sysfs_init(void)
return -ENOMEM;
}
+ return 0;
+}
+subsys_initcall(param_sysfs_init);
+
+/*
+ * param_sysfs_builtin_init - add sysfs version and parameter
+ * attributes for built-in modules
+ */
+static int __init param_sysfs_builtin_init(void)
+{
+ if (!module_kset)
+ return -ENOMEM;
+
version_sysfs_builtin();
param_sysfs_builtin();
return 0;
}
-subsys_initcall(param_sysfs_init);
+late_initcall(param_sysfs_builtin_init);
#endif /* CONFIG_SYSFS */
--
2.37.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] kernel/params.c: defer most of param_sysfs_init() to late_initcall time
2022-10-25 22:13 ` [PATCH v2] " Rasmus Villemoes
@ 2022-10-25 23:06 ` Luis Chamberlain
0 siblings, 0 replies; 4+ messages in thread
From: Luis Chamberlain @ 2022-10-25 23:06 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Miroslav Benes, Christophe Leroy, Greg Kroah-Hartman, linux-kernel
On Wed, Oct 26, 2022 at 12:13:56AM +0200, Rasmus Villemoes wrote:
> param_sysfs_init(), and in particular param_sysfs_builtin() is rather
> time-consuming; for my board, it currently takes about 30ms.
>
> That amounts to about 3% of the time budget I have from U-Boot hands
> over control to linux and linux must assume responsibility for keeping
> the external watchdog happy.
>
> We must still continue to initialize module_kset at subsys_initcall
> time, since otherwise any request_module() would fail in
> mod_sysfs_init(). However, the bulk of the work in
> param_sysfs_builtin(), namely populating /sys/module/*/version and/or
> /sys/module/*/parameters/ for builtin modules, can be deferred to
> late_initcall time - there's no userspace yet anyway to observe
> contents of /sys or the lack thereof.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Thanks, queued onto modules-next.
Luis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-25 23:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 13:00 [PATCH] kernel/params.c: defer most of param_sysfs_init() to late_initcall time Rasmus Villemoes
2022-10-25 15:56 ` Luis Chamberlain
2022-10-25 22:13 ` [PATCH v2] " Rasmus Villemoes
2022-10-25 23:06 ` Luis Chamberlain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®