Re: [PATCH v4 3/4] x86, kdump: Change crashkernel_high/low= to crashkernel=,high/low
On Thu, Apr 11, 2013 at 10:46 PM, HATAYAMA Daisuke wrote: > (2013/04/11 4:39), Yinghai Lu wrote: > >> Index: linux-2.6/kernel/kexec.c >> === >> --- linux-2.6.orig/kernel/kexec.c >> +++ linux-2.6/kernel/kexec.c >> @@ -1368,35 +1368,108 @@ static int __init parse_crashkernel_simp >> return 0; >> } >> >> +#define SUFFIX_HIGH 0 >> +#define SUFFIX_LOW 1 >> +#define SUFFIX_NULL 2 >> +static __initdata char *suffix_tbl[] = { >> + [SUFFIX_HIGH] = ",high", >> + [SUFFIX_LOW] = ",low", >> + [SUFFIX_NULL] = NULL, >> +}; >> + >> /* >> - * That function is the entry point for command line parsing and should be >> - * called from the arch-specific code. >> + * That function parses "suffix" crashkernel command lines like >> + * >> + * crashkernel=size,[high|low] >> + * >> + * It returns 0 on success and -EINVAL on failure. >>*/ >> +static int __init parse_crashkernel_suffix(char *cmdline, >> +unsigned long long *crash_size, >> +unsigned long long *crash_base, >> +const char *suffix) >> +{ >> + char *cur = cmdline; >> + >> + *crash_size = memparse(cmdline, ); >> + if (cmdline == cur) { >> + pr_warn("crashkernel: memory value expected\n"); >> + return -EINVAL; >> + } >> + >> + /* check with suffix */ >> + if (!strncmp(cur, suffix, strlen(suffix))) >> + return 0; > > What kind of strings do you intend to be passed here? The syntax that > matches this check would be > > [0-9]+[kmgKMG]?(,low|,high){.*(,low|,high)}* should be [0-9]+[kmgKMG](,low|,high) will tight the checking. > > though memparse() part might be less precise. For example, the following > one passes the check since it ends with ",low" and ",high" follows > "12345K" to be parsed by memparse(). Is this within your intension for > ease of implementation? > > crashkernel=12345K,highfoobar,highabcd,low it will be rejected. crashkernel=12345K,highfoobar,highabcd,high should be rejected too. > >> + >> + pr_warn("crashkernel: unrecognized char\n"); >> + return -EINVAL; >> +} > > I like functions checking errornous cases in the middle and ends with > successful case. How about: > > /* check with suffix */ > if (strncmp(cur, suffix, strlen(suffix)) { > pr_warn("crashkernel: unrecognized char\n"); > return -EINVAL; > } > > return 0; ok. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/4] x86, kdump: Change crashkernel_high/low= to crashkernel=,high/low
On Thu, Apr 11, 2013 at 10:46 PM, HATAYAMA Daisuke d.hatay...@jp.fujitsu.com wrote: (2013/04/11 4:39), Yinghai Lu wrote: cut Index: linux-2.6/kernel/kexec.c === --- linux-2.6.orig/kernel/kexec.c +++ linux-2.6/kernel/kexec.c @@ -1368,35 +1368,108 @@ static int __init parse_crashkernel_simp return 0; } +#define SUFFIX_HIGH 0 +#define SUFFIX_LOW 1 +#define SUFFIX_NULL 2 +static __initdata char *suffix_tbl[] = { + [SUFFIX_HIGH] = ,high, + [SUFFIX_LOW] = ,low, + [SUFFIX_NULL] = NULL, +}; + /* - * That function is the entry point for command line parsing and should be - * called from the arch-specific code. + * That function parses suffix crashkernel command lines like + * + * crashkernel=size,[high|low] + * + * It returns 0 on success and -EINVAL on failure. */ +static int __init parse_crashkernel_suffix(char *cmdline, +unsigned long long *crash_size, +unsigned long long *crash_base, +const char *suffix) +{ + char *cur = cmdline; + + *crash_size = memparse(cmdline, cur); + if (cmdline == cur) { + pr_warn(crashkernel: memory value expected\n); + return -EINVAL; + } + + /* check with suffix */ + if (!strncmp(cur, suffix, strlen(suffix))) + return 0; What kind of strings do you intend to be passed here? The syntax that matches this check would be [0-9]+[kmgKMG]?(,low|,high){.*(,low|,high)}* should be [0-9]+[kmgKMG](,low|,high) will tight the checking. though memparse() part might be less precise. For example, the following one passes the check since it ends with ,low and ,high follows 12345K to be parsed by memparse(). Is this within your intension for ease of implementation? crashkernel=12345K,highfoobar,highabcd,low it will be rejected. crashkernel=12345K,highfoobar,highabcd,high should be rejected too. + + pr_warn(crashkernel: unrecognized char\n); + return -EINVAL; +} I like functions checking errornous cases in the middle and ends with successful case. How about: /* check with suffix */ if (strncmp(cur, suffix, strlen(suffix)) { pr_warn(crashkernel: unrecognized char\n); return -EINVAL; } return 0; ok. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/4] x86, kdump: Change crashkernel_high/low= to crashkernel=,high/low
(2013/04/11 4:39), Yinghai Lu wrote: > Index: linux-2.6/kernel/kexec.c > === > --- linux-2.6.orig/kernel/kexec.c > +++ linux-2.6/kernel/kexec.c > @@ -1368,35 +1368,108 @@ static int __init parse_crashkernel_simp > return 0; > } > > +#define SUFFIX_HIGH 0 > +#define SUFFIX_LOW 1 > +#define SUFFIX_NULL 2 > +static __initdata char *suffix_tbl[] = { > + [SUFFIX_HIGH] = ",high", > + [SUFFIX_LOW] = ",low", > + [SUFFIX_NULL] = NULL, > +}; > + > /* > - * That function is the entry point for command line parsing and should be > - * called from the arch-specific code. > + * That function parses "suffix" crashkernel command lines like > + * > + * crashkernel=size,[high|low] > + * > + * It returns 0 on success and -EINVAL on failure. >*/ > +static int __init parse_crashkernel_suffix(char *cmdline, > +unsigned long long *crash_size, > +unsigned long long *crash_base, > +const char *suffix) > +{ > + char *cur = cmdline; > + > + *crash_size = memparse(cmdline, ); > + if (cmdline == cur) { > + pr_warn("crashkernel: memory value expected\n"); > + return -EINVAL; > + } > + > + /* check with suffix */ > + if (!strncmp(cur, suffix, strlen(suffix))) > + return 0; What kind of strings do you intend to be passed here? The syntax that matches this check would be [0-9]+[kmgKMG]?(,low|,high){.*(,low|,high)}* though memparse() part might be less precise. For example, the following one passes the check since it ends with ",low" and ",high" follows "12345K" to be parsed by memparse(). Is this within your intension for ease of implementation? crashkernel=12345K,highfoobar,highabcd,low > + > + pr_warn("crashkernel: unrecognized char\n"); > + return -EINVAL; > +} I like functions checking errornous cases in the middle and ends with successful case. How about: /* check with suffix */ if (strncmp(cur, suffix, strlen(suffix)) { pr_warn("crashkernel: unrecognized char\n"); return -EINVAL; } return 0; -- Thanks. HATAYAMA, Daisuke -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/4] x86, kdump: Change crashkernel_high/low= to crashkernel=,high/low
(2013/04/11 4:39), Yinghai Lu wrote: cut Index: linux-2.6/kernel/kexec.c === --- linux-2.6.orig/kernel/kexec.c +++ linux-2.6/kernel/kexec.c @@ -1368,35 +1368,108 @@ static int __init parse_crashkernel_simp return 0; } +#define SUFFIX_HIGH 0 +#define SUFFIX_LOW 1 +#define SUFFIX_NULL 2 +static __initdata char *suffix_tbl[] = { + [SUFFIX_HIGH] = ,high, + [SUFFIX_LOW] = ,low, + [SUFFIX_NULL] = NULL, +}; + /* - * That function is the entry point for command line parsing and should be - * called from the arch-specific code. + * That function parses suffix crashkernel command lines like + * + * crashkernel=size,[high|low] + * + * It returns 0 on success and -EINVAL on failure. */ +static int __init parse_crashkernel_suffix(char *cmdline, +unsigned long long *crash_size, +unsigned long long *crash_base, +const char *suffix) +{ + char *cur = cmdline; + + *crash_size = memparse(cmdline, cur); + if (cmdline == cur) { + pr_warn(crashkernel: memory value expected\n); + return -EINVAL; + } + + /* check with suffix */ + if (!strncmp(cur, suffix, strlen(suffix))) + return 0; What kind of strings do you intend to be passed here? The syntax that matches this check would be [0-9]+[kmgKMG]?(,low|,high){.*(,low|,high)}* though memparse() part might be less precise. For example, the following one passes the check since it ends with ,low and ,high follows 12345K to be parsed by memparse(). Is this within your intension for ease of implementation? crashkernel=12345K,highfoobar,highabcd,low + + pr_warn(crashkernel: unrecognized char\n); + return -EINVAL; +} I like functions checking errornous cases in the middle and ends with successful case. How about: /* check with suffix */ if (strncmp(cur, suffix, strlen(suffix)) { pr_warn(crashkernel: unrecognized char\n); return -EINVAL; } return 0; -- Thanks. HATAYAMA, Daisuke -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/4] x86, kdump: Change crashkernel_high/low= to crashkernel=,high/low
On Tue, Apr 09, 2013 at 01:01:50PM -0700, Yinghai Lu wrote: > Per hpa, use crashkernel=X,high crashkernel=Y,low instead of > crashkernel_hign=X crashkernel_low=Y. As that could be extensible. > > -v2: according to Vivek, change delimiter to ; > -v3: let hign and low only handle simple form and it conforms to > description in kernel-parameters.txt > still keep crashkernel=X override any crashkernel=X,high > crashkernel=Y,low > -v4: update get_last_crashkernel returning and add more strict > checking in parse_crashkernel_simple() found by HATAYAMA. > -v5: Change delimiter back to , according to HPA. > also separate parse_suffix from parse_simper according to vivek. > so we can avoid @pos in that path. > > Cc: HATAYAMA Daisuke > Signed-off-by: Yinghai Lu This one looks good to me. Looks like you posted this one independet of previous series. Can you repost the final version in a series again. I will do some more testing and ack it. Thanks Vivek > > --- > Documentation/kernel-parameters.txt | 10 +-- > arch/x86/kernel/setup.c |6 +- > kernel/kexec.c | 103 > +++- > 3 files changed, 98 insertions(+), 21 deletions(-) > > Index: linux-2.6/Documentation/kernel-parameters.txt > === > --- linux-2.6.orig/Documentation/kernel-parameters.txt > +++ linux-2.6/Documentation/kernel-parameters.txt > @@ -603,16 +603,16 @@ bytes respectively. Such letter suffixes > a memory unit (amount[KMG]). See also > Documentation/kdump/kdump.txt for an example. > > - crashkernel_high=size[KMG] > + crashkernel=size[KMG],high > [KNL, x86_64] range could be above 4G. Allow kernel > to allocate physical memory region from top, so could > be above 4G if system have more than 4G ram installed. > Otherwise memory region will be allocated below 4G, if > available. > It will be ignored if crashkernel=X is specified. > - crashkernel_low=size[KMG] > - [KNL, x86_64] range under 4G. When crashkernel_high= is > - passed, kernel could allocate physical memory region > + crashkernel=size[KMG],low > + [KNL, x86_64] range under 4G. When crashkernel=X,high > + is passed, kernel could allocate physical memory region > above 4G, that cause second kernel crash on system > that require some amount of low memory, e.g. swiotlb > requires at least 64M+32K low memory. Kernel would > @@ -620,7 +620,7 @@ bytes respectively. Such letter suffixes > This one let user to specify own low range under 4G > for second kernel instead. > 0: to disable low allocation. > - It will be ignored when crashkernel_high=X is not used > + It will be ignored when crashkernel=X,high is not used > or memory reserved is below 4G. > > cs89x0_dma= [HW,NET] > Index: linux-2.6/arch/x86/kernel/setup.c > === > --- linux-2.6.orig/arch/x86/kernel/setup.c > +++ linux-2.6/arch/x86/kernel/setup.c > @@ -526,7 +526,7 @@ static void __init reserve_crashkernel_l > int ret; > > total_low_mem = memblock_mem_size(1UL<<(32-PAGE_SHIFT)); > - /* crashkernel_low=YM */ > + /* crashkernel=Y,low */ > ret = parse_crashkernel_low(boot_command_line, total_low_mem, > _size, ); > if (ret != 0) { > @@ -539,7 +539,7 @@ static void __init reserve_crashkernel_l > low_size = swiotlb_size_or_default() + (8UL<<20); > auto_set = true; > } else { > - /* passed with crashkernel_low=0 ? */ > + /* passed with crashkernel=0,low ? */ > if (!low_size) > return; > } > @@ -579,7 +579,7 @@ static void __init reserve_crashkernel(v > ret = parse_crashkernel(boot_command_line, total_mem, > _size, _base); > if (ret != 0 || crash_size <= 0) { > - /* crashkernel_high=XM */ > + /* crashkernel=X,high */ > ret = parse_crashkernel_high(boot_command_line, total_mem, > _size, _base); > if (ret != 0 || crash_size <= 0) > Index: linux-2.6/kernel/kexec.c > === > --- linux-2.6.orig/kernel/kexec.c > +++ linux-2.6/kernel/kexec.c > @@ -1368,35 +1368,108 @@ static int __init parse_crashkernel_simp > return 0; > } > > +#define SUFFIX_HIGH 0 > +#define SUFFIX_LOW 1 > +#define
Re: [PATCH v4 3/4] x86, kdump: Change crashkernel_high/low= to crashkernel=,high/low
On Tue, Apr 09, 2013 at 01:01:50PM -0700, Yinghai Lu wrote: Per hpa, use crashkernel=X,high crashkernel=Y,low instead of crashkernel_hign=X crashkernel_low=Y. As that could be extensible. -v2: according to Vivek, change delimiter to ; -v3: let hign and low only handle simple form and it conforms to description in kernel-parameters.txt still keep crashkernel=X override any crashkernel=X,high crashkernel=Y,low -v4: update get_last_crashkernel returning and add more strict checking in parse_crashkernel_simple() found by HATAYAMA. -v5: Change delimiter back to , according to HPA. also separate parse_suffix from parse_simper according to vivek. so we can avoid @pos in that path. Cc: HATAYAMA Daisuke d.hatay...@jp.fujitsu.com Signed-off-by: Yinghai Lu ying...@kernel.org This one looks good to me. Looks like you posted this one independet of previous series. Can you repost the final version in a series again. I will do some more testing and ack it. Thanks Vivek --- Documentation/kernel-parameters.txt | 10 +-- arch/x86/kernel/setup.c |6 +- kernel/kexec.c | 103 +++- 3 files changed, 98 insertions(+), 21 deletions(-) Index: linux-2.6/Documentation/kernel-parameters.txt === --- linux-2.6.orig/Documentation/kernel-parameters.txt +++ linux-2.6/Documentation/kernel-parameters.txt @@ -603,16 +603,16 @@ bytes respectively. Such letter suffixes a memory unit (amount[KMG]). See also Documentation/kdump/kdump.txt for an example. - crashkernel_high=size[KMG] + crashkernel=size[KMG],high [KNL, x86_64] range could be above 4G. Allow kernel to allocate physical memory region from top, so could be above 4G if system have more than 4G ram installed. Otherwise memory region will be allocated below 4G, if available. It will be ignored if crashkernel=X is specified. - crashkernel_low=size[KMG] - [KNL, x86_64] range under 4G. When crashkernel_high= is - passed, kernel could allocate physical memory region + crashkernel=size[KMG],low + [KNL, x86_64] range under 4G. When crashkernel=X,high + is passed, kernel could allocate physical memory region above 4G, that cause second kernel crash on system that require some amount of low memory, e.g. swiotlb requires at least 64M+32K low memory. Kernel would @@ -620,7 +620,7 @@ bytes respectively. Such letter suffixes This one let user to specify own low range under 4G for second kernel instead. 0: to disable low allocation. - It will be ignored when crashkernel_high=X is not used + It will be ignored when crashkernel=X,high is not used or memory reserved is below 4G. cs89x0_dma= [HW,NET] Index: linux-2.6/arch/x86/kernel/setup.c === --- linux-2.6.orig/arch/x86/kernel/setup.c +++ linux-2.6/arch/x86/kernel/setup.c @@ -526,7 +526,7 @@ static void __init reserve_crashkernel_l int ret; total_low_mem = memblock_mem_size(1UL(32-PAGE_SHIFT)); - /* crashkernel_low=YM */ + /* crashkernel=Y,low */ ret = parse_crashkernel_low(boot_command_line, total_low_mem, low_size, base); if (ret != 0) { @@ -539,7 +539,7 @@ static void __init reserve_crashkernel_l low_size = swiotlb_size_or_default() + (8UL20); auto_set = true; } else { - /* passed with crashkernel_low=0 ? */ + /* passed with crashkernel=0,low ? */ if (!low_size) return; } @@ -579,7 +579,7 @@ static void __init reserve_crashkernel(v ret = parse_crashkernel(boot_command_line, total_mem, crash_size, crash_base); if (ret != 0 || crash_size = 0) { - /* crashkernel_high=XM */ + /* crashkernel=X,high */ ret = parse_crashkernel_high(boot_command_line, total_mem, crash_size, crash_base); if (ret != 0 || crash_size = 0) Index: linux-2.6/kernel/kexec.c === --- linux-2.6.orig/kernel/kexec.c +++ linux-2.6/kernel/kexec.c @@ -1368,35 +1368,108 @@ static int __init parse_crashkernel_simp return 0; } +#define SUFFIX_HIGH 0 +#define SUFFIX_LOW 1 +#define SUFFIX_NULL 2 +static __initdata char