On Fri, 28 Apr 2023 13:06:04 +0800
Tao Liu <ltao(a)redhat.com> wrote:
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.
v2 -> v3: remove pkill/pgrep way of kill memstrack, only keep systemctl
stop way of kill memstrack. Since systemctl is always available
in kdump case.
This makes it much better :-)
---
dracut-kdump.sh | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 4eec70b..9971e2c 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -574,6 +574,21 @@ fence_kdump_notify()
fi
}
+handle_memstrack_report()
+{
+ MEMSTRACK_LOG="/.memstrack"
+
+ if [ "$DEBUG_MEM_LEVEL" -lt 4 ]; then
+ return
+ fi
Where does DEBUG_MEM_LEVEL come from? It's not from the kexec-tools. Can
you add a small comment so people know where to look in the future.
+ systemctl stop memstrack.service
Is it guaranteed that the memstrack service runs with
DEBUG_MEM_LEVEL==4? If not this might throw some ugly errors.
Furthermore you are adding a dependency to systemd. Does it make sense
to add it to the .spec file? Or is systemd so fundamental that we can
assume it's always there?
Thanks
Philipp
+
+ if [ -e "$MEMSTRACK_LOG" ]; then
+ IFS= dinfo < "$MEMSTRACK_LOG"
+ fi
+}
+
if [ "$1" = "--error-handler" ]; then
get_kdump_confs
do_failure_action
@@ -615,6 +630,8 @@ fi
save_log
+handle_memstrack_report
+
if [ $DUMP_RETVAL -ne 0 ]; then
exit 1
fi