b/fs/proc/cmdline.c | 13 +++++++++++++ b/include/linux/init.h | 3 ++- b/init/main.c | 2 +- fs/proc/cmdline.c | 12 ++++++++++++ include/linux/init.h | 11 ++++++----- init/main.c | 9 +++++++++ 6 files changed, 43 insertions(+), 7 deletions(-)
Hello! This series provides /proc interfaces parallel to /proc/cmdline that provide only those kernel boot parameters that were provided by the bootloader (/proc/cmdline_load) and only those parameters that were embedded in the kernel image (/proc/cmdline_image, in boot-config format). This is especially important when these parameters are presented to the boot loader by automation that might gather them from diverse sources, and also when a kexec-based reboot process pulls the kernel boot parameters from /proc. If such a reboot process uses /proc/cmdline, the kernel parameters from the image are replicated on every reboot, which can be frustrating when the new kernel has different embedded kernel boot parameters. Why put these in /proc? Because they is quite similar to /proc/cmdline, so it makes sense to put it in the same place that /proc/cmdline is located. 1. fs/proc: Add /proc/cmdline_load for boot loader arguments. 2. fs/proc: Add /proc/cmdline_image for embedded arguments. Thanx, Paul ------------------------------------------------------------------------ b/fs/proc/cmdline.c | 13 +++++++++++++ b/include/linux/init.h | 3 ++- b/init/main.c | 2 +- fs/proc/cmdline.c | 12 ++++++++++++ include/linux/init.h | 11 ++++++----- init/main.c | 9 +++++++++ 6 files changed, 43 insertions(+), 7 deletions(-)
On Thu, Jul 27, 2023 at 08:35:10PM -0700, Paul E. McKenney wrote: Hello! This series provides a /proc interface parallel to /proc/cmdline that provides only those kernel boot parameters that were provided by the bootloader in a new /proc/cmdline_load. This is especially important when these parameters are presented to the boot loader by automation that might gather them from diverse sources, and also when a kexec-based reboot process pulls the kernel boot parameters from /proc. If such a reboot process uses /proc/cmdline, the kernel parameters from the image are replicated on every reboot, which can be frustrating when the new kernel has different embedded kernel boot parameters. Why put these in /proc? Because they is quite similar to /proc/cmdline, so it makes sense to put it in the same place that /proc/cmdline is located. 1. Update /proc/cmdline documentation to include boot config. 2. fs/proc: Add /proc/cmdline_load for boot loader arguments. 3. Add /proc/bootconfig to proc.rst. Changes since v1: o Dropped /proc/cmdline_image in favor of the existing /proc/bootconfig. o Pulled in fixes from Stephen and Arnd. o Added documentation for /proc/bootconfig. Thanx, Paul ------------------------------------------------------------------------ Documentation/filesystems/proc.rst | 2 ++ b/Documentation/filesystems/proc.rst | 3 ++- b/fs/proc/cmdline.c | 13 +++++++++++++ b/include/linux/init.h | 3 ++- b/init/main.c | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-)
Update the /proc/cmdline documentation to explicitly state that this
file provides kernel boot parameters obtained via boot config from the
kernel image as well as those supplied by the boot loader.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Arnd Bergmann <arnd@kernel.org>
---
Documentation/filesystems/proc.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index 7897a7dafcbc..75a8c899ebcc 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -686,7 +686,8 @@ files are there, and which are missing.
apm Advanced power management info
buddyinfo Kernel memory allocator information (see text) (2.5)
bus Directory containing bus specific information
- cmdline Kernel command line
+ cmdline Kernel command line, both from bootloader and embedded
+ in the kernel image.
cpuinfo Info about the CPU
devices Available devices (block and character)
dma Used DMS channels
--
2.40.1
On 7/31/23 16:31, Paul E. McKenney wrote: > Update the /proc/cmdline documentation to explicitly state that this > file provides kernel boot parameters obtained via boot config from the > kernel image as well as those supplied by the boot loader. > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Masami Hiramatsu <mhiramat@kernel.org> > Cc: Jonathan Corbet <corbet@lwn.net> > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: Randy Dunlap <rdunlap@infradead.org> > Cc: Stephen Rothwell <sfr@canb.auug.org.au> > Cc: Arnd Bergmann <arnd@kernel.org> Reviewed-by: Randy Dunlap <rdunlap@infradead.org> Thanks. > --- > Documentation/filesystems/proc.rst | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst > index 7897a7dafcbc..75a8c899ebcc 100644 > --- a/Documentation/filesystems/proc.rst > +++ b/Documentation/filesystems/proc.rst > @@ -686,7 +686,8 @@ files are there, and which are missing. > apm Advanced power management info > buddyinfo Kernel memory allocator information (see text) (2.5) > bus Directory containing bus specific information > - cmdline Kernel command line > + cmdline Kernel command line, both from bootloader and embedded > + in the kernel image. > cpuinfo Info about the CPU > devices Available devices (block and character) > dma Used DMS channels -- ~Randy
On Mon, Jul 31, 2023 at 07:00:22PM -0700, Randy Dunlap wrote: > On 7/31/23 16:31, Paul E. McKenney wrote: > > Update the /proc/cmdline documentation to explicitly state that this > > file provides kernel boot parameters obtained via boot config from the > > kernel image as well as those supplied by the boot loader. > > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Masami Hiramatsu <mhiramat@kernel.org> > > Cc: Jonathan Corbet <corbet@lwn.net> > > Cc: Andrew Morton <akpm@linux-foundation.org> > > Cc: Randy Dunlap <rdunlap@infradead.org> > > Cc: Stephen Rothwell <sfr@canb.auug.org.au> > > Cc: Arnd Bergmann <arnd@kernel.org> > > Reviewed-by: Randy Dunlap <rdunlap@infradead.org> Thank you both! I will apply these on my next rebase. Thanx, Paul > Thanks. > > > --- > > Documentation/filesystems/proc.rst | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst > > index 7897a7dafcbc..75a8c899ebcc 100644 > > --- a/Documentation/filesystems/proc.rst > > +++ b/Documentation/filesystems/proc.rst > > @@ -686,7 +686,8 @@ files are there, and which are missing. > > apm Advanced power management info > > buddyinfo Kernel memory allocator information (see text) (2.5) > > bus Directory containing bus specific information > > - cmdline Kernel command line > > + cmdline Kernel command line, both from bootloader and embedded > > + in the kernel image. > > cpuinfo Info about the CPU > > devices Available devices (block and character) > > dma Used DMS channels > > -- > ~Randy
On Mon, 31 Jul 2023 16:31:28 -0700 "Paul E. McKenney" <paulmck@kernel.org> wrote: > Update the /proc/cmdline documentation to explicitly state that this > file provides kernel boot parameters obtained via boot config from the > kernel image as well as those supplied by the boot loader. > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Masami Hiramatsu <mhiramat@kernel.org> > Cc: Jonathan Corbet <corbet@lwn.net> > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: Randy Dunlap <rdunlap@infradead.org> > Cc: Stephen Rothwell <sfr@canb.auug.org.au> > Cc: Arnd Bergmann <arnd@kernel.org> Looks good to me. Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Thank you! > --- > Documentation/filesystems/proc.rst | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst > index 7897a7dafcbc..75a8c899ebcc 100644 > --- a/Documentation/filesystems/proc.rst > +++ b/Documentation/filesystems/proc.rst > @@ -686,7 +686,8 @@ files are there, and which are missing. > apm Advanced power management info > buddyinfo Kernel memory allocator information (see text) (2.5) > bus Directory containing bus specific information > - cmdline Kernel command line > + cmdline Kernel command line, both from bootloader and embedded > + in the kernel image. > cpuinfo Info about the CPU > devices Available devices (block and character) > dma Used DMS channels > -- > 2.40.1 > -- Masami Hiramatsu (Google) <mhiramat@kernel.org>
In kernels built with CONFIG_BOOT_CONFIG_FORCE=y, /proc/cmdline will
show all kernel boot parameters, both those supplied by the boot loader
and those embedded in the kernel image. This works well for those who
just want to see all of the kernel boot parameters, but is not helpful to
those who need to see only those parameters supplied by the boot loader.
This is especially important when these parameters are presented to the
boot loader by automation that might gather them from diverse sources.
It is also useful when booting the next kernel via kexec(), in which
case it is necessary to supply only those kernel command-line arguments
from the boot loader, and most definitely not those that were embedded
into the current kernel.
Therefore, provide a /proc/cmdline_load file that shows only those kernel
boot parameters supplied by the boot loader.
Why put this in /proc? Because it is quite similar to /proc/cmdline, so
it makes sense to put it in the same place that /proc/cmdline is located.
[ sfr: Apply kernel test robot feedback. ]
[ paulmck: Apply Randy Dunlap feedback. ]
Co-developed-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: <linux-fsdevel@vger.kernel.org>
---
Documentation/filesystems/proc.rst | 1 +
fs/proc/cmdline.c | 13 +++++++++++++
include/linux/init.h | 3 ++-
init/main.c | 2 +-
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index 75a8c899ebcc..c2aee55248a8 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -688,6 +688,7 @@ files are there, and which are missing.
bus Directory containing bus specific information
cmdline Kernel command line, both from bootloader and embedded
in the kernel image.
+ cmdline_load Kernel command line obtained from kernel image (6.6)
cpuinfo Info about the CPU
devices Available devices (block and character)
dma Used DMS channels
diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
index a6f76121955f..1d0ef9d2949d 100644
--- a/fs/proc/cmdline.c
+++ b/fs/proc/cmdline.c
@@ -3,6 +3,7 @@
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <asm/setup.h>
#include "internal.h"
static int cmdline_proc_show(struct seq_file *m, void *v)
@@ -12,6 +13,13 @@ static int cmdline_proc_show(struct seq_file *m, void *v)
return 0;
}
+static int cmdline_load_proc_show(struct seq_file *m, void *v)
+{
+ seq_puts(m, boot_command_line);
+ seq_putc(m, '\n');
+ return 0;
+}
+
static int __init proc_cmdline_init(void)
{
struct proc_dir_entry *pde;
@@ -19,6 +27,11 @@ static int __init proc_cmdline_init(void)
pde = proc_create_single("cmdline", 0, NULL, cmdline_proc_show);
pde_make_permanent(pde);
pde->size = saved_command_line_len + 1;
+ if (IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE)) {
+ pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show);
+ pde_make_permanent(pde);
+ pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+ }
return 0;
}
fs_initcall(proc_cmdline_init);
diff --git a/include/linux/init.h b/include/linux/init.h
index 266c3e1640d4..29e75bbe7984 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -112,6 +112,7 @@
#define __REFCONST .section ".ref.rodata", "a"
#ifndef __ASSEMBLY__
+
/*
* Used for initialization calls..
*/
@@ -143,7 +144,7 @@ struct file_system_type;
/* Defined in init/main.c */
extern int do_one_initcall(initcall_t fn);
-extern char __initdata boot_command_line[];
+extern char boot_command_line[];
extern char *saved_command_line;
extern unsigned int saved_command_line_len;
extern unsigned int reset_devices;
diff --git a/init/main.c b/init/main.c
index ad920fac325c..2121685c479a 100644
--- a/init/main.c
+++ b/init/main.c
@@ -135,7 +135,7 @@ EXPORT_SYMBOL(system_state);
void (*__initdata late_time_init)(void);
/* Untouched command line saved by arch-specific code. */
-char __initdata boot_command_line[COMMAND_LINE_SIZE];
+char boot_command_line[COMMAND_LINE_SIZE] __ro_after_init;
/* Untouched saved command line (eg. for /proc) */
char *saved_command_line __ro_after_init;
unsigned int saved_command_line_len __ro_after_init;
--
2.40.1
Add /proc/bootconfig description to Documentation/filesystems/proc.rst.
Reported-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
Documentation/filesystems/proc.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index c2aee55248a8..4b9e9510a53f 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -684,6 +684,7 @@ files are there, and which are missing.
File Content
============ ===============================================================
apm Advanced power management info
+ bootconfig Kernel command line obtained from boot config (5.5)
buddyinfo Kernel memory allocator information (see text) (2.5)
bus Directory containing bus specific information
cmdline Kernel command line, both from bootloader and embedded
--
2.40.1
On Mon, 31 Jul 2023 16:31:30 -0700 "Paul E. McKenney" <paulmck@kernel.org> wrote: > Add /proc/bootconfig description to Documentation/filesystems/proc.rst. > Looks good to me. Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Thank you! > Reported-by: Masami Hiramatsu <mhiramat@kernel.org> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > --- > Documentation/filesystems/proc.rst | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst > index c2aee55248a8..4b9e9510a53f 100644 > --- a/Documentation/filesystems/proc.rst > +++ b/Documentation/filesystems/proc.rst > @@ -684,6 +684,7 @@ files are there, and which are missing. > File Content > ============ =============================================================== > apm Advanced power management info > + bootconfig Kernel command line obtained from boot config (5.5) > buddyinfo Kernel memory allocator information (see text) (2.5) > bus Directory containing bus specific information > cmdline Kernel command line, both from bootloader and embedded > -- > 2.40.1 > -- Masami Hiramatsu (Google) <mhiramat@kernel.org>
On 7/27/23 20:35, Paul E. McKenney wrote: > Hello! > > This series provides /proc interfaces parallel to /proc/cmdline that > provide only those kernel boot parameters that were provided by the > bootloader (/proc/cmdline_load) and only those parameters that were > embedded in the kernel image (/proc/cmdline_image, in boot-config format). > This is especially important when these parameters are presented to the > boot loader by automation that might gather them from diverse sources, > and also when a kexec-based reboot process pulls the kernel boot > parameters from /proc. If such a reboot process uses /proc/cmdline, > the kernel parameters from the image are replicated on every reboot, > which can be frustrating when the new kernel has different embedded > kernel boot parameters. > > Why put these in /proc? Because they is quite similar to /proc/cmdline, > so it makes sense to put it in the same place that /proc/cmdline is > located. > > 1. fs/proc: Add /proc/cmdline_load for boot loader arguments. > > 2. fs/proc: Add /proc/cmdline_image for embedded arguments. > > Thanx, Paul > Hi Paul, This series seems to be missing updates to Documentation/filesystems/proc.rst. Please add them. Thanks. > ------------------------------------------------------------------------ > > b/fs/proc/cmdline.c | 13 +++++++++++++ > b/include/linux/init.h | 3 ++- > b/init/main.c | 2 +- > fs/proc/cmdline.c | 12 ++++++++++++ > include/linux/init.h | 11 ++++++----- > init/main.c | 9 +++++++++ > 6 files changed, 43 insertions(+), 7 deletions(-) -- ~Randy
On Thu, Jul 27, 2023 at 09:25:06PM -0700, Randy Dunlap wrote: > > > On 7/27/23 20:35, Paul E. McKenney wrote: > > Hello! > > > > This series provides /proc interfaces parallel to /proc/cmdline that > > provide only those kernel boot parameters that were provided by the > > bootloader (/proc/cmdline_load) and only those parameters that were > > embedded in the kernel image (/proc/cmdline_image, in boot-config format). > > This is especially important when these parameters are presented to the > > boot loader by automation that might gather them from diverse sources, > > and also when a kexec-based reboot process pulls the kernel boot > > parameters from /proc. If such a reboot process uses /proc/cmdline, > > the kernel parameters from the image are replicated on every reboot, > > which can be frustrating when the new kernel has different embedded > > kernel boot parameters. > > > > Why put these in /proc? Because they is quite similar to /proc/cmdline, > > so it makes sense to put it in the same place that /proc/cmdline is > > located. > > > > 1. fs/proc: Add /proc/cmdline_load for boot loader arguments. > > > > 2. fs/proc: Add /proc/cmdline_image for embedded arguments. > > > > Thanx, Paul > > > > Hi Paul, > > This series seems to be missing updates to > Documentation/filesystems/proc.rst. > > Please add them. Good catch, thank you! I will fold the diff below into the three respective commits on my next rebase, but in the meantime, please let me know what you think. Thanx, Paul diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 7897a7dafcbc..98c43c5ef1ee 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -686,7 +686,10 @@ files are there, and which are missing. apm Advanced power management info buddyinfo Kernel memory allocator information (see text) (2.5) bus Directory containing bus specific information - cmdline Kernel command line + cmdline Kernel command line, both from bootloader and embedded + in the kernel image + cmdline_image Kernel command line obtained from boot loader (6.6) + cmdline_load Kernel command line obtained from kernel image (6.6) cpuinfo Info about the CPU devices Available devices (block and character) dma Used DMS channels
© 2016 - 2025 Red Hat, Inc.