Blame SOURCES/0488-99base-apply-kernel-module-memory-debug-support.patch

18971c
From e186d99780d1247f24535e5dc4ec9c82444afaa3 Mon Sep 17 00:00:00 2001
18971c
From: Xunlei Pang <xlpang@redhat.com>
18971c
Date: Thu, 3 Nov 2016 19:40:16 +0800
18971c
Subject: [PATCH] 99base: apply kernel module memory debug support
18971c
18971c
Extend "rd.memdebug" to "4", and "make_trace_mem" to "4+:komem".
18971c
Add new "cleanup_trace_mem" to cleanup the trace if active.
18971c
18971c
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
18971c
---
18971c
 modules.d/98systemd/dracut-cmdline.sh     |  2 +-
18971c
 modules.d/98systemd/dracut-pre-mount.sh   |  2 +-
18971c
 modules.d/98systemd/dracut-pre-pivot.sh   |  3 ++-
18971c
 modules.d/98systemd/dracut-pre-trigger.sh |  2 +-
18971c
 modules.d/99base/dracut-lib.sh            | 13 ++++++++++++-
18971c
 modules.d/99base/init.sh                  |  9 +++++----
18971c
 modules.d/99base/module-setup.sh          |  1 +
18971c
 7 files changed, 23 insertions(+), 9 deletions(-)
18971c
18971c
diff --git a/modules.d/98systemd/dracut-cmdline.sh b/modules.d/98systemd/dracut-cmdline.sh
18971c
index 630f3f92..b6b899f0 100755
18971c
--- a/modules.d/98systemd/dracut-cmdline.sh
18971c
+++ b/modules.d/98systemd/dracut-cmdline.sh
18971c
@@ -43,7 +43,7 @@ export root
18971c
 export rflags
18971c
 export fstype
18971c
 
18971c
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
18971c
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
18971c
 # run scriptlets to parse the command line
18971c
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
18971c
 source_hook cmdline
18971c
diff --git a/modules.d/98systemd/dracut-pre-mount.sh b/modules.d/98systemd/dracut-pre-mount.sh
18971c
index 55b051ab..199cf965 100755
18971c
--- a/modules.d/98systemd/dracut-pre-mount.sh
18971c
+++ b/modules.d/98systemd/dracut-pre-mount.sh
18971c
@@ -9,7 +9,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
18971c
 
18971c
 source_conf /etc/conf.d
18971c
 
18971c
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
18971c
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
18971c
 # pre pivot scripts are sourced just before we doing cleanup and switch over
18971c
 # to the new root.
18971c
 getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
18971c
diff --git a/modules.d/98systemd/dracut-pre-pivot.sh b/modules.d/98systemd/dracut-pre-pivot.sh
18971c
index 4c3eefcd..c079972e 100755
18971c
--- a/modules.d/98systemd/dracut-pre-pivot.sh
18971c
+++ b/modules.d/98systemd/dracut-pre-pivot.sh
18971c
@@ -10,12 +10,13 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
18971c
 
18971c
 source_conf /etc/conf.d
18971c
 
18971c
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
18971c
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
18971c
 # pre pivot scripts are sourced just before we doing cleanup and switch over
18971c
 # to the new root.
18971c
 getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
18971c
 source_hook pre-pivot
18971c
 
18971c
+cleanup_trace_mem
18971c
 # pre pivot cleanup scripts are sourced just before we switch over to the new root.
18971c
 getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
18971c
 source_hook cleanup
18971c
diff --git a/modules.d/98systemd/dracut-pre-trigger.sh b/modules.d/98systemd/dracut-pre-trigger.sh
18971c
index 0dbf32a5..241cd1e5 100755
18971c
--- a/modules.d/98systemd/dracut-pre-trigger.sh
18971c
+++ b/modules.d/98systemd/dracut-pre-trigger.sh
18971c
@@ -10,7 +10,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
18971c
 
18971c
 source_conf /etc/conf.d
18971c
 
18971c
-make_trace_mem "hook pre-trigger" "1:shortmem" "2+:mem" "3+:slab"
18971c
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
18971c
 
18971c
 source_hook pre-trigger
18971c
 
