Commit:     30d7e0d466b3ac0b5ef77e4062bf9385f0d72270
Parent:     ff91691bccdb741efb2df0489058a4961fa79598
Author:     Alon Bar-Lev <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 12 00:53:52 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Feb 12 09:48:37 2007 -0800

    [PATCH] Dynamic kernel command-line: common
    Current implementation stores a static command-line buffer allocated to
    COMMAND_LINE_SIZE size.  Most architectures stores two copies of this 
    one for future reference and one for parameter parsing.
    Current kernel command-line size for most architecture is much too small for
    module parameters, video settings, initramfs paramters and much more.  The
    problem is that setting COMMAND_LINE_SIZE to a grater value, allocates 
    In order to allow a greater command-line size, these buffers should be
    dynamically allocated or marked as init disposable buffers, so unused memory
    can be released.
    This patch renames the static saved_command_line variable into
    boot_command_line adding __initdata attribute, so that it can be disposed
    after initialization.  This rename is required so applications that use
    saved_command_line will not be affected by this change.
    It reintroduces saved_command_line as dynamically allocated buffer to match
    the data in boot_command_line.
    It also mark secondary command-line buffer as __initdata, and copies it to
    dynamically allocated static_command_line buffer components may hold 
    to it after initialization.
    This patch is for linux-2.6.20-rc4-mm1 and is divided to target each
    architecture.  I could not check this in any architecture so please forgive 
    if I got it wrong.
    The per-architecture modification is very simple, use boot_command_line in
    place of saved_command_line.  The common code is the change into dynamic
    This patch:
    1. Rename saved_command_line into boot_command_line, mark as init
    2. Add dynamic allocated saved_command_line.
    3. Add dynamic allocated static_command_line.
    4. During startup copy: boot_command_line into saved_command_line.  arch
       command_line into static_command_line.
    5. Parse static_command_line and not arch command_line, so arch
       command_line may be freed.
    Signed-off-by: Alon Bar-Lev <[EMAIL PROTECTED]>
    Cc: Andi Kleen <[EMAIL PROTECTED]>
    Cc: Paul Mackerras <[EMAIL PROTECTED]>
    Cc: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
    Cc: Richard Henderson <[EMAIL PROTECTED]>
    Cc: Ivan Kokshaysky <[EMAIL PROTECTED]>
    Cc: Russell King <[EMAIL PROTECTED]>
    Cc: Ian Molton <[EMAIL PROTECTED]>
    Cc: Mikael Starvik <[EMAIL PROTECTED]>
    Cc: David Howells <[EMAIL PROTECTED]>
    Cc: Yoshinori Sato <[EMAIL PROTECTED]>
    Cc: Ralf Baechle <[EMAIL PROTECTED]>
    Cc: Kyle McMartin <[EMAIL PROTECTED]>
    Cc: Heiko Carstens <[EMAIL PROTECTED]>
    Cc: Martin Schwidefsky <[EMAIL PROTECTED]>
    Cc: Hirokazu Takata <[EMAIL PROTECTED]>
    Cc: Paul Mundt <[EMAIL PROTECTED]>
    Cc: Kazumoto Kojima <[EMAIL PROTECTED]>
    Cc: Richard Curnow <[EMAIL PROTECTED]>
    Cc: William Lee Irwin III <[EMAIL PROTECTED]>
    Cc: "David S. Miller" <[EMAIL PROTECTED]>
    Cc: Jeff Dike <[EMAIL PROTECTED]>
    Cc: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
    Cc: Miles Bader <[EMAIL PROTECTED]>
    Cc: Chris Zankel <[EMAIL PROTECTED]>
    Cc: "Luck, Tony" <[EMAIL PROTECTED]>
    Cc: Geert Uytterhoeven <[EMAIL PROTECTED]>
    Cc: Roman Zippel <[EMAIL PROTECTED]>
    Cc: Greg Ungerer <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
 include/linux/init.h |    5 +++--
 init/main.c          |   29 ++++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index c65f510..e290a01 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -67,7 +67,8 @@ extern initcall_t __con_initcall_start[], 
 extern initcall_t __security_initcall_start[], __security_initcall_end[];
 /* Defined in init/main.c */
-extern char saved_command_line[];
+extern char __initdata boot_command_line[];
+extern char *saved_command_line;
 extern unsigned int reset_devices;
 /* used by init/main.c */
@@ -164,7 +165,7 @@ struct obs_kernel_param {
 #define early_param(str, fn)                                   \
        __setup_param(str, fn, fn, 1)
-/* Relies on saved_command_line being set */
+/* Relies on boot_command_line being set */
 void __init parse_early_param(void);
 #endif /* __ASSEMBLY__ */
diff --git a/init/main.c b/init/main.c
index 4e88bdd..4e9e92b 100644
--- a/init/main.c
+++ b/init/main.c
@@ -121,8 +121,12 @@ extern void time_init(void);
 void (*late_time_init)(void);
 extern void softirq_init(void);
-/* Untouched command line (eg. for /proc) saved by arch-specific code. */
-char saved_command_line[COMMAND_LINE_SIZE];
+/* Untouched command line saved by arch-specific code. */
+char __initdata boot_command_line[COMMAND_LINE_SIZE];
+/* Untouched saved command line (eg. for /proc) */
+char *saved_command_line;
+/* Command line for parameter parsing */
+static char *static_command_line;
 static char *execute_command;
 static char *ramdisk_execute_command;
@@ -400,6 +404,20 @@ static void __init smp_init(void)
+ * We need to store the untouched command line for future reference.
+ * We also need to store the touched command line since the parameter
+ * parsing is performed in place, and we should allow a component to
+ * store reference of name/value for future reference.
+ */
+static void __init setup_command_line(char *command_line)
+       saved_command_line = alloc_bootmem(strlen (boot_command_line)+1);
+       static_command_line = alloc_bootmem(strlen (command_line)+1);
+       strcpy (saved_command_line, boot_command_line);
+       strcpy (static_command_line, command_line);
  * We need to finalize in a non-__init function or else race conditions
  * between the root thread and the init thread may cause start_kernel to
  * be reaped by free_initmem before the root thread has proceeded to
@@ -453,7 +471,7 @@ void __init parse_early_param(void)
        /* All fall through to do_early_param. */
-       strlcpy(tmp_cmdline, saved_command_line, COMMAND_LINE_SIZE);
+       strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
        parse_args("early options", tmp_cmdline, NULL, 0, do_early_param);
        done = 1;
@@ -503,6 +521,7 @@ asmlinkage void __init start_kernel(void)
+       setup_command_line(command_line);
        smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
@@ -520,9 +539,9 @@ asmlinkage void __init start_kernel(void)
-       printk(KERN_NOTICE "Kernel command line: %s\n", saved_command_line);
+       printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
-       parse_args("Booting kernel", command_line, __start___param,
+       parse_args("Booting kernel", static_command_line, __start___param,
                   __stop___param - __start___param,
        if (!irqs_disabled()) {
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to