Harald Hoyer 308914
From 49c4172f4eef6e2015615e132b199a7ec0699ffc Mon Sep 17 00:00:00 2001
Harald Hoyer 308914
From: Kairui Song <kasong@redhat.com>
Harald Hoyer 308914
Date: Wed, 8 Apr 2020 16:39:52 +0800
Harald Hoyer 308914
Subject: [PATCH] Remove memtrace-ko and rd.memdebug=4 support in dracut
Harald Hoyer 308914
Harald Hoyer 308914
This feature could be off loaded to memstrack, which have better
Harald Hoyer 308914
accurecy, better performance, and have more detailed tracing features.
Harald Hoyer 308914
Harald Hoyer 308914
Also simplify make_trace_mem a bit.
Harald Hoyer 308914
Harald Hoyer 308914
And currently rd.memdebug=4 is unstable, fails from time to time.
Harald Hoyer 308914
---
Harald Hoyer 308914
 dracut.cmdline.7.asc                             |   4 +--
Harald Hoyer 308914
 modules.d/98dracut-systemd/dracut-cmdline.sh     |   2 +-
Harald Hoyer 308914
 modules.d/98dracut-systemd/dracut-pre-mount.sh   |   2 +-
Harald Hoyer 308914
 modules.d/98dracut-systemd/dracut-pre-pivot.sh   |   2 +-
Harald Hoyer 308914
 modules.d/98dracut-systemd/dracut-pre-trigger.sh |   2 +-
Harald Hoyer 308914
 modules.d/99base/dracut-lib.sh                   |  44 +++++-------------------
Harald Hoyer 308914
 modules.d/99base/init.sh                         |   8 ++---
Harald Hoyer 308914
 modules.d/99base/memtrace-ko.sh                  | 191 -----------------------------------------------------------------------------------------------------
Harald Hoyer 308914
 modules.d/99base/module-setup.sh                 |   1 -
Harald Hoyer 308914
 9 files changed, 18 insertions(+), 238 deletions(-)
Harald Hoyer 308914
Harald Hoyer 308914
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
Harald Hoyer 308914
index 2b38aa33..c53601ea 100644
Harald Hoyer 308914
--- a/dracut.cmdline.7.asc
Harald Hoyer 308914
+++ b/dracut.cmdline.7.asc
Harald Hoyer 308914
@@ -188,9 +188,9 @@ It should be attached to any report about dracut problems.
Harald Hoyer 308914
     _/run/initramfs/init.log_.
Harald Hoyer 308914
     If "quiet" is set, it also logs to the console.
Harald Hoyer 308914
 
Harald Hoyer 308914
-**rd.memdebug=[0-4]**::
Harald Hoyer 308914
+**rd.memdebug=[0-3]**::
Harald Hoyer 308914
     Print memory usage info at various points, set the verbose level from 0 to 4.
Harald Hoyer 308914
-+    
Harald Hoyer 308914
++
Harald Hoyer 308914
     Higher level means more debugging output:
Harald Hoyer 308914
 +
Harald Hoyer 308914
 ----
Harald Hoyer 308914
diff --git a/modules.d/98dracut-systemd/dracut-cmdline.sh b/modules.d/98dracut-systemd/dracut-cmdline.sh
Harald Hoyer 308914
index bff9435a..6c6ee026 100755
Harald Hoyer 308914
--- a/modules.d/98dracut-systemd/dracut-cmdline.sh
Harald Hoyer 308914
+++ b/modules.d/98dracut-systemd/dracut-cmdline.sh
Harald Hoyer 308914
@@ -42,7 +42,7 @@ export root
Harald Hoyer 308914
 export rflags
Harald Hoyer 308914
 export fstype
Harald Hoyer 308914
 
Harald Hoyer 308914
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
Harald Hoyer 308914
 # run scriptlets to parse the command line
Harald Hoyer 308914
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
Harald Hoyer 308914
 source_hook cmdline
Harald Hoyer 308914
diff --git a/modules.d/98dracut-systemd/dracut-pre-mount.sh b/modules.d/98dracut-systemd/dracut-pre-mount.sh
Harald Hoyer 308914
index a3b9d291..ae511286 100755
Harald Hoyer 308914
--- a/modules.d/98dracut-systemd/dracut-pre-mount.sh
Harald Hoyer 308914
+++ b/modules.d/98dracut-systemd/dracut-pre-mount.sh
Harald Hoyer 308914
@@ -8,7 +8,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
Harald Hoyer 308914
 
