From: Oleg Drokin Date: Sun, 26 May 2019 18:53:21 +0000 (-0400) Subject: LU-12341 tests: Add kmemleak awareness to test-framework X-Git-Tag: 2.12.54~3 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=15c0a21ea9a6e98d642e6d16898e46ba9e9b2fa9 LU-12341 tests: Add kmemleak awareness to test-framework 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 Reviewed-on: https://review.whamcloud.com/34959 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Petros Koutoupis Reviewed-by: James Simmons --- diff --git a/lustre/scripts/lustre_rmmod b/lustre/scripts/lustre_rmmod index a2dfd0a..53c8ae2 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -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 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index a0b18eb..5b78d09 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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