If there is any "rd.kodebug", we will monitor the kernel module
memory consumption as follows:
1) Use dracut early inst_hook to setup tracing, as no kernel module
is supposed to be loaded at this point.
2) Parse the trace data at kdump's pre_dump stage, as all kernel
modules needed are supposed to be loaded at this point.
Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
---
dracut-kdump.sh | 9 +++++++++
dracut-module-setup.sh | 9 +++++++++
kdumpctl | 14 ++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 42ba37f..7ada205 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -33,6 +33,15 @@ 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/00-memdebug-ko.sh ]; then
+ . /lib/dracut/hooks/cmdline/00-memdebug-ko.sh 1
+ fi
}
do_kdump_post()
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 68e0ff8..1785a12 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -733,4 +733,13 @@ 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
+ # Prepare tracing kernel module memory consumption.
+ # NOTE: Change the flename in dracut-kdump.sh::do_kdump_pre() accordingly.
+ inst_hook cmdline 00 "$moddir/memdebug-ko.sh"
+ fi
}
diff --git a/kdumpctl b/kdumpctl
index bf12d0d..171f252 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -178,12 +178,26 @@ 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.kodebug"
+ 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
if [ $? != 0 ]; then
echo "mkdumprd: failed to make kdump initrd" >&2
+ # Clean up memdebug.ko temp file if any
+ rm /tmp/.kdump.memdebug.ko.tmp* -rf
return 1
fi
+ # Clean up memdebug.ko temp file if any
+ rm /tmp/.kdump.memdebug.ko.tmp* -rf
return 0
}
--
1.8.3.1