Harald Hoyer 308914
 source_conf /etc/conf.d
Harald Hoyer 308914
 
Harald Hoyer 308914
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
Harald Hoyer 308914
 # pre pivot scripts are sourced just before we doing cleanup and switch over
Harald Hoyer 308914
 # to the new root.
Harald Hoyer 308914
 getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
Harald Hoyer 308914
diff --git a/modules.d/98dracut-systemd/dracut-pre-pivot.sh b/modules.d/98dracut-systemd/dracut-pre-pivot.sh
Harald Hoyer 308914
index dc9a2504..96e6f8ca 100755
Harald Hoyer 308914
--- a/modules.d/98dracut-systemd/dracut-pre-pivot.sh
Harald Hoyer 308914
+++ b/modules.d/98dracut-systemd/dracut-pre-pivot.sh
Harald Hoyer 308914
@@ -8,7 +8,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
Harald Hoyer 308914
 
Harald Hoyer 308914
 source_conf /etc/conf.d
Harald Hoyer 308914
 
Harald Hoyer 308914
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
Harald Hoyer 308914
 # pre pivot scripts are sourced just before we doing cleanup and switch over
Harald Hoyer 308914
 # to the new root.
Harald Hoyer 308914
 getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
Harald Hoyer 308914
diff --git a/modules.d/98dracut-systemd/dracut-pre-trigger.sh b/modules.d/98dracut-systemd/dracut-pre-trigger.sh
Harald Hoyer 308914
index 7cd821ed..a1a33960 100755
Harald Hoyer 308914
--- a/modules.d/98dracut-systemd/dracut-pre-trigger.sh
Harald Hoyer 308914
+++ b/modules.d/98dracut-systemd/dracut-pre-trigger.sh
Harald Hoyer 308914
@@ -8,7 +8,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
Harald Hoyer 308914
 
Harald Hoyer 308914
 source_conf /etc/conf.d
Harald Hoyer 308914
 
Harald Hoyer 308914
-make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab'
Harald Hoyer 308914
 
Harald Hoyer 308914
 source_hook pre-trigger
Harald Hoyer 308914
 
