reduce memory consumption for powerpc firmware-assisted capture kernel
Subsystems (5)
v9 cover reduce memory consumption for powerpc firmware-assisted capture kernel
I posted the initial version [1] of patchset [2] adding support to enforce additional parameters when firmware-assisted dump capture kernel is active. Michal reposted it with few improvements to parameter processing to make it more robust. He further posted patchset [3] with few more improvements.
This patch series clubs the work from these two patch-sets while segregating the generic and arch-specific code to ease the review process.
[1] http://patchwork.ozlabs.org/patch/758176/
[2] http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=2733
[3] http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=3338
---
Hari Bathini (2):
powerpc/fadump: reduce memory consumption for capture kernel powerpc/fadump: update documentation about 'fadump_extra_args=' parameter
Michal Suchanek (6):
lib/cmdline.c: remove quotes symmetrically
boot/param: add pointer to current and next argument to unknown parameter callback lib/cmdline.c: add backslash support to kernel commandline parsing Documentation/admin-guide: backslash support in commandline lib/cmdline.c: implement single quotes in commandline argument parsing Documentation/admin-guide: single quotes in kernel arguments
Documentation/admin-guide/kernel-parameters.rst | 5 + Documentation/powerpc/firmware-assisted-dump.txt | 20 ++++- arch/powerpc/include/asm/fadump.h | 2 arch/powerpc/kernel/fadump.c | 97 +++++++++++++++++++++- arch/powerpc/kernel/prom.c | 7 ++ include/linux/moduleparam.h | 1 init/main.c | 8 +- kernel/module.c | 5 + kernel/params.c | 18 +++- lib/cmdline.c | 54 +++++++----- lib/dynamic_debug.c | 1 11 files changed, 179 insertions(+), 39 deletions(-)
PATCH v9 1/8 lib/cmdline.c: remove quotes symmetrically
From: Michal Suchanek <[email protected]>
Remove quotes from argument value only if there is qoute on both sides.
--- lib/cmdline.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
lib/cmdline.c +4 -6
@@ -227,14 +227,12 @@ char *next_arg(char *args, char **param, char **val) *val = args + equals +1 ;/* Don't include quotes in value. */ -if (**val =='"' ) { - (*val)++; -if (args[i-1 ] =='"' ) - args[i-1 ] ='\0' ; +if ((args[i-1 ] =='"' ) && ((quoted) || (**val =='"' ))) { + args[i-1 ] ='\0' ; +if (!quoted) + (*val)++; } } -if (quoted && args[i-1 ] =='"' ) - args[i-1 ] ='\0' ;if (args[i]) { args[i] ='\0' ;
Re: [PATCH v9 1/8] lib/cmdline.c: remove quotes symmetrically
Quoted 33 lines · On Wed, 15 Nov 2017 20:46:56 +0530 Hari Bathini <[email protected]>…
From: Michal Suchanek <[email protected]>
Remove quotes from argument value only if there is qoute on both sides.
Signed-off-by Michal Suchanek <[email protected]>--- lib/cmdline.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)lib/cmdline.c +4
-6@@ -227,14 +227,12 @@ char *next_arg(char *args, char **param, char **val) *val = args + equals + 1;/* Don't include quotes in value. */ -if (**val =='"' ) { - (*val)++; -if (args[i-1 ] =='"' ) - args[i-1 ] ='\0' ; +if ((args[i-1 ] =='"' ) && ((quoted) || (**val =='"' ))) { + args[i-1 ] ='\0' ; +if (!quoted) + (*val)++; } } -if (quoted && args[i-1 ] =='"' ) - args[i-1 ] ='\0' ;if (args[i]) {
Quoted 2 lines
args[i] = '\0';
This was only useful as separate patch with the incremental fadump update. Since the fadump update is squashed in this refresh series this can be squashed with the following lib/cmdline patch as well.
Thanks
Michal
PATCH v9 2/8 boot/param: add pointer to current and next argument to unknown parameter callback
In reply to Hari BathiniFrom: Michal Suchanek <[email protected]>
Add pointer to current and next argument to make parameter processing more robust. This can make parameter processing easier and less error prone in cases where the parameters need to be enforced/ignored based on firmware/system state.
---
Changes in v9:
* Fixed messages like below observed while loading modules with no parameters.
- iptable_filter: unknown parameter '' ignored
- ip_tables: unknown parameter '' ignored
include/linux/moduleparam.h | 1 + init/main.c | 8 ++++++-- kernel/module.c | 5 +++-- kernel/params.c | 18 ++++++++++++------ lib/dynamic_debug.c | 1 + 5 files changed, 23 insertions(+), 10 deletions(-)
include/linux/moduleparam.h +1 -0
@@ -328,6 +328,7 @@ extern char *parse_args(const char *name,s16 level_max, void *arg, int (*unknown)(char *param, char *val, +char *currant,char *next, const char *doing, void *arg));/* Called by module remove. */
init/main.c +6 -2
@@ -241,6 +241,7 @@ early_param("loglevel", loglevel);/* Change NUL term back to "=", to make "param" the whole string. */ static int __init repair_env_string (char *param,char *val, +char *unused3,char *unused2,const char *unused,void *arg) {if (val) {
@@ -259,6 +260,7 @@ static int __init repair_env_string(char *param, char *val,/* Anything after -- gets handed straight to init. */ static int __init set_init_arg (char *param,char *val, +char *unused3,char *unused2,const char *unused,void *arg) {unsigned int i;
@@ -266,7 +268,7 @@ static int __init set_init_arg(char *param, char *val,if (panic_later)return 0 ; -repair_env_string (param, val, unused,NULL ); +repair_env_string (param, val, unused3, unused2, unused,NULL );for (i =0 ; argv_init[i]; i++) {if (i ==MAX_INIT_ARGS ) {
@@ -284,9 +286,10 @@ static int __init set_init_arg(char *param, char *val,* unused parameters (modprobe will find them in /proc/cmdline). */ static int __init unknown_bootoption (char *param,char *val, +char *unused3,char *unused2,const char *unused,void *arg) { -repair_env_string (param, val, unused,NULL ); +repair_env_string (param, val, unused3, unused2, unused,NULL );/* Handle obsolete-style parameters */ if (obsolete_checksetup (param))
@@ -438,6 +441,7 @@ static noinline void __ref rest_init(void)/* Check for early params. */ static int __init do_early_param (char *param,char *val, +char *unused3,char *unused2,const char *unused,void *arg) {const struct obs_kernel_param *p;
kernel/module.c +3 -2
@@ -3619,8 +3619,9 @@ static int prepare_coming_module(struct module *mod)return 0 ; } -static int unknown_module_param_cb (char *param,char *val,const char *modname, -void *arg) +static int unknown_module_param_cb (char *param,char *val, +char *unused,char *unused2, +const char *modname,void *arg) {struct module *mod = arg;int ret;
kernel/params.c +12 -6
@@ -119,6 +119,8 @@ static void param_check_unsafe(const struct kernel_param *kp) static int parse_one(char *param, char *val, + char *currant, + char *next, const char *doing, const struct kernel_param *params, unsigned num_params,
@@ -126,7 +128,8 @@ static int parse_one(char *param,s16 max_level, void *arg, int (*handle_unknown)(char *param, char *val, - const char *doing, void *arg)) + char *currant, char *next, + const char *doing, void *arg)) { unsigned int i;int err;
@@ -153,7 +156,7 @@ static int parse_one(char *param,if (handle_unknown) {pr_debug ("doing %s: %s='%s'\n" , doing, param, val); -return handle_unknown (param, val, doing, arg); +return handle_unknown (param, val, currant, next, doing, arg); }pr_debug ("Unknown argument '%s'\n" , param);
@@ -169,9 +172,10 @@ char *parse_args(const char *doing,s16 max_level, void *arg, int (*unknown)(char *param, char *val, + char *currant, char *next, const char *doing, void *arg)) { - char *param, *val, *err = NULL; + char *param, *val, *next, *err = NULL;/* Chew leading spaces */ args =skip_spaces (args);
@@ -179,16 +183,18 @@ char *parse_args(const char *doing,if (*args)pr_debug ("doing %s, parsing ARGS: '%s'\n" , doing, args); -while (*args) { + next =next_arg (args, ¶m, &val); +while (*next) {int ret;int irq_was_disabled; - args =next_arg (args, ¶m, &val); + args = next; + next =next_arg (args, ¶m, &val);/* Stop at -- */ if (!val &&strcmp (param,"--" ) ==0 )return err ?: args; irq_was_disabled =irqs_disabled (); - ret =parse_one (param, val, doing, params, num, + ret =parse_one (param, val, args, next, doing, params, num, min_level, max_level, arg, unknown);if (irq_was_disabled && !irqs_disabled ()) pr_warn("%s: option '%s' enabled irq's!\n",
lib/dynamic_debug.c +1 -0
@@ -889,6 +889,7 @@ static int ddebug_dyndbg_param_cb(char *param, char *val,/* handle both dyndbg and $module.dyndbg params at boot */ static int ddebug_dyndbg_boot_param_cb (char *param,char *val, +char *unused3,char *unused2,const char *unused,void *arg) {vpr_info ("%s=\"%s\"\n" , param, val);
Re: [PATCH v9 2/8] boot/param: add pointer to current and next argument to unknown parameter callback
Hello,
Quoted 14 lines · On Wed, 15 Nov 2017 20:47:14 +0530 Hari Bathini <[email protected]>…
From: Michal Suchanek <[email protected]>
Add pointer to current and next argument to make parameter processing more robust. This can make parameter processing easier and less error prone in cases where the parameters need to be enforced/ignored based on
firmware/systemstate.Signed-off-by Michal Suchanek <[email protected]>Signed-off-by Hari Bathini <[email protected]>kernel/params.c +0
-0@@ -179,16 +183,18 @@ char *parse_args(const char *doing,if (*args)pr_debug ("doing %s, parsing ARGS: '%s'\n" , doing, args);
kernel/params.c char *parse_args(const char *doing, · line 193
Quoted 10 lines
kernel/params.c +4
-2-while (*args) { + next =next_arg (args, ¶m, &val); +while (*next) {int ret;int irq_was_disabled; - args =next_arg (args, ¶m, &val); + args = next; + next =next_arg (args, ¶m, &val);/* Stop at -- */
The [PATCH v8 5/6] you refreshed here moves the while(*next) to the end of the cycle for a reason. Checking *args at the start is mostly equivalent checking *next at the end. Checking *next at the start on the other hand skips the last argument.
The "mostly" part is that there is a bug here because *args is not checked at the start of the cycle making it possible to crash if it is
0. To fix that the if(*args) above should be extended to wrap the cycle.
Thanks
Michal
PATCH 1/1 Fix parse_args cycle limit check.
Actually args are supposed to be renamed to next so both and args hold the previous argument so both can be passed to the callback. This additionla patch should fix up the rename.
--- kernel/params.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
kernel/params.c +8 -6
@@ -182,17 +182,18 @@ char *parse_args(const char *doing,if (*args)pr_debug ("doing %s, parsing ARGS: '%s'\n" , doing, args); +else +return err; - next =next_arg (args, ¶m, &val); -while (*next) { + do { int ret; int irq_was_disabled; - args = next; next = next_arg(args, ¶m, &val); + /* Stop at -- */ if (!val && strcmp(param, "--") == 0) -return err ?: args; + return err ?: next; irq_was_disabled = irqs_disabled(); ret = parse_one(param, val, args, next, doing, params, num, min_level, max_level, arg, unknown);
@@ -215,9 +216,10 @@ char *parse_args(const char *doing, doing, val ?: "", param);break ; } - err =ERR_PTR (ret); - } + + args = next; + }while (*args);return err; }
Signature · 1 line
2.13.6
Randy Dunlap
reviewerRe: [PATCH] Fix parse_args cycle limit check.
Quoted 2 lines · Michal Suchanek
Actually args are supposed to be renamed to next so both and args hold the previous argument so both can be passed to the callback. This additionla patch
additional
Quoted 1 line
should fix up the rename.
Would you try rewriting the first sentence, please? I don't get it.
Quoted 3 lines
--- kernel/params.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
~Randy
Re: [PATCH] Fix parse_args cycle limit check.
Quoted 10 lines · On Fri, 15 Dec 2017 15:49:09 -0800 Randy Dunlap <[email protected]> wrote:
Quoted 3 lines · Michal Suchanek
Actually args are supposed to be renamed to next so both and args hold the previous argument so both can be passed to the callback. This additionla patch
additional
Quoted 1 line
should fix up the rename.
Would you try rewriting the first sentence, please? I don't get it.
Ok, I guess this should be clarified. For the original patch and the fixup squashed together this is what the patch is supposed to do:
This patch adds variable for tracking the parameter which is currently being processed. There is "args" variable which tracks the parameter which will be processed next so this patch adds "next" variable to track that and uses "args" to track the current argument.
Thanks
Michal
Randy Dunlap
reviewerRe: [PATCH] Fix parse_args cycle limit check.
Quoted 14 lines · Michal Suchánek
Quoted 10 lines · On Fri, 15 Dec 2017 15:49:09 -0800 Randy Dunlap <[email protected]> wrote:
Quoted 3 lines · Michal Suchanek
Actually args are supposed to be renamed to next so both and args hold the previous argument so both can be passed to the callback. This additionla patch
additional
Quoted 1 line
should fix up the rename.
Would you try rewriting the first sentence, please? I don't get it.
Quoted 7 lines
Ok, I guess this should be clarified. For the original patch and the fixup squashed together this is what the patch is supposed to do:
This patch adds variable for tracking the parameter which is currently being processed. There is "args" variable which tracks the parameter which will be processed next so this patch adds "next" variable to track that and uses "args" to track the current argument.
OK, thanks.
Signature · 1 line
~Randy
PATCH v9 3/8 lib/cmdline.c: add backslash support to kernel commandline parsing
In reply to Hari BathiniFrom: Michal Suchanek <[email protected]>
This allows passing quotes in kernel arguments. It is useful for passing nested arguemnts and might be useful if somebody wanted to pass a double quote directly as part of an argument. It is also useful to have quoting grammar more similar to shells and bootloaders.
--- lib/cmdline.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-)
lib/cmdline.c +20 -21
@@ -193,30 +193,36 @@ bool parse_option_str(const char *str, const char *option)/* * Parse a string to get a param value pair. -* You can use " around spaces, but can't escape ". +* You can use " around spaces, and you can escape with \ * Hyphens and underscores equivalent in parameter names. */ char *next_arg (char *args,char **param,char **val) {unsigned int i, equals =0 ; -int in_quote =0 , quoted =0 ; +int in_quote =0 , backslash =0 ;char *next; -if (*args =='"' ) { - args++; - in_quote =1 ; - quoted =1 ; - } -for (i =0 ; args[i]; i++) { -if (isspace (args[i]) && !in_quote) +if (isspace (args[i]) && !in_quote && !backslash)break ; -if (equals ==0 ) { -if (args[i] =='=' ) - equals = i; + +if ((equals ==0 ) && (args[i] =='=' )) + equals = i; + +if (!backslash) { +if ((args[i] =='"' ) || (args[i] =='\\' )) { +if (args[i] =='"' ) + in_quote = !in_quote; +if (args[i] =='\\' ) + backslash =1 ; + +memmove (args +1 , args, i); + args++; + i--; + } + }else { + backslash =0 ; } -if (args[i] =='"' ) - in_quote = !in_quote; } *param = args;
@@ -225,13 +231,6 @@ char *next_arg(char *args, char **param, char **val)else { args[equals] ='\0' ; *val = args + equals +1 ; - -/* Don't include quotes in value. */ -if ((args[i-1 ] =='"' ) && ((quoted) || (**val =='"' ))) { - args[i-1 ] ='\0' ; -if (!quoted) - (*val)++; - } }if (args[i]) {
PATCH 1/1 init/main.c: simplify repair_env_string
Quoting characters are now removed from the parameter so value always follows directly after the NUL terminating parameter name.
--- init/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Since the previous "[PATCH v9 3/8] lib/cmdline.c: add backslash support to kernel commandline parsing" adds the memmove in lib/cmdline.c it is now superfluous in init/main.c
init/main.c +4 -9
@@ -244,15 +244,10 @@ static int __init repair_env_string(char *param, char *val, const char *unused, void *arg) { if (val) { - /* param=val or param="val"? */ - if (val == param+strlen(param)+1) - val[-1 ] ='=' ; - else if (val == param+strlen(param)+2) { - val[-2 ] ='=' ; -memmove (val-1 , val,strlen (val)+1 ); - val--; - } else -BUG (); + int parm_len = strlen(param); + + param[parm_len] ='=' ; +BUG_ON (val != param + parm_len +1 ); }return 0 ; }
Signature · 1 line
2.13.6
Re: [PATCH] init/main.c: simplify repair_env_string
Cleaning out my INBOX, I stumbled across this old patch.
Quoted 11 lines · On Fri, 15 Dec 2017 22:33:17 +0100 Michal Suchanek <[email protected]> wrote:
Quoting characters are now removed from the parameter so value always follows directly after the NUL terminating parameter name.
Signed-off-by Michal Suchanek <[email protected]>--- init/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)Since the previous "[PATCH v9 3/8]
lib/cmdline.c: add backslash support to kernel commandline parsing" adds the memmove inlib/cmdline.cit is now superfluous ininit/main.c
I don't believe the above patches were ever applied. Were they?
-- Steve
Quoted 25 lines
init/main.c +4
-9@@ -244,15 +244,10 @@ static int __init repair_env_string(char *param, char *val, const char *unused, void *arg) { if (val) { - /* param=val or param="val"? */ - if (val == param+strlen(param)+1) - val[-1 ] ='=' ; - else if (val == param+strlen(param)+2) { - val[-2 ] ='=' ; -memmove (val-1 , val,strlen (val)+1 ); - val--; - } else -BUG (); + int parm_len = strlen(param); + + param[parm_len] ='=' ; +BUG_ON (val != param + parm_len +1 ); }return 0 ; }
Re: [PATCH] init/main.c: simplify repair_env_string
Quoted 13 lines · On Fri, 4 May 2018 11:40:35 -0400 Steven Rostedt <[email protected]> wrote:
Cleaning out my INBOX, I stumbled across this old patch.
Quoted 8 lines · On Fri, 15 Dec 2017 22:33:17 +0100 Michal Suchanek <[email protected]> wrote:
Quoting characters are now removed from the parameter so value always follows directly after the NUL terminating parameter name.
Signed-off-by Michal Suchanek <[email protected]>--- init/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Quoted 5 lines
Quoted 3 lines
Since the previous "[PATCH v9 3/8]
lib/cmdline.c: add backslash support to kernel commandline parsing" adds the memmove inlib/cmdline.cit is now superfluous ininit/main.cI don't believe the above patches were ever applied. Were they?
No, they weren't.
The reason to write them was to support the fadump_extra_args argument with peculiar semantics that required the quoting cleanup in kernel argument parsing.
A different solution for the fadump memory consumption is in the works so I dropped this. There was lack of interest from reviewers, too.
Thanks
Michal
Quoted 29 lines
-- Steve
Quoted 25 lines
init/main.c +4
-9@@ -244,15 +244,10 @@ static int __init repair_env_string(char *param, char *val, const char *unused, void *arg) {if (val) { -/* param=val or param="val"? */ -if (val == param+strlen (param)+1 ) - val[-1 ] ='=' ; -else if (val == param+strlen (param)+2 ) { - val[-2 ] ='=' ; -memmove (val-1 , val,strlen (val)+1 ); - val--; - }else -BUG (); +int parm_len =strlen (param); + + param[parm_len] ='=' ; +BUG_ON (val != param + parm_len +1 ); }return 0 ; }
PATCH v9 4/8 Documentation/admin-guide: backslash support in commandline
In reply to Hari BathiniFrom: Michal Suchanek <[email protected]>
--- Documentation/admin-guide/kernel-parameters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/kernel-parameters.rst +2 -2
@@ -35,9 +35,9 @@ can also be entered as:: log-buf-len=1M print_fatal_signals=1 -Double-quotes can be used to protect spaces in values, e.g.:: +Double-quotes and backslashes can be used to protect spaces in values, e.g.:: - param="spaces in here" + param="spaces in here" param2=spaces\ in\ here cpu lists: ----------
PATCH v9 5/8 lib/cmdline.c: implement single quotes in commandline argument parsing
In reply to Hari BathiniFrom: Michal Suchanek <[email protected]>
This brings the kernel parser about on par with bourne shell, grub, and other tools that chew the arguments before kernel does.
This should make it easier to deal with multiple levels of nesting/quoting. With same quoting grammar on each level there is less room for confusion.
--- lib/cmdline.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
lib/cmdline.c +20 -9
@@ -191,34 +191,45 @@ bool parse_option_str(const char *str, const char *option)return false; } +#define squash_char { \ + memmove(args + 1, args, i); \ + args++; \ + i--; \ +} +/* * Parse a string to get a param value pair. -* You can use " around spaces, and you can escape with \ +* You can use " or ' around spaces, and you can escape with \ * Hyphens and underscores equivalent in parameter names. */ char *next_arg (char *args,char **param,char **val) {unsigned int i, equals =0 ; -int in_quote =0 , backslash =0 ; +int in_quote =0 , backslash =0 , in_single =0 ;char *next;for (i =0 ; args[i]; i++) { -if (isspace (args[i]) && !in_quote && !backslash) +if (isspace (args[i]) && !in_quote && !backslash && !in_single)break ;if ((equals ==0 ) && (args[i] =='=' )) equals = i; -if (!backslash) { -if ((args[i] =='"' ) || (args[i] =='\\' )) { +if (in_single) { +if (args[i] =='\'' ) { + in_single =0 ; + squash_char; + } + }else if (!backslash) { +if ((args[i] =='"' ) || (args[i] =='\\' ) || + (args[i] =='\'' )) {if (args[i] =='"' ) in_quote = !in_quote;if (args[i] =='\\' ) backslash =1 ; - -memmove (args +1 , args, i); - args++; - i--; +if (args[i] =='\'' ) + in_single =1 ; + squash_char; } }else { backslash =0 ;
PATCH 1/1 Optimize final quote removal.
This is additional patch that avoids the memmove when processing the quote on the end of the parameter.
--- lib/cmdline.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-)
lib/cmdline.c +7 -2
@@ -191,7 +191,13 @@ bool parse_option_str(const char *str, const char *option)return false; } +#define break_arg_end (i) { \ + if (isspace(args[i]) && !in_quote && !backslash && !in_single) \ + break; \ + } +#define squash_char { \ + break_arg_end(i + 1); \ memmove(args + 1, args, i); \ args++; \ i--; \
@@ -209,8 +215,7 @@ char *next_arg(char *args, char **param, char **val)char *next;for (i =0 ; args[i]; i++) { -if (isspace (args[i]) && !in_quote && !backslash && !in_single) -break ; +break_arg_end (i);if ((equals ==0 ) && (args[i] =='=' )) equals = i;
Signature · 1 line
2.13.6
PATCH v9 6/8 Documentation/admin-guide: single quotes in kernel arguments
In reply to Hari BathiniFrom: Michal Suchanek <[email protected]>
--- Documentation/admin-guide/kernel-parameters.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/admin-guide/kernel-parameters.rst +3 -2
@@ -35,9 +35,10 @@ can also be entered as:: log-buf-len=1M print_fatal_signals=1 -Double-quotes and backslashes can be used to protect spaces in values, e.g.:: +Double-quotes single-quotes and backslashes can be used to protect spaces +in values, e.g.:: - param="spaces in here" param2=spaces\ in\ here + param="spaces in here" param2=spaces\ in\ here param3='@%# !\' cpu lists: ----------
PATCH v9 7/8 powerpc/fadump: reduce memory consumption for capture kernel
In reply to Hari BathiniWith fadump (dump capture) kernel booting like a regular kernel, it needs almost the same amount of memory to boot as the production kernel, which is unwarranted for a dump capture kernel. But with no option to disable some of the unnecessary subsystems in fadump kernel, that much memory is wasted on fadump, depriving the production kernel of that memory.
Introduce kernel parameter 'fadump_extra_args=' that would take regular parameters as a space separated quoted string, to be enforced when fadump is active. This 'fadump_extra_args=' parameter can be leveraged to pass parameters like nr_cpus=1, cgroup_disable=memory and numa=off, to disable unwarranted resources/subsystems.
Also, ensure the log "Firmware-assisted dump is active" is printed early in the boot process to put the subsequent fadump messages in context.
--- arch/powerpc/include/asm/fadump.h | 2 + arch/powerpc/kernel/fadump.c | 97 ++++++++++++++++++++++++++++++++++++- arch/powerpc/kernel/prom.c | 7 +++ 3 files changed, 103 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/fadump.h +2 -0
@@ -208,12 +208,14 @@ extern int early_init_dt_scan_fw_dump(unsigned long node, const char *uname, int depth, void *data);extern int fadump_reserve_mem (void );extern int setup_fadump (void ); +extern void enforce_fadump_extra_args (char *cmdline);extern int is_fadump_active (void );extern int should_fadump_crash (void );extern void crash_fadump (struct pt_regs *,const char *);extern void fadump_cleanup (void );#else /* CONFIG_FA_DUMP */ +static inline void enforce_fadump_extra_args (char *cmdline) { }static inline int is_fadump_active (void ) {return 0 ; }static inline int should_fadump_crash (void ) {return 0 ; }static inline void crash_fadump (struct pt_regs *regs,const char *str) { }
arch/powerpc/kernel/fadump.c +94 -3
123 lines not on this page · raw message
arch/powerpc/kernel/prom.c +7 -0
@@ -693,6 +693,13 @@ void __init early_init_devtree(void *params)of_scan_flat_dt (early_init_dt_scan_root,NULL );of_scan_flat_dt (early_init_dt_scan_memory_ppc,NULL ); +/* +* Look for 'fadump_extra_args=' parameter and enfore the additional +* parameters passed to it if fadump is active. +*/ +if (is_fadump_active ()) +enforce_fadump_extra_args (boot_command_line); +parse_early_param ();/* make sure we've parsed cmdline for mem= before this */
PATCH v9 8/8 powerpc/fadump: update documentation about 'fadump_extra_args=' parameter
In reply to Hari BathiniWith the introduction of 'fadump_extra_args=' parameter to pass additional parameters to fadump (capture) kernel, update documentation about it.
--- Documentation/powerpc/firmware-assisted-dump.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
Documentation/powerpc/firmware-assisted-dump.txt +19 -1
@@ -162,7 +162,19 @@ How to enable firmware-assisted dump (fadump): 1. Set config option CONFIG_FA_DUMP=y and build kernel. 2. Boot into linux kernel with 'fadump=on' kernel cmdline option. -3. Optionally, user can also set 'crashkernel=' kernel cmdline +3. A user can pass additional command line parameters as a space + separated quoted list through 'fadump_extra_args=' parameter, + to be enforced when fadump is active. For example, parameter + 'fadump_extra_args="nr_cpus=1 numa=off udev.children-max=2"' + will be changed to 'fadump_extra_args nr_cpus=1 numa=off + udev.children-max=2' in-place when fadump is active. This + parameter has no affect when fadump is not active. Multiple + instances of 'fadump_extra_args=' can be passed. This provision + can be used to reduce memory consumption during dump capture by + disabling unwarranted resources/subsystems like CPUs, NUMA + and such. Value with spaces can be passed as + 'fadump_extra_args="parameter=\"value with spaces\""' +4. Optionally, user can also set 'crashkernel=' kernel cmdline to specify size of the memory to reserve for boot memory dump preservation.
@@ -172,6 +184,12 @@ NOTE: 1. 'fadump_reserve_mem=' parameter has been deprecated. Instead 2. If firmware-assisted dump fails to reserve memory then it will fallback to existing kdump mechanism if 'crashkernel=' option is set at kernel cmdline. + 3. Special parameters like '--' passed inside fadump_extra_args are also + just left in-place. So, the user is advised to consider this while + specifying such parameters. It may be required to quote the argument + to fadump_extra_args when the bootloader uses double-quotes as + argument delimiter as well. eg + append = " fadump_extra_args=\"nr_cpus=1 numa=off udev.children-max=2\"" Sysfs/debugfs files: ------------
Le 15/11/2017 à 16:16, Hari Bathini a écrit :
Quoted 5 lines
I posted the initial version [1] of patchset [2] adding support to enforce additional parameters when firmware-assisted dump capture kernel is active. Michal reposted it with few improvements to parameter processing to make it more robust. He further posted patchset [3] with few more improvements.
Quoted 7 lines
This patch series clubs the work from these two patch-sets while segregating the generic and arch-specific code to ease the review process.
[1] http://patchwork.ozlabs.org/patch/758176/
[2] http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=2733
[3] http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=3338
Hello,
We still have this series flagged as "new" in powerpc's patchwork.
It is still of interest ?
Patch 1 applies but patch 2 hardly conflicts in init/main.c
So I'll flag it as "change requested", fell free to resubmit if still relevant.
Or if you think that's still required but don't plan to handle it, tell me and I'll open an issue in our issue board so that we don't loose history.
Thanks
Christophe
Quoted 27 lines
---
Hari Bathini (2):
powerpc/fadump: reduce memory consumption for capture kernel powerpc/fadump: update documentation about 'fadump_extra_args=' parameterMichal Suchanek (6):
lib/cmdline.c: remove quotes symmetrically
boot/param: add pointer to current and next argument to unknown parameter callbacklib/cmdline.c: add backslash support to kernel commandline parsingDocumentation/admin-guide: backslash support in commandlinelib/cmdline.c: implement single quotes in commandline argument parsingDocumentation/admin-guide: single quotes in kernel argumentsDocumentation/admin-guide/kernel-parameters.rst | 5 + Documentation/powerpc/firmware-assisted-dump.txt | 20 ++++- arch/powerpc/include/asm/fadump.h | 2 arch/powerpc/kernel/fadump.c | 97 +++++++++++++++++++++- arch/powerpc/kernel/prom.c | 7 ++ include/linux/moduleparam.h | 1 init/main.c | 8 +- kernel/module.c | 5 + kernel/params.c | 18 +++- lib/cmdline.c | 54 +++++++----- lib/dynamic_debug.c | 1 11 files changed, 179 insertions(+), 39 deletions(-)