From cd6c30daf6d09ae15b24f6149efa40256b38f09f Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Wed, 3 Sep 2025 12:30:44 +0200 Subject: [PATCH] contest: vm: kmemleak: eat, sleep, rave, repeat As recommended by Catalin (and Fatboy Slim???), it seems better to scan, wait for the grace period, scan again, then look for leaks. This should catch most issues, and avoid most of the false positives. Link: https://lore.kernel.org/aLdfOrQ4O4rnD5M9@arm.com Signed-off-by: Matthieu Baerts (NGI0) --- contest/remote/lib/vm.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contest/remote/lib/vm.py b/contest/remote/lib/vm.py index 5ba324f..8e7efbe 100644 --- a/contest/remote/lib/vm.py +++ b/contest/remote/lib/vm.py @@ -405,12 +405,13 @@ def check_health(self): if self.fail_state: return if self.has_kmemleak: + # First scan, to identify possible leaks + self.cmd("echo scan > /sys/kernel/debug/kmemleak") + self.drain_to_prompt() # kmemleak needs objects to be at least MSECS_MIN_AGE (5000) # before it considers them to have been leaked sleep(5) - self.cmd("echo scan > /sys/kernel/debug/kmemleak && cat /sys/kernel/debug/kmemleak") - self.drain_to_prompt() - # Do it twice, kmemleak likes to hide the leak on the first attempt + # Second scan, to identify what has really leaked self.cmd("echo scan > /sys/kernel/debug/kmemleak && cat /sys/kernel/debug/kmemleak") self.drain_to_prompt()