18971c
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
18971c
index 10d9cbc5..78e01a78 100755
18971c
--- a/modules.d/99base/dracut-lib.sh
18971c
+++ b/modules.d/99base/dracut-lib.sh
18971c
@@ -1177,12 +1177,20 @@ are_lists_eq() {
18971c
 
18971c
 setmemdebug() {
18971c
     if [ -z "$DEBUG_MEM_LEVEL" ]; then
18971c
-        export DEBUG_MEM_LEVEL=$(getargnum 0 0 3 rd.memdebug)
18971c
+        export DEBUG_MEM_LEVEL=$(getargnum 0 0 4 rd.memdebug)
18971c
     fi
18971c
 }
18971c
 
18971c
 setmemdebug
18971c
 
18971c
+cleanup_trace_mem()
18971c
+{
18971c
+    # tracekomem based on kernel trace needs cleanup after use.
18971c
+    if [ "$DEBUG_MEM_LEVEL" -eq 4 ]; then
18971c
+        tracekomem --cleanup
18971c
+    fi
18971c
+}
18971c
+
18971c
 # parameters: msg [trace_level:trace]...
18971c
 make_trace_mem()
18971c
 {
18971c
@@ -1267,5 +1275,8 @@ show_memstats()
18971c
         iomem)
18971c
             cat /proc/iomem
18971c
             ;;
18971c
+        komem)
18971c
+            tracekomem
18971c
+            ;;
18971c
     esac
18971c
 }
18971c
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
18971c
index 7bbe6703..473bf42e 100755
18971c
--- a/modules.d/99base/init.sh
18971c
+++ b/modules.d/99base/init.sh
18971c
@@ -124,7 +124,7 @@ if getarg "rd.cmdline=ask"; then
18971c
 fi
18971c
 
18971c
 # run scriptlets to parse the command line
18971c
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
18971c
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
18971c
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
18971c
 source_hook cmdline
18971c
 
18971c
@@ -153,7 +153,7 @@ getargbool 0 rd.udev.info -d -y rdudevinfo && udevadm control "$UDEV_LOG_PRIO_AR
18971c
 getargbool 0 rd.udev.debug -d -y rdudevdebug && udevadm control "$UDEV_LOG_PRIO_ARG=debug"
18971c
 udevproperty "hookdir=$hookdir"
18971c
 
18971c
-make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab'
18971c
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
18971c
 getarg 'rd.break=pre-trigger' -d 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
18971c
 source_hook pre-trigger
18971c
 
18971c
@@ -224,7 +224,7 @@ unset RDRETRY
18971c
 
18971c
 # pre-mount happens before we try to mount the root filesystem,
18971c
 # and happens once.
18971c
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
18971c
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
18971c
 getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
18971c
 source_hook pre-mount
18971c
 
18971c
@@ -260,11 +260,12 @@ done
18971c
 
18971c
 # pre pivot scripts are sourced just before we doing cleanup and switch over
18971c
 # to the new root.
18971c
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
18971c
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
18971c
 getarg 'rd.break=pre-pivot' -d 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
18971c
 source_hook pre-pivot
18971c
 
18971c
 make_trace_mem "hook cleanup" '1:shortmem' '2+:mem' '3+:slab'
18971c
+cleanup_trace_mem
18971c
 # pre pivot cleanup scripts are sourced just before we switch over to the new root.
18971c
 getarg 'rd.break=cleanup' -d 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
18971c
 source_hook cleanup
18971c
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
18971c
index d5e78613..8fd4e80d 100755
18971c
--- a/modules.d/99base/module-setup.sh
18971c
+++ b/modules.d/99base/module-setup.sh
18971c
@@ -34,6 +34,7 @@ install() {
18971c
     inst_script "$moddir/initqueue.sh" "/sbin/initqueue"
18971c
     inst_script "$moddir/loginit.sh" "/sbin/loginit"
18971c
     inst_script "$moddir/rdsosreport.sh" "/sbin/rdsosreport"
18971c
+    inst_script "$moddir/memtrace-ko.sh" "/sbin/tracekomem"
18971c
 
18971c
     [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
18971c
     mkdir -m 0755 -p ${initdir}/lib/dracut