public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Ingo Molnar <mingo@elte.hu>
Cc: Yinghai Lu <yinghai@kernel.org>, Hugh Dickins <hugh@veritas.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, "Luck, Tony" <tony.luck@intel.com>
Subject: [RFC PATCH] param: start_kernel_with_args()
Date: Thu, 25 Dec 2008 22:50:44 +1030	[thread overview]
Message-ID: <200812252250.45071.rusty@rustcorp.com.au> (raw)
In-Reply-To: <200812252247.12957.rusty@rustcorp.com.au>

This is a cute corollary of the cleanup patches.  IA64 could particularly
benefit I think.

Impact: cleanup, new API

This gives a nicer entry point for archs to start_kernel; they don't
have to use boot_command_line (though they can if they want).

A nice side effect is that archs which use this entry point don't have
a COMMAND_LINE_SIZE limit any more (and if you don't define it,
boot_command_line does not exist).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/include/linux/start_kernel.h b/include/linux/start_kernel.h
--- a/include/linux/start_kernel.h
+++ b/include/linux/start_kernel.h
@@ -7,6 +7,13 @@
 /* Define the prototype for start_kernel here, rather than cluttering
    up something else. */
 
+/*
+ * Command-line pointer must be writable, must be NUL-terminated, but
+ * has no length limit and may be __initdata.
+ */
+extern asmlinkage void __init start_kernel_with_args(char *cmdline);
+
+/* Old entry point: calls arch_get_boot_command_line(). */
 extern asmlinkage void __init start_kernel(void);
 
 #endif /* _LINUX_START_KERNEL_H */
diff --git a/init/main.c b/init/main.c
--- a/init/main.c
+++ b/init/main.c
@@ -119,8 +119,11 @@ void (*late_time_init)(void);
 void (*late_time_init)(void);
 extern void softirq_init(void);
 
+#ifdef COMMAND_LINE_SIZE
 /* Untouched command line saved by arch-specific code. */
 char __initdata boot_command_line[COMMAND_LINE_SIZE];
+#endif
+
 /* Untouched saved command line (eg. for /proc) */
 char *saved_command_line;
 
@@ -522,15 +525,22 @@ void __init __weak thread_info_cache_ini
 {
 }
 
+#ifdef COMMAND_LINE_SIZE
 asmlinkage void __init start_kernel(void)
+{
+	arch_get_boot_command_line();
+	start_kernel_with_args(boot_command_line);
+}
+#endif
+
+asmlinkage void __init start_kernel_with_args(char *cmdline)
 {
 	char *static_command_line;
 
 	printk(KERN_NOTICE);
 	printk(linux_banner);
 
-	arch_get_boot_command_line();
-	parse_args("Core and early params", boot_command_line,
+	parse_args("Core and early params", cmdline,
 		   __start___core_param,
 		   __stop___core_param - __start___core_param,
 		   do_early_param, true);
@@ -579,10 +589,10 @@ asmlinkage void __init start_kernel(void
 	preempt_disable();
 	build_all_zonelists();
 	page_alloc_init();
-	printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
+	printk(KERN_NOTICE "Kernel command line: %s\n", cmdline);
 	/* param parsing can keep pointers to the commandline. */
-	static_command_line = alloc_bootmem(strlen(boot_command_line)+1);
-	strcpy(static_command_line, boot_command_line);
+	static_command_line = alloc_bootmem(strlen(cmdline)+1);
+	strcpy(static_command_line, cmdline);
 	parse_args("Booting kernel", static_command_line, __start___param,
 		   __stop___param - __start___param,
 		   &unknown_bootoption, false);
@@ -684,7 +694,7 @@ asmlinkage void __init start_kernel(void
 
 	ftrace_init();
 
-	saved_command_line = kstrdup(boot_command_line, GFP_KERNEL);
+	saved_command_line = kstrdup(cmdline, GFP_KERNEL);
 
 	/* Do the rest non-__init'ed, we're now alive */
 	rest_init();

  reply	other threads:[~2008-12-25 12:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-23  3:06 linux-next: parsing mem=700M broken Hugh Dickins
2008-12-23  5:52 ` Yinghai Lu
2008-12-23 14:33   ` Ingo Molnar
2008-12-24  7:38     ` Rusty Russell
2008-12-24  8:09       ` Yinghai Lu
2008-12-24 23:09         ` Yinghai Lu
2008-12-25 11:40         ` Rusty Russell
2008-12-25 22:46           ` Yinghai Lu
2008-12-24 12:30       ` Ingo Oeser
2008-12-25  5:50         ` Rusty Russell
2008-12-24 14:44       ` Hugh Dickins
2008-12-25  3:28         ` Rusty Russell
2008-12-27 13:12         ` Rusty Russell
2008-12-28  0:43           ` Hugh Dickins
2008-12-28  2:07             ` Yinghai Lu
2009-01-01  3:42               ` Rusty Russell
2008-12-25 12:17     ` [RFC] boot parameter handling cleanup II Rusty Russell
2008-12-25 12:20       ` Rusty Russell [this message]
2008-12-27 10:14       ` Ingo Molnar

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=200812252250.45071.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sfr@canb.auug.org.au \
    --cc=tony.luck@intel.com \
    --cc=yinghai@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox