Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1445343 > unrolled thread

[PATCH] kmemleak: don't hang if user disables scanning early

Started byVegard Nossum <vegard.nossum@oracle.com>
First post2016-07-18 11:50 +0200
Last post2016-07-22 14:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] kmemleak: don't hang if user disables scanning early Vegard Nossum <vegard.nossum@oracle.com> - 2016-07-18 11:50 +0200
    Re: [PATCH] kmemleak: don't hang if user disables scanning early Catalin Marinas <catalin.marinas@arm.com> - 2016-07-22 14:50 +0200

#1445343 — [PATCH] kmemleak: don't hang if user disables scanning early

FromVegard Nossum <vegard.nossum@oracle.com>
Date2016-07-18 11:50 +0200
Subject[PATCH] kmemleak: don't hang if user disables scanning early
Message-ID<rWdlw-4u2-19@gated-at.bofh.it>
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).

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
---
 mm/kmemleak.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 04320d3..086292f 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -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()) {
-- 
1.9.1

[toc] | [next] | [standalone]


#1448563

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-07-22 14:50 +0200
Message-ID<rXI3U-5Un-23@gated-at.bofh.it>
In reply to#1445343
On Mon, Jul 18, 2016 at 11:43:25AM +0200, Vegard Nossum wrote:
> 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).
> 
> Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web