On Monday 10 October 2016 01:13 PM, Xunlei Pang wrote:
If there is any "rd.memdebug", we will monitor the kernel module memory consumption as follows:
- use dracut various inst_hook to monitor.
- monitor at the kdump's pre_dump stage.
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-kdump.sh | 11 +++++++++++ dracut-module-setup.sh | 12 ++++++++++++ kdumpctl | 14 ++++++++++++++ 3 files changed, 37 insertions(+)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 42ba37f..e8f08eb 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -33,6 +33,17 @@ do_kdump_pre() if [ -n "$KDUMP_PRE" ]; then "$KDUMP_PRE" fi
- # If cmdline hook exists, we know that memdebug-ko.sh
- # was activated.
- #
- # Execute memdebug-ko.sh before dumping, at this point
- # all kernel modules are supposed to be loaded.
- if [ -f /lib/dracut/hooks/cmdline/99-memdebug-ko.sh ]; then
. /lib/dracut/hooks/cmdline/99-memdebug-ko.sh# This is the last call of trace, turn off it.echo 0 > /sys/kernel/debug/tracing/tracing_on- fi
}
do_kdump_post() diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 68e0ff8..27d13b2 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -733,4 +733,16 @@ install() { # target. Ideally all this should be pushed into dracut iscsi module # at some point of time. kdump_check_iscsi_targets
- # Setup memdebug-ko if there is any "/tmp/.kdump.memdebug.ko.tmp* which
- # has been created by kdump temporarily as a hint.
- ls /tmp/.kdump.memdebug.ko.tmp* > /dev/null 2>&1
- if [[ $? -eq 0 ]]; then
inst_hook cmdline 99 "$moddir/memdebug-ko.sh"inst_hook pre-udev 99 "$moddir/memdebug-ko.sh"inst_hook pre-trigger 99 "$moddir/memdebug-ko.sh"inst_hook initqueue 99 "$moddir/memdebug-ko.sh"inst_hook pre-mount 99 "$moddir/memdebug-ko.sh"inst_hook cleanup 99 "$moddir/memdebug-ko.sh"- fi
} diff --git a/kdumpctl b/kdumpctl index 250f87b..928e163 100755 --- a/kdumpctl +++ b/kdumpctl @@ -178,7 +178,21 @@ rebuild_fadump_initrd()
rebuild_kdump_initrd() {
- # Clean up memdebug.ko temp file if any
- rm /tmp/.kdump.memdebug.ko.tmp* -rf
- echo "$(prepare_cmdline)" | grep -q "rd.memdebug"
- if [ $? -eq 0 ]; then
# As a hint to inst_hook memdebug.ko.sh for dracut 99kdumpbase,# see dracut-module-setup.sh.touch /tmp/.kdump.memdebug.ko.tmp$$$$- fi
- $MKDUMPRD $TARGET_INITRD $kdump_kver
Need to save this return value, which can be checked after rm instruction, otherwise $? will not have correct value after rm.
- # Clean up memdebug.ko temp file if any
- rm /tmp/.kdump.memdebug.ko.tmp* -rf
- if [ $? != 0 ]; then echo "mkdumprd: failed to make kdump initrd" >&2 return 1
~Pratyush