We will output memstrack analysis report in kexec-tools side during kdump.
Becasue kdump will use 'reboot -f' to reboot 2nd kernel by default,
which leaves no stable hook target to terminate memstrack and output its
analysis report in dracut side. However it is easy to implement in
kexec-tools side.
In this patch, we will place the memstrack report after do_kdump_post(),
so the whole kdump process can be recorded by memstrack and analyzed.
Note this will make memstrack share memory with kdump in 2nd kernel, so
a larger possibility of memory shortage is expected. A bigger
crashkernel value will help if it is truly a problem.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
v1 -> v2: move memstrack report from do_kdump_pre to do_kdump_post.
---
dracut-kdump.sh | 22 ++++++++++++++++++++++
dracut-module-setup.sh | 2 ++
2 files changed, 24 insertions(+)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 4eec70b..8f4bc11 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -574,6 +574,26 @@ fence_kdump_notify()
fi
}
+handle_memstrack_report()
+{
+ MEMSTRACK_LOG="/.memstrack"
+
+ if [ "$DEBUG_MEM_LEVEL" -lt 4 ]; then
+ return
+ fi
+
+ if pgrep -c '[m]emstrack' > /dev/null; then
+ pkill --signal INT '[m]emstrack'
+ while pgrep -c '[m]emstrack' > /dev/null; do
+ sleep 1
+ done
+ fi
+
+ if [ -e "$MEMSTRACK_LOG" ]; then
+ IFS= dinfo < "$MEMSTRACK_LOG"
+ fi
+}
+
if [ "$1" = "--error-handler" ]; then
get_kdump_confs
do_failure_action
@@ -615,6 +635,8 @@ fi
save_log
+handle_memstrack_report
+
if [ $DUMP_RETVAL -ne 0 ]; then
exit 1
fi
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index a8ac16c..37845e3 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -1033,6 +1033,8 @@ install() {
inst "/usr/bin/printf" "/sbin/printf"
inst "/usr/bin/logger" "/sbin/logger"
inst "/usr/bin/chmod" "/sbin/chmod"
+ inst "/usr/bin/pkill" "/usr/bin/pkill"
+ inst "/usr/bin/pgrep" "/usr/bin/pgrep"
inst "/lib/kdump/kdump-lib-initramfs.sh"
"/lib/kdump-lib-initramfs.sh"
inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
--
2.33.1
Show replies by date