Whamcloud - gitweb
LU-12341 tests: Add kmemleak awareness to test-framework 59/34959/4
authorOleg Drokin <green@whamcloud.com>
Sun, 26 May 2019 18:53:21 +0000 (14:53 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 4 Jun 2019 05:27:11 +0000 (05:27 +0000)
If active kmemleak is detected, perform a clear operation to
ensure all non-Lustre related leaks are not getting in the way.

When it comes time to unload modules, first perform a scan
and then save the output if it's not empty, print to
syslog (for simplicity).
Also save /proc/modules content for the next step (we can save ogdb
from /tmp, but that seems to be getting stale and needs its own
fixing)

After modules unload perform another scan and if the result is non-empty,
output the saved /proc/modules output and the updated memleaks
into syslog as well

Test-Parameters: trivial
Change-Id: Ibba9047e4d8b98e7ab74aeb0906078549029ad43
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/34959
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
lustre/scripts/lustre_rmmod
lustre/tests/test-framework.sh

index a2dfd0a..53c8ae2 100755 (executable)
@@ -35,8 +35,26 @@ if [ -z "$modules" ] || [ "$modules" = "ldiskfs" ]; then
        modules="ptlrpc lnet_selftest ldiskfs libcfs"
 fi
 
+if [ -f /sys/kernel/debug/kmemleak ] ; then
+       cat /proc/modules >/tmp/kmemleak-modules-list.txt
+       echo scan > /sys/kernel/debug/kmemleak
+       cat /sys/kernel/debug/kmemleak > /tmp/kmemleak-before-unload.txt
+       test -s /tmp/kmemleak-before-unload.txt && logger -t leak-pre -f /tmp/kmemleak-before-unload.txt
+       rm /tmp/kmemleak-before-unload.txt
+       # Clear everything here so that only new leaks show up
+       # after module unload
+       echo clear > /sys/kernel/debug/kmemleak
+fi
+
 for mod in $modules; do
        unload_dep_modules_inclusive $mod || exit 1
 done
 
+if [ -f /sys/kernel/debug/kmemleak ] ; then
+       echo scan > /sys/kernel/debug/kmemleak
+       cat /sys/kernel/debug/kmemleak > /tmp/kmemleak-after-unload.txt
+       test -s /tmp/kmemleak-after-unload.txt && logger -t leak-mods -f /tmp/kmemleak-modules-list.txt && logger -t leak-post -f /tmp/kmemleak-after-unload.txt
+       rm -f /tmp/kmemleak-after-unload.txt /tmp/kmemleak-modules-list.txt
+fi
+
 exit 0
index a0b18eb..5b78d09 100755 (executable)
@@ -639,6 +639,15 @@ load_modules_local() {
        udevadm control --reload-rules
        udevadm trigger
 
+       # For kmemleak-enabled kernels we need clear all past state
+       # that obviously has nothing to do with this Lustre run
+       # Disable automatic memory scanning to avoid perf hit.
+       if [ -f /sys/kernel/debug/kmemleak ] ; then
+               echo scan=off > /sys/kernel/debug/kmemleak
+               echo scan > /sys/kernel/debug/kmemleak
+               echo clear > /sys/kernel/debug/kmemleak
+       fi
+
        echo Loading modules from $LUSTRE
 
        local ncpus