common/rc: fix check for disabled kmemleak
authorAmir Goldstein <amir73il@gmail.com>
Sat, 22 Sep 2018 15:23:39 +0000 (18:23 +0300)
committerEryu Guan <guaneryu@gmail.com>
Sun, 23 Sep 2018 14:26:56 +0000 (22:26 +0800)
With kernel commit b353756b2b71 ("kmemleak: always register debugfs
file") that was merged to v4.19-rc3, the kmemleak debugfs knob
exists even if kmemleak is disabled, but returns EBUSY on write.

Suppress EBUSY errors in tests by disabling _check_kmemleak() calls
if the write to kmemleak knob failed on _init_kmemleak().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc

index ec631ad9035ee9d6cc6e486cd1d25b7185dceb9f..d5bb1feee2c3f83093f7eec3540b4466a8c5b502 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3508,14 +3508,23 @@ _init_kmemleak()
 {
        local kern_knob="${DEBUGFS_MNT}/kmemleak"
 
+       # Since kernel v4.19-rc3, the kmemleak knob exists even if kmemleak is
+       # disabled, but returns EBUSY on write. So instead of relying on
+       # existance of writable knob file, we use a test file to indicate that
+       # _check_kmemleak() is enabled only if we actually managed to write to
+       # the knob file.
+       rm -f ${RESULT_BASE}/check_kmemleak
+
        if [ ! -w "$kern_knob" ]; then
                return 0
        fi
 
        # Disable the automatic scan so that we can control it completely,
        # then dump all the leaks recorded so far.
-       echo "scan=off" > "$kern_knob"
-       _capture_kmemleak /dev/null
+       if echo "scan=off" > "$kern_knob" 2>/dev/null; then
+               _capture_kmemleak /dev/null
+               touch ${RESULT_BASE}/check_kmemleak
+       fi
 }
 
 # check kmemleak log
@@ -3524,7 +3533,7 @@ _check_kmemleak()
        local kern_knob="${DEBUGFS_MNT}/kmemleak"
        local leak_file="${seqres}.kmemleak"
 
-       if [ ! -w "$kern_knob" ]; then
+       if [ ! -f ${RESULT_BASE}/check_kmemleak ]; then
                return 0
        fi