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 1st kernel cmdline or KERNEL_COMMANDLINE if set in /etc/sysconfig/kdump. However It wouldn't touch user specified KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
update: Add description of remove_cmdline_param() per Vivek.
Signed-off-by: WANG Chao chaowang@redhat.com --- kdumpctl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index 36e969f..8b2e746 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,19 @@ if [ -f /etc/sysconfig/kdump ]; then . /etc/sysconfig/kdump fi
+# Removes a list of kernel parameters from KDUMP_COMMANDLINE +# $@ takes a list of arguments, but can not be empty. +# For each arg in $@, kernel param "arg" and "arg=xxx" will be removed if exists. +function remove_cmdline_param() +{ + for arg in $@; do + KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | \ + sed -e "s/\b$arg=[^ ]*\b//g" \ + -e "s/\b$arg\b//g" \ + -e "s/\s+/ /g"` + done +} + function save_core() { coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" @@ -221,8 +234,8 @@ function load_kdump() then KDUMP_COMMANDLINE=`cat /proc/cmdline` fi + remove_cmdline_param 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 Fri, Jul 26, 2013 at 12:19:16AM +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 1st kernel cmdline or KERNEL_COMMANDLINE if set in /etc/sysconfig/kdump. However It wouldn't touch user specified KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
update: Add description of remove_cmdline_param() per Vivek.
Signed-off-by: WANG Chao chaowang@redhat.com
kdumpctl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index 36e969f..8b2e746 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,19 @@ if [ -f /etc/sysconfig/kdump ]; then . /etc/sysconfig/kdump fi
+# Removes a list of kernel parameters from KDUMP_COMMANDLINE +# $@ takes a list of arguments, but can not be empty. +# For each arg in $@, kernel param "arg" and "arg=xxx" will be removed if exists. +function remove_cmdline_param() +{
- for arg in $@; do
KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | \
sed -e "s/\b$arg=[^ ]*\b//g" \
-e "s/\b$arg\b//g" \
-e "s/\s\+/ /g"`
- done
+}
I think working on globals is not a very good idea (KDUMP_COMMANDLINE). How about passing two args. First arg is the command line and second arg is the param which needs to be removed. And this function will echo back the command line with parameter removed.
If functions modify globals directly, it is difficult to figure out who changed what.
@@ -221,8 +234,8 @@ function load_kdump() then KDUMP_COMMANDLINE=`cat /proc/cmdline` fi
- remove_cmdline_param crashkernel hugepages hugepagesz
- KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | sed -e 's/crashkernel=[^ ]*//'`
Also we should be able to use remove_cmdline_param() for removing crashkernel too?
Thanks Vivek
On 07/25/13 at 01:53pm, Vivek Goyal wrote:
On Fri, Jul 26, 2013 at 12:19:16AM +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 1st kernel cmdline or KERNEL_COMMANDLINE if set in /etc/sysconfig/kdump. However It wouldn't touch user specified KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump.
update: Add description of remove_cmdline_param() per Vivek.
Signed-off-by: WANG Chao chaowang@redhat.com
kdumpctl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index 36e969f..8b2e746 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,19 @@ if [ -f /etc/sysconfig/kdump ]; then . /etc/sysconfig/kdump fi
+# Removes a list of kernel parameters from KDUMP_COMMANDLINE +# $@ takes a list of arguments, but can not be empty. +# For each arg in $@, kernel param "arg" and "arg=xxx" will be removed if exists. +function remove_cmdline_param() +{
- for arg in $@; do
KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | \
sed -e "s/\b$arg=[^ ]*\b//g" \
-e "s/\b$arg\b//g" \
-e "s/\s\+/ /g"`
- done
+}
I think working on globals is not a very good idea (KDUMP_COMMANDLINE). How about passing two args. First arg is the command line and second arg is the param which needs to be removed. And this function will echo back the command line with parameter removed.
Actually this idea did come to my mind. I'll change.
If functions modify globals directly, it is difficult to figure out who changed what.
@@ -221,8 +234,8 @@ function load_kdump() then KDUMP_COMMANDLINE=`cat /proc/cmdline` fi
- remove_cmdline_param crashkernel hugepages hugepagesz
- KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | sed -e 's/crashkernel=[^ ]*//'`
Also we should be able to use remove_cmdline_param() for removing crashkernel too?
Yeah. Now we have a function there, why not use it?
WANG Chao