All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Greg KH <greg@kroah.com>,
	arjan@linux.intel.com, linux-kernel@vger.kernel.org
Subject: Core kernel parameters and /sys/parameters?
Date: Thu, 31 Jul 2008 13:59:02 +1000	[thread overview]
Message-ID: <200807311359.02561.rusty@rustcorp.com.au> (raw)

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);
 }
 
 

             reply	other threads:[~2008-07-31  3:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-31  3:59 Rusty Russell [this message]
2008-08-14 22:25 ` Core kernel parameters and /sys/parameters? Greg KH
2008-08-14 23:32   ` Rusty Russell
2008-08-15  2:16     ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200807311359.02561.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=arjan@linux.intel.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.