Core kernel parameters and /sys/parameters?
Hi Greg,
Was looking at implementing "core_param" for things like "initcall_debug"
(ie. params with no prefix), and wanted to put them in sysfs of course. I hacked in a new "kernel" dir, but /sys/module/kernel/parameters/ is a bit of an odd place for it to end up in.
I noticed this comment in params.c:
* /sys/module/[mod->name]/parameters to /sys/parameters/[mod->name]/
I like the idea of /sys/parameters/ much better (perhaps even with core parameters at the top level). Is this obsolete? Planned?
Thanks,
Rusty.
include/linux/moduleparam.h +19 -0
@@ -99,6 +99,25 @@ struct kparam_array#define module_param (name, type, perm) \ module_param_named(name, name, type, perm) + +#ifndef MODULE +/** +* core_param - define a historical core kernel parameter. +* @name: the name of the cmdline and sysfs parameter (often the same as var) +* @var: the variable +* @type: the type (for param_set_##type and param_get_##type) +* @perm: visibility in sysfs +* +* core_param is just like module_param(), but cannot be modular and +* doesn't add a prefix (such as "printk."). This is for compatibility +* with __setup(), and it makes sense that truly core parameters aren't +* tied to the particular file they're in. +*/ +#define core_param (name, var, type, perm) \ + param_check_##type(name, &(var)); \ + __module_param_call("", name, param_set_##type, param_get_##type, \ + &var, perm) +#endif /* !MODULE */ /* Actually copy string: maxlen param is usually sizeof(string). */ #define module_param_string (name, string, len, perm) \
kernel/params.c +17 -13
@@ -584,12 +584,14 @@ static void __init param_sysfs_builtin(vstatic void __init param_sysfs_builtin (void ) {struct kernel_param *kp, *kp_begin =NULL ; -unsigned int i, name_len, count =0 ; +unsigned int i, name_len, skip, count =0 ;char modname[MODULE_NAME_LEN +1 ] ="" ; +char core[] ="kernel" ;for (i=0 ; i < __stop___param - __start___param; i++) {char *dot;size_t max_name_len; +const char *name; kp = &__start___param[i]; max_name_len =
@@ -597,25 +599,28 @@ static void __init param_sysfs_builtin(v dot =memchr (kp->name,'.' , max_name_len);if (!dot) { -DEBUGP ("couldn't find period in first %d characters " -"of %s\n" ,MODULE_NAME_LEN , kp->name); -continue ; + name = core; + name_len =strlen (name); + }else { + name = kp->name; + name_len = dot - kp->name; } - name_len = dot - kp->name;/* new kbuild_modname? */ if (strlen (modname) != name_len - ||strncmp (modname, kp->name, name_len) !=0 ) { + ||strncmp (modname, name, name_len) !=0 ) {/* add a new kobject for previous kernel_params. */ if (count) -kernel_param_sysfs_setup (modname, - kp_begin, - count, -strlen (modname)+1 ); +kernel_param_sysfs_setup (modname, kp_begin, + count, skip); -strncpy (modname, kp->name, name_len); +strncpy (modname, name, name_len); modname[name_len] ='\0' ; count =0 ; +if (!dot) + skip =0 ; +else + skip = name_len +1 ; kp_begin = kp; } count++;
@@ -623,8 +628,7 @@ static void __init param_sysfs_builtin(v/* last kernel_params need to be registered as well */ if (count) -kernel_param_sysfs_setup (modname, kp_begin, count, -strlen (modname)+1 ); +kernel_param_sysfs_setup (modname, kp_begin, count, skip); }
Quoted 7 lines · Rusty Russell
Hi Greg,
Was looking at implementing "
core_param" for things like "initcall_debug"
(ie. params with no prefix), and wanted to put them in sysfs of course. I hacked in a new "kernel" dir, but/sys/module/kernel/parameters/is a bit of an odd place for it to end up in.
Quoted 6 lines
I noticed this comment in
params.c:* /sys/module/[mod->name]/parameters to /sys/parameters/[mod->name]/
I like the idea of
/sys/parameters/much better (perhaps even with core parameters at the top level). Is this obsolete? Planned?
Did I write that comment? I sure don't remember it, sorry :)
I don't have any plans on changing this, but I do know people use the /sys/module/MODULE_NAME/parameters interface today, why change it?
thanks,
greg k-h
Quoted 13 lines · On Friday 15 August 2008 08:25:22 Greg KH wrote:
Quoted 12 lines · Rusty Russell
Hi Greg,
Was looking at implementing "
core_param" for things like
"initcall_debug" (ie. params with no prefix), and wanted to put them in sysfs of course. I hacked in a new "kernel" dir, but/sys/module/kernel/parameters/is a bit of an odd place for it to end up in.I noticed this comment in
params.c:* /sys/module/[mod->name]/parameters to /sys/parameters/[mod->name]/
Quoted 7 lines
Quoted 2 lines
I like the idea of
/sys/parameters/much better (perhaps even with core parameters at the top level). Is this obsolete? Planned?Did I write that comment? I sure don't remember it, sorry :)
I don't have any plans on changing this, but I do know people use the
/sys/module/MODULE_NAME/parametersinterface today, why change it?
Well mainly that many of them aren't modules, so if a change was planned for some other reason I'd support it.
And as I said, having core parameters (ie. converting things which are current __setup) appear in /sys/module/kernel/parameters/ is a bit strange.
Cheers,
Rusty.
Hi Rusty,
Quoted 15 lines
Quoted 15 lines
Quoted 6 lines
Was looking at implementing "
core_param" for things like
"initcall_debug" (ie. params with no prefix), and wanted to put them in sysfs of course. I hacked in a new "kernel" dir, but/sys/module/kernel/parameters/is a bit of an odd place for it to end up in.Quoted 6 lines
I noticed this comment in
params.c:* /sys/module/[mod->name]/parameters to /sys/parameters/[mod->name]/
I like the idea of
/sys/parameters/much better (perhaps even with core parameters at the top level). Is this obsolete? Planned?Did I write that comment? I sure don't remember it, sorry :)
Quoted 8 lines
Quoted 2 lines
I don't have any plans on changing this, but I do know people use the
/sys/module/MODULE_NAME/parametersinterface today, why change it?Well mainly that many of them aren't modules, so if a change was planned for some other reason I'd support it.
And as I said, having core parameters (ie. converting things which are current
__setup) appear in/sys/module/kernel/parameters/is a bit strange.
if you guys dislike /sys/module/kernel/* for core stuff, then you should do the change as soon as possible since userspace relies on it for a lot of tasks. Even I started using it. However I only want one general place for kernel/module parameters. A symlink might help us in the meantime to get the transition done smoothly.
Regards
Marcel