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

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