2nd kernel has very limited memory. Allocating huge pages will probably trigger OOM. So let's remove hugepages and hugepagesz kernel parameters for 2nd kernel when 1st kernel are using them.
If user wants huge pages cmdline in 2nd kernel, he/she can still specify it through KERNEL_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
This patch adds a new function remove_cmdline_param(). It takes a list of kernel parameters as its arguments and remove them from given kernel cmdline.
update: 1. Add description of remove_cmdline_param() per Vivek. 2. Remove_cmdline_param() will take kernel cmdline as $1, then strip it and print the result.
Signed-off-by: WANG Chao chaowang@redhat.com --- kdumpctl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index 36e969f..aba1e3c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,23 @@ if [ -f /etc/sysconfig/kdump ]; then . /etc/sysconfig/kdump fi
+# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>] +# Remove a list of kernel parameters from a given kernel cmdline and print the result. +# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. +function remove_cmdline_param() +{ + local cmdline=$1 + shift + + for arg in $@; do + cmdline=`echo $cmdline | \ + sed -e "s/\b$arg=[^ ]*\b//g" \ + -e "s/\b$arg\b//g" \ + -e "s/\s+/ /g"` + done + echo $cmdline +} + function save_core() { coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" @@ -221,8 +238,8 @@ function load_kdump() then KDUMP_COMMANDLINE=`cat /proc/cmdline` fi + KDUMP_COMMANDLINE=`remove_cmdline_param "$KDUMP_COMMANDLINE" crashkernel hugepages hugepagesz`
- KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | sed -e 's/crashkernel=[^ ]*//'` KDUMP_COMMANDLINE="${KDUMP_COMMANDLINE} ${KDUMP_COMMANDLINE_APPEND}"
$KEXEC $KEXEC_ARGS $standard_kexec_args \
On 07/26/13 at 02:39am, WANG Chao wrote:
2nd kernel has very limited memory. Allocating huge pages will probably trigger OOM. So let's remove hugepages and hugepagesz kernel parameters for 2nd kernel when 1st kernel are using them.
If user wants huge pages cmdline in 2nd kernel, he/she can still specify it through KERNEL_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
This patch adds a new function remove_cmdline_param(). It takes a list of kernel parameters as its arguments and remove them from given kernel cmdline.
update:
- Add description of remove_cmdline_param() per Vivek.
- Remove_cmdline_param() will take kernel cmdline as $1, then strip it and print the result.
Vivek?
Signed-off-by: WANG Chao chaowang@redhat.com
kdumpctl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index 36e969f..aba1e3c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,23 @@ if [ -f /etc/sysconfig/kdump ]; then . /etc/sysconfig/kdump fi
+# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>] +# Remove a list of kernel parameters from a given kernel cmdline and print the result. +# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. +function remove_cmdline_param() +{
- local cmdline=$1
- shift
- for arg in $@; do
cmdline=`echo $cmdline | \
sed -e "s/\b$arg=[^ ]*\b//g" \
-e "s/\b$arg\b//g" \
-e "s/\s\+/ /g"`
- done
- echo $cmdline
+}
function save_core() { coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" @@ -221,8 +238,8 @@ function load_kdump() then KDUMP_COMMANDLINE=`cat /proc/cmdline` fi
- KDUMP_COMMANDLINE=`remove_cmdline_param "$KDUMP_COMMANDLINE" crashkernel hugepages hugepagesz`
KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | sed -e 's/crashkernel=[^ ]*//'` KDUMP_COMMANDLINE="${KDUMP_COMMANDLINE} ${KDUMP_COMMANDLINE_APPEND}"
$KEXEC $KEXEC_ARGS $standard_kexec_args \
-- 1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On Fri, Jul 26, 2013 at 02:39:52AM +0800, WANG Chao wrote:
2nd kernel has very limited memory. Allocating huge pages will probably trigger OOM. So let's remove hugepages and hugepagesz kernel parameters for 2nd kernel when 1st kernel are using them.
If user wants huge pages cmdline in 2nd kernel, he/she can still specify it through KERNEL_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
This patch adds a new function remove_cmdline_param(). It takes a list of kernel parameters as its arguments and remove them from given kernel cmdline.
update:
- Add description of remove_cmdline_param() per Vivek.
- Remove_cmdline_param() will take kernel cmdline as $1, then strip it and print the result.
Signed-off-by: WANG Chao chaowang@redhat.com
Looks good to me.
Acked-by: Vivek Goyal vgoyal@redhat.com
It took me a while trying to understand sed expressions. Last one to replace multiple white spaces with one seems unnecessary as command line parser will anyway ignore multiple white spaces.
Thanks Vivek
kdumpctl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index 36e969f..aba1e3c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,23 @@ if [ -f /etc/sysconfig/kdump ]; then . /etc/sysconfig/kdump fi
+# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>] +# Remove a list of kernel parameters from a given kernel cmdline and print the result. +# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. +function remove_cmdline_param() +{
- local cmdline=$1
- shift
- for arg in $@; do
cmdline=`echo $cmdline | \
sed -e "s/\b$arg=[^ ]*\b//g" \
-e "s/\b$arg\b//g" \
-e "s/\s\+/ /g"`
- done
- echo $cmdline
+}
function save_core() { coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" @@ -221,8 +238,8 @@ function load_kdump() then KDUMP_COMMANDLINE=`cat /proc/cmdline` fi
- KDUMP_COMMANDLINE=`remove_cmdline_param "$KDUMP_COMMANDLINE" crashkernel hugepages hugepagesz`
KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | sed -e 's/crashkernel=[^ ]*//'` KDUMP_COMMANDLINE="${KDUMP_COMMANDLINE} ${KDUMP_COMMANDLINE_APPEND}"
$KEXEC $KEXEC_ARGS $standard_kexec_args \
-- 1.8.3.1
On 07/30/13 at 09:23am, Vivek Goyal wrote:
On Fri, Jul 26, 2013 at 02:39:52AM +0800, WANG Chao wrote:
2nd kernel has very limited memory. Allocating huge pages will probably trigger OOM. So let's remove hugepages and hugepagesz kernel parameters for 2nd kernel when 1st kernel are using them.
If user wants huge pages cmdline in 2nd kernel, he/she can still specify it through KERNEL_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
This patch adds a new function remove_cmdline_param(). It takes a list of kernel parameters as its arguments and remove them from given kernel cmdline.
update:
- Add description of remove_cmdline_param() per Vivek.
- Remove_cmdline_param() will take kernel cmdline as $1, then strip it and print the result.
Signed-off-by: WANG Chao chaowang@redhat.com
Looks good to me.
Acked-by: Vivek Goyal vgoyal@redhat.com
It took me a while trying to understand sed expressions. Last one to replace multiple white spaces with one seems unnecessary as command line parser will anyway ignore multiple white spaces.
cmdline size is limited and multiple white spaces looks bad :/ regular expressions is evil, tempted and dangerous.
On Tue, Jul 30, 2013 at 11:40:40PM +0800, WANG Chao wrote:
On 07/30/13 at 09:23am, Vivek Goyal wrote:
On Fri, Jul 26, 2013 at 02:39:52AM +0800, WANG Chao wrote:
2nd kernel has very limited memory. Allocating huge pages will probably trigger OOM. So let's remove hugepages and hugepagesz kernel parameters for 2nd kernel when 1st kernel are using them.
If user wants huge pages cmdline in 2nd kernel, he/she can still specify it through KERNEL_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
This patch adds a new function remove_cmdline_param(). It takes a list of kernel parameters as its arguments and remove them from given kernel cmdline.
update:
- Add description of remove_cmdline_param() per Vivek.
- Remove_cmdline_param() will take kernel cmdline as $1, then strip it and print the result.
Signed-off-by: WANG Chao chaowang@redhat.com
Looks good to me.
Acked-by: Vivek Goyal vgoyal@redhat.com
It took me a while trying to understand sed expressions. Last one to replace multiple white spaces with one seems unnecessary as command line parser will anyway ignore multiple white spaces.
cmdline size is limited
In this case you will at max remove 3 whitespaces.
and multiple white spaces looks bad :/
Nobody is looking at command line. This is passed internally.
regular expressions is evil, tempted and dangerous.
And that's the reason that keep regular expressions to minimum and keep them simple.
Thanks Vivek
On 07/30/13 at 11:51am, Vivek Goyal wrote:
On Tue, Jul 30, 2013 at 11:40:40PM +0800, WANG Chao wrote:
On 07/30/13 at 09:23am, Vivek Goyal wrote:
On Fri, Jul 26, 2013 at 02:39:52AM +0800, WANG Chao wrote:
2nd kernel has very limited memory. Allocating huge pages will probably trigger OOM. So let's remove hugepages and hugepagesz kernel parameters for 2nd kernel when 1st kernel are using them.
If user wants huge pages cmdline in 2nd kernel, he/she can still specify it through KERNEL_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
This patch adds a new function remove_cmdline_param(). It takes a list of kernel parameters as its arguments and remove them from given kernel cmdline.
update:
- Add description of remove_cmdline_param() per Vivek.
- Remove_cmdline_param() will take kernel cmdline as $1, then strip it and print the result.
Signed-off-by: WANG Chao chaowang@redhat.com
Looks good to me.
Acked-by: Vivek Goyal vgoyal@redhat.com
It took me a while trying to understand sed expressions. Last one to replace multiple white spaces with one seems unnecessary as command line parser will anyway ignore multiple white spaces.
cmdline size is limited
In this case you will at max remove 3 whitespaces.
and multiple white spaces looks bad :/
Nobody is looking at command line. This is passed internally.
regular expressions is evil, tempted and dangerous.
And that's the reason that keep regular expressions to minimum and keep them simple.
I couldn't argue on this one. I'll post an update later.
On Tue, Jul 30, 2013 at 11:55:35PM +0800, WANG Chao wrote:
On 07/30/13 at 11:51am, Vivek Goyal wrote:
On Tue, Jul 30, 2013 at 11:40:40PM +0800, WANG Chao wrote:
On 07/30/13 at 09:23am, Vivek Goyal wrote:
On Fri, Jul 26, 2013 at 02:39:52AM +0800, WANG Chao wrote:
2nd kernel has very limited memory. Allocating huge pages will probably trigger OOM. So let's remove hugepages and hugepagesz kernel parameters for 2nd kernel when 1st kernel are using them.
If user wants huge pages cmdline in 2nd kernel, he/she can still specify it through KERNEL_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
This patch adds a new function remove_cmdline_param(). It takes a list of kernel parameters as its arguments and remove them from given kernel cmdline.
update:
- Add description of remove_cmdline_param() per Vivek.
- Remove_cmdline_param() will take kernel cmdline as $1, then strip it and print the result.
Signed-off-by: WANG Chao chaowang@redhat.com
Looks good to me.
Acked-by: Vivek Goyal vgoyal@redhat.com
It took me a while trying to understand sed expressions. Last one to replace multiple white spaces with one seems unnecessary as command line parser will anyway ignore multiple white spaces.
cmdline size is limited
In this case you will at max remove 3 whitespaces.
and multiple white spaces looks bad :/
Nobody is looking at command line. This is passed internally.
regular expressions is evil, tempted and dangerous.
And that's the reason that keep regular expressions to minimum and keep them simple.
I couldn't argue on this one. I'll post an update later.
I think this patch is fine. There is no need to post an update. I am saying in general try to keep regular expressions simple.
Thanks Vivek