public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Core kernel parameters and /sys/parameters?
@ 2008-07-31  3:59 Rusty Russell
  2008-08-14 22:25 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2008-07-31  3:59 UTC (permalink / raw)
  To: Greg KH, arjan, linux-kernel

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.

diff -r e7ea7e2ee243 include/linux/moduleparam.h
--- a/include/linux/moduleparam.h	Thu Jul 31 11:06:10 2008 +1000
+++ b/include/linux/moduleparam.h	Thu Jul 31 13:58:16 2008 +1000
@@ -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)			\
diff -r e7ea7e2ee243 kernel/params.c
--- a/kernel/params.c	Thu Jul 31 11:06:10 2008 +1000
+++ b/kernel/params.c	Thu Jul 31 13:58:16 2008 +1000
@@ -584,12 +584,14 @@ static void __init param_sysfs_builtin(v
 static 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);
 }
 
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Core kernel parameters and /sys/parameters?
  2008-07-31  3:59 Core kernel parameters and /sys/parameters? Rusty Russell
@ 2008-08-14 22:25 ` Greg KH
  2008-08-14 23:32   ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2008-08-14 22:25 UTC (permalink / raw)
  To: Rusty Russell; +Cc: arjan, linux-kernel

On Thu, Jul 31, 2008 at 01:59:02PM +1000, Rusty Russell wrote:
> 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?

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Core kernel parameters and /sys/parameters?
  2008-08-14 22:25 ` Greg KH
@ 2008-08-14 23:32   ` Rusty Russell
  2008-08-15  2:16     ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2008-08-14 23:32 UTC (permalink / raw)
  To: Greg KH; +Cc: arjan, linux-kernel

On Friday 15 August 2008 08:25:22 Greg KH wrote:
> On Thu, Jul 31, 2008 at 01:59:02PM +1000, Rusty Russell wrote:
> > 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?
>
> 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?

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Core kernel parameters and /sys/parameters?
  2008-08-14 23:32   ` Rusty Russell
@ 2008-08-15  2:16     ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2008-08-15  2:16 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Greg KH, arjan, linux-kernel

Hi Rusty,

>>>   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?
>>
>> 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?
>
> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-15  2:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-31  3:59 Core kernel parameters and /sys/parameters? Rusty Russell
2008-08-14 22:25 ` Greg KH
2008-08-14 23:32   ` Rusty Russell
2008-08-15  2:16     ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox