Skip to content

Commit

Permalink
kernel/params.c: defer most of param_sysfs_init() to late_initcall time
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
  • Loading branch information
Rasmus Villemoes authored and Luis Chamberlain committed Nov 11, 2022
1 parent 89a6b59 commit 96a1a24
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions kernel/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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 */

0 comments on commit 96a1a24

Please sign in to comment.