Skip to content

Commit

Permalink
kmemleak: don't hang if user disables scanning early
Browse files Browse the repository at this point in the history
If the user tries to disable automatic scanning early in the boot
process using e.g.:

  echo scan=off > /sys/kernel/debug/kmemleak

then this command will hang until SECS_FIRST_SCAN (= 60) seconds have
elapsed, even though the system is fully initialised.

We can fix this using interruptible sleep and checking if we're supposed
to stop whenever we wake up (like the rest of the code does).

Link: http://lkml.kernel.org/r/1468835005-2873-1-git-send-email-vegard.nossum@oracle.com
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
vegard authored and torvalds committed Jul 28, 2016
1 parent cb0a650 commit 98c42d9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/kmemleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -1485,8 +1485,10 @@ static int kmemleak_scan_thread(void *arg)
* Wait before the first scan to allow the system to fully initialize.
*/
if (first_run) {
signed long timeout = msecs_to_jiffies(SECS_FIRST_SCAN * 1000);
first_run = 0;
ssleep(SECS_FIRST_SCAN);
while (timeout && !kthread_should_stop())
timeout = schedule_timeout_interruptible(timeout);
}

while (!kthread_should_stop()) {
Expand Down

0 comments on commit 98c42d9

Please sign in to comment.