Harald Hoyer 308914
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 308914
index c57523d3..b7020892 100755
Harald Hoyer 308914
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 308914
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 308914
@@ -1187,50 +1187,25 @@ are_lists_eq() {
Harald Hoyer 308914
 
Harald Hoyer 308914
 setmemdebug() {
Harald Hoyer 308914
     if [ -z "$DEBUG_MEM_LEVEL" ]; then
Harald Hoyer 308914
-        export DEBUG_MEM_LEVEL=$(getargnum 0 0 4 rd.memdebug)
Harald Hoyer 308914
+        export DEBUG_MEM_LEVEL=$(getargnum 0 0 3 rd.memdebug)
Harald Hoyer 308914
     fi
Harald Hoyer 308914
 }
Harald Hoyer 308914
 
Harald Hoyer 308914
 setmemdebug
Harald Hoyer 308914
 
Harald Hoyer 308914
-cleanup_trace_mem()
Harald Hoyer 308914
-{
Harald Hoyer 308914
-    # tracekomem based on kernel trace needs cleanup after use.
Harald Hoyer 308914
-    if [ "$DEBUG_MEM_LEVEL" -eq 4 ]; then
Harald Hoyer 308914
-        tracekomem --cleanup
Harald Hoyer 308914
-    fi
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-# parameters: msg [trace_level:trace]...
Harald Hoyer 308914
-make_trace_mem()
Harald Hoyer 308914
-{
Harald Hoyer 308914
-    local msg
Harald Hoyer 308914
-    msg="$1"
Harald Hoyer 308914
-    shift
Harald Hoyer 308914
-    if [ -n "$DEBUG_MEM_LEVEL" ] && [ "$DEBUG_MEM_LEVEL" -gt 0 ]; then
Harald Hoyer 308914
-        make_trace show_memstats $DEBUG_MEM_LEVEL "[debug_mem]" "$msg" "$@" >&2
Harald Hoyer 308914
-    fi
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
 # parameters: func log_level prefix msg [trace_level:trace]...
Harald Hoyer 308914
-make_trace()
Harald Hoyer 308914
+make_trace_mem()
Harald Hoyer 308914
 {
Harald Hoyer 308914
-    local func log_level prefix msg msg_printed
Harald Hoyer 308914
+    local log_level prefix msg msg_printed
Harald Hoyer 308914
     local trace trace_level trace_in_higher_levels insert_trace
Harald Hoyer 308914
 
Harald Hoyer 308914
-    func=$1
Harald Hoyer 308914
-    shift
Harald Hoyer 308914
-
Harald Hoyer 308914
-    log_level=$1
Harald Hoyer 308914
-    shift
Harald Hoyer 308914
-
Harald Hoyer 308914
-    prefix=$1
Harald Hoyer 308914
-    shift
Harald Hoyer 308914
-
Harald Hoyer 308914
     msg=$1
Harald Hoyer 308914
     shift
Harald Hoyer 308914
 
Harald Hoyer 308914
-    if [ -z "$log_level" ]; then
Harald Hoyer 308914
+    prefix='[debug_mem]'
Harald Hoyer 308914
+    log_level=$DEBUG_MEM_LEVEL
Harald Hoyer 308914
+
Harald Hoyer 308914
+    if [ -z "$log_level" ] || [ "$log_level" -le 0 ]; then
Harald Hoyer 308914
         return
Harald Hoyer 308914
     fi
Harald Hoyer 308914
 
Harald Hoyer 308914
@@ -1263,7 +1238,7 @@ make_trace()
Harald Hoyer 308914
                 echo "$prefix $msg"
Harald Hoyer 308914
                 msg_printed=1
Harald Hoyer 308914
             fi
Harald Hoyer 308914
-            $func $trace
Harald Hoyer 308914
+            show_memstats $trace
Harald Hoyer 308914
         fi
Harald Hoyer 308914
         shift
Harald Hoyer 308914
     done
Harald Hoyer 308914
@@ -1285,9 +1260,6 @@ show_memstats()
Harald Hoyer 308914
         iomem)
Harald Hoyer 308914
             cat /proc/iomem
Harald Hoyer 308914
             ;;
Harald Hoyer 308914
-        komem)
Harald Hoyer 308914
-            tracekomem
Harald Hoyer 308914
-            ;;
Harald Hoyer 308914
     esac
Harald Hoyer 308914
 }
Harald Hoyer 308914
 
Harald Hoyer 308914
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer 308914
index 1111d09b..148ce831 100755
Harald Hoyer 308914
--- a/modules.d/99base/init.sh
Harald Hoyer 308914
+++ b/modules.d/99base/init.sh
Harald Hoyer 308914
@@ -131,7 +131,7 @@ if ! getargbool 1 'rd.hostonly'; then
Harald Hoyer 308914
 fi
Harald Hoyer 308914
 
Harald Hoyer 308914
 # run scriptlets to parse the command line
Harald Hoyer 308914
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
Harald Hoyer 308914
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
Harald Hoyer 308914
 source_hook cmdline
Harald Hoyer 308914
 
Harald Hoyer 308914
@@ -160,7 +160,7 @@ fi
Harald Hoyer 308914
 
Harald Hoyer 308914
 udevproperty "hookdir=$hookdir"
Harald Hoyer 308914
 
Harald Hoyer 308914
-make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab'
Harald Hoyer 308914
 getarg 'rd.break=pre-trigger' -d 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
Harald Hoyer 308914
 source_hook pre-trigger
Harald Hoyer 308914
 
Harald Hoyer 308914
@@ -230,7 +230,7 @@ unset RDRETRY
Harald Hoyer 308914
 
Harald Hoyer 308914
 # pre-mount happens before we try to mount the root filesystem,
Harald Hoyer 308914
 # and happens once.
Harald Hoyer 308914
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
Harald Hoyer 308914
 getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
Harald Hoyer 308914
 source_hook pre-mount
Harald Hoyer 308914
 
Harald Hoyer 308914
@@ -266,7 +266,7 @@ done
Harald Hoyer 308914
 
Harald Hoyer 308914
 # pre pivot scripts are sourced just before we doing cleanup and switch over
Harald Hoyer 308914
 # to the new root.
Harald Hoyer 308914
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
Harald Hoyer 308914
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
Harald Hoyer 308914
 getarg 'rd.break=pre-pivot' -d 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
Harald Hoyer 308914
 source_hook pre-pivot
Harald Hoyer 308914
 
Harald Hoyer 308914
diff --git a/modules.d/99base/memtrace-ko.sh b/modules.d/99base/memtrace-ko.sh
Harald Hoyer 308914
deleted file mode 100755
Harald Hoyer 308914
index ee035e15..00000000
Harald Hoyer 308914
--- a/modules.d/99base/memtrace-ko.sh
Harald Hoyer 308914
+++ /dev/null
Harald Hoyer 308914
@@ -1,191 +0,0 @@
Harald Hoyer 308914
-#!/bin/sh
Harald Hoyer 308914
-
Harald Hoyer 308914
-# Try to find out kernel modules with large total memory allocation during loading.
Harald Hoyer 308914
-# For large slab allocation, it will fall into buddy, also not trace "mm_page_free"
Harald Hoyer 308914
-# considering large free is quite rare for module_init, thus saving tons of events
Harald Hoyer 308914
-# to avoid trace data overwritten.
Harald Hoyer 308914
-#
Harald Hoyer 308914
-# Therefore, tracing "mm_page_alloc"alone should be enough for the purpose.
Harald Hoyer 308914
-
Harald Hoyer 308914
-# "sys/kernel/tracing" has the priority if exists.
Harald Hoyer 308914
-get_trace_base() {
Harald Hoyer 308914
-    # trace access through debugfs would be obsolete if "/sys/kernel/tracing" is available.
Harald Hoyer 308914
-    if [ -d "/sys/kernel/tracing" ]; then
Harald Hoyer 308914
-        echo "/sys/kernel"
Harald Hoyer 308914
-    else
Harald Hoyer 308914
-        echo "/sys/kernel/debug"
Harald Hoyer 308914
-    fi
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-# We want to enable these trace events.
Harald Hoyer 308914
-get_want_events() {
Harald Hoyer 308914
-    echo "module:module_put module:module_load kmem:mm_page_alloc"
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-get_event_filter() {
Harald Hoyer 308914
-    echo "comm == systemd-udevd || comm == modprobe || comm == insmod"
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-is_trace_ready() {
Harald Hoyer 308914
-    local trace_base want_events current_events
Harald Hoyer 308914
-
Harald Hoyer 308914
-    trace_base=$(get_trace_base)
Harald Hoyer 308914
-    ! [ -f "$trace_base/tracing/trace" ] && return 1
Harald Hoyer 308914
-
Harald Hoyer 308914
-    [ "$(cat $trace_base/tracing/tracing_on)" -eq 0 ] && return 1
Harald Hoyer 308914
-
Harald Hoyer 308914
-    # Also check if trace events were properly setup.
Harald Hoyer 308914
-    want_events=$(get_want_events)
Harald Hoyer 308914
-    current_events=$(echo $(cat $trace_base/tracing/set_event))
Harald Hoyer 308914
-    [ "$current_events" != "$want_events" ] && return 1
Harald Hoyer 308914
-
Harald Hoyer 308914
-    return 0
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-prepare_trace() {
Harald Hoyer 308914
-    local trace_base
Harald Hoyer 308914
-
Harald Hoyer 308914
-    trace_base=$(get_trace_base)
Harald Hoyer 308914
-    # old debugfs interface case.
Harald Hoyer 308914
-    if ! [ -d "$trace_base/tracing" ]; then
Harald Hoyer 308914
-        mount none -t debugfs $trace_base
Harald Hoyer 308914
-    # new tracefs interface case.
Harald Hoyer 308914
-    elif ! [ -f "$trace_base/tracing/trace" ]; then
Harald Hoyer 308914
-        mount none -t tracefs "$trace_base/tracing"
Harald Hoyer 308914
-    fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-    if ! [ -f "$trace_base/tracing/trace" ]; then
Harald Hoyer 308914
-        echo "WARN: Mount trace failed for kernel module memory analyzing."
Harald Hoyer 308914
-        return 1
Harald Hoyer 308914
-    fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-    # Active all the wanted trace events.
Harald Hoyer 308914
-    echo "$(get_want_events)" > $trace_base/tracing/set_event
Harald Hoyer 308914
-
Harald Hoyer 308914
-    # There are three kinds of known applications for module loading:
Harald Hoyer 308914
-    # "systemd-udevd", "modprobe" and "insmod".
Harald Hoyer 308914
-    # Set them as the global events filter.
Harald Hoyer 308914
-    # NOTE: Some kernel may not support this format of filter, anyway
Harald Hoyer 308914
-    #       the operation will fail and it doesn't matter.
Harald Hoyer 308914
-    echo "$(get_event_filter)" > $trace_base/tracing/events/kmem/filter 2>&1
Harald Hoyer 308914
-    echo "$(get_event_filter)" > $trace_base/tracing/events/module/filter 2>&1
Harald Hoyer 308914
-
Harald Hoyer 308914
-    # Set the number of comm-pid if supported.
Harald Hoyer 308914
-    if [ -f "$trace_base/tracing/saved_cmdlines_size" ]; then
Harald Hoyer 308914
-        # Thanks to filters, 4096 is big enough(also well supported).
Harald Hoyer 308914
-        echo 4096 > $trace_base/tracing/saved_cmdlines_size
Harald Hoyer 308914
-    fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-    # Enable and clear trace data for the first time.
Harald Hoyer 308914
-    echo 1 > $trace_base/tracing/tracing_on
Harald Hoyer 308914
-    echo > $trace_base/tracing/trace
Harald Hoyer 308914
-    echo "Prepare trace success."
Harald Hoyer 308914
-    return 0
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-order_to_pages()
Harald Hoyer 308914
-{
Harald Hoyer 308914
-    local pages=1
Harald Hoyer 308914
-    local order=$1
Harald Hoyer 308914
-
Harald Hoyer 308914
-    while [ "$order" != 0 ]; do
Harald Hoyer 308914
-        order=$((order-1))
Harald Hoyer 308914
-        pages=$(($pages*2))
Harald Hoyer 308914
-	done
Harald Hoyer 308914
-
Harald Hoyer 308914
-    echo $pages
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-parse_trace_data() {
Harald Hoyer 308914
-    local module_name tmp_eval pages
Harald Hoyer 308914
-
Harald Hoyer 308914
-    cat "$(get_trace_base)/tracing/trace" | while read pid cpu flags ts function args
Harald Hoyer 308914
-    do
Harald Hoyer 308914
-        # Skip comment lines
Harald Hoyer 308914
-        if [ "$pid" = "#" ]; then
Harald Hoyer 308914
-            continue
Harald Hoyer 308914
-        fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-        pid=${pid##*-}
Harald Hoyer 308914
-        function=${function%:}
Harald Hoyer 308914
-        if [ "$function" = "module_load" ]; then
Harald Hoyer 308914
-            # One module is being loaded, save the task pid for tracking.
Harald Hoyer 308914
-            # Remove the trailing after whitespace, there may be the module flags.
Harald Hoyer 308914
-            module_name=${args%% *}
Harald Hoyer 308914
-            # Mark current_module to track the task.
Harald Hoyer 308914
-            eval current_module_$pid="$module_name"
Harald Hoyer 308914
-            tmp_eval=$(eval echo '${module_loaded_'${module_name}'}')
Harald Hoyer 308914
-            if [ -n "$tmp_eval" ]; then
Harald Hoyer 308914
-                echo "WARN: \"$module_name\" was loaded multiple times!"
Harald Hoyer 308914
-            fi
Harald Hoyer 308914
-            eval unset module_loaded_$module_name
Harald Hoyer 308914
-            eval nr_alloc_pages_$module_name=0
Harald Hoyer 308914
-            continue
Harald Hoyer 308914
-        fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-        module_name=$(eval echo '${current_module_'${pid}'}')
Harald Hoyer 308914
-        if [ -z "$module_name" ]; then
Harald Hoyer 308914
-            continue
Harald Hoyer 308914
-        fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-        # Once we get here, the task is being tracked(is loading a module).
Harald Hoyer 308914
-        if [ "$function" = "module_put" ]; then
Harald Hoyer 308914
-            # Mark the module as loaded when the first module_put event happens after module_load.
Harald Hoyer 308914
-            tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
Harald Hoyer 308914
-            echo "$tmp_eval pages consumed by \"$module_name\""
Harald Hoyer 308914
-            eval module_loaded_$module_name=1
Harald Hoyer 308914
-            # Module loading finished, so untrack the task.
Harald Hoyer 308914
-            eval unset current_module_$pid
Harald Hoyer 308914
-            eval unset nr_alloc_pages_$module_name
Harald Hoyer 308914
-            continue
Harald Hoyer 308914
-        fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-        if [ "$function" = "mm_page_alloc" ]; then
Harald Hoyer 308914
-            # Get order first, then convert to actual pages.
Harald Hoyer 308914
-            pages=$(echo $args | sed -e 's/.*order=\([0-9]*\) .*/\1/')
Harald Hoyer 308914
-            pages=$(order_to_pages "$pages")
Harald Hoyer 308914
-            tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
Harald Hoyer 308914
-            eval nr_alloc_pages_$module_name="$(($tmp_eval+$pages))"
Harald Hoyer 308914
-        fi
Harald Hoyer 308914
-    done
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-cleanup_trace() {
Harald Hoyer 308914
-    local trace_base
Harald Hoyer 308914
-
Harald Hoyer 308914
-    if is_trace_ready; then
Harald Hoyer 308914
-        trace_base=$(get_trace_base)
Harald Hoyer 308914
-        echo 0 > $trace_base/tracing/tracing_on
Harald Hoyer 308914
-        echo > $trace_base/tracing/trace
Harald Hoyer 308914
-        echo > $trace_base/tracing/set_event
Harald Hoyer 308914
-        echo 0 > $trace_base/tracing/events/kmem/filter
Harald Hoyer 308914
-        echo 0 > $trace_base/tracing/events/module/filter
Harald Hoyer 308914
-    fi
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-show_usage() {
Harald Hoyer 308914
-    echo "Find out kernel modules with large memory consumption during loading based on trace."
Harald Hoyer 308914
-    echo "Usage:"
Harald Hoyer 308914
-    echo "1) run it first to setup trace."
Harald Hoyer 308914
-    echo "2) run again to parse the trace data if any."
Harald Hoyer 308914
-    echo "3) run with \"--cleanup\" option to cleanup trace after use."
Harald Hoyer 308914
-}
Harald Hoyer 308914
-
Harald Hoyer 308914
-if [ "$1" = "--help" ]; then
Harald Hoyer 308914
-    show_usage
Harald Hoyer 308914
-    exit 0
Harald Hoyer 308914
-fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-if [ "$1" = "--cleanup" ]; then
Harald Hoyer 308914
-    cleanup_trace
Harald Hoyer 308914
-    exit 0
Harald Hoyer 308914
-fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-if is_trace_ready ; then
Harald Hoyer 308914
-    echo "tracekomem - Rough memory consumption by loading kernel modules (larger value with better accuracy)"
Harald Hoyer 308914
-    parse_trace_data
Harald Hoyer 308914
-else
Harald Hoyer 308914
-    prepare_trace
Harald Hoyer 308914
-fi
Harald Hoyer 308914
-
Harald Hoyer 308914
-exit $?
Harald Hoyer 308914
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
Harald Hoyer 308914
index 3a2246b4..c9e3ebcb 100755
Harald Hoyer 308914
--- a/modules.d/99base/module-setup.sh
Harald Hoyer 308914
+++ b/modules.d/99base/module-setup.sh
Harald Hoyer 308914
@@ -39,7 +39,6 @@ install() {
Harald Hoyer 308914
     inst_script "$moddir/initqueue.sh" "/sbin/initqueue"
Harald Hoyer 308914
     inst_script "$moddir/loginit.sh" "/sbin/loginit"
Harald Hoyer 308914
     inst_script "$moddir/rdsosreport.sh" "/sbin/rdsosreport"
Harald Hoyer 308914
-    inst_script "$moddir/memtrace-ko.sh" "/sbin/tracekomem"
Harald Hoyer 308914
 
Harald Hoyer 308914
     [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
Harald Hoyer 308914
     mkdir -m 0755 -p ${initdir}/lib/dracut
Harald Hoyer 308914