Skip to content

Commit 96a1a24

Browse files
Villemoesmcgrof
authored andcommitted
kernel/params.c: defer most of param_sysfs_init() to late_initcall time
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 <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 89a6b59 commit 96a1a24

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

kernel/params.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,11 @@ struct kobj_type module_ktype = {
953953
};
954954

955955
/*
956-
* param_sysfs_init - wrapper for built-in params support
956+
* param_sysfs_init - create "module" kset
957+
*
958+
* This must be done before the initramfs is unpacked and
959+
* request_module() thus becomes possible, because otherwise the
960+
* module load would fail in mod_sysfs_init.
957961
*/
958962
static int __init param_sysfs_init(void)
959963
{
@@ -964,11 +968,24 @@ static int __init param_sysfs_init(void)
964968
return -ENOMEM;
965969
}
966970

971+
return 0;
972+
}
973+
subsys_initcall(param_sysfs_init);
974+
975+
/*
976+
* param_sysfs_builtin_init - add sysfs version and parameter
977+
* attributes for built-in modules
978+
*/
979+
static int __init param_sysfs_builtin_init(void)
980+
{
981+
if (!module_kset)
982+
return -ENOMEM;
983+
967984
version_sysfs_builtin();
968985
param_sysfs_builtin();
969986

970987
return 0;
971988
}
972-
subsys_initcall(param_sysfs_init);
989+
late_initcall(param_sysfs_builtin_init);
973990

974991
#endif /* CONFIG_SYSFS */

0 commit comments

Comments
 (0)