[1/2] kmemleak: drop (age <increasing>) from leak record

Message ID 20231116224318.124209-2-jim.cromie@gmail.com
State New
Headers
Series tweak kmemleak report format |

Commit Message

Jim Cromie Nov. 16, 2023, 10:43 p.m. UTC
  Displaying age is pretty, but counter-productive; it changes with
current-time, so it surrenders idempotency of the output, which breaks
simple hash-based cataloging of the records by the user.

The trouble: sequential reads, wo new leaks, get new results:

  :#> sum /sys/kernel/debug/kmemleak
  53439    74 /sys/kernel/debug/kmemleak
  :#> sum /sys/kernel/debug/kmemleak
  59066    74 /sys/kernel/debug/kmemleak

and age is why (nothing else changes):

  :#> grep -v age /sys/kernel/debug/kmemleak | sum
  58894    67
  :#> grep -v age /sys/kernel/debug/kmemleak | sum
  58894    67

Since jiffies is already printed in the "comm" line, age adds nothing.

Notably, syzkaller reads kmemleak only for "unreferenced object", and
won't care about this reform of age-ism.  A few moribund github repos
mention it, but don't compile.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 mm/kmemleak.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Catalin Marinas Nov. 18, 2023, 5:35 p.m. UTC | #1
On Thu, Nov 16, 2023 at 03:43:17PM -0700, Jim Cromie wrote:
> Displaying age is pretty, but counter-productive; it changes with
> current-time, so it surrenders idempotency of the output, which breaks
> simple hash-based cataloging of the records by the user.
> 
> The trouble: sequential reads, wo new leaks, get new results:
> 
>   :#> sum /sys/kernel/debug/kmemleak
>   53439    74 /sys/kernel/debug/kmemleak
>   :#> sum /sys/kernel/debug/kmemleak
>   59066    74 /sys/kernel/debug/kmemleak
> 
> and age is why (nothing else changes):
> 
>   :#> grep -v age /sys/kernel/debug/kmemleak | sum
>   58894    67
>   :#> grep -v age /sys/kernel/debug/kmemleak | sum
>   58894    67
> 
> Since jiffies is already printed in the "comm" line, age adds nothing.
> 
> Notably, syzkaller reads kmemleak only for "unreferenced object", and
> won't care about this reform of age-ism.  A few moribund github repos
> mention it, but don't compile.
> 
> Signed-off-by: Jim Cromie <jim.cromie@gmail.com>

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

Patch

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 1eacca03bedd..10c9b611c395 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -355,14 +355,12 @@  static void print_unreferenced(struct seq_file *seq,
 	int i;
 	unsigned long *entries;
 	unsigned int nr_entries;
-	unsigned int msecs_age = jiffies_to_msecs(jiffies - object->jiffies);
 
 	nr_entries = stack_depot_fetch(object->trace_handle, &entries);
 	warn_or_seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n",
 			  object->pointer, object->size);
-	warn_or_seq_printf(seq, "  comm \"%s\", pid %d, jiffies %lu (age %d.%03ds)\n",
-			   object->comm, object->pid, object->jiffies,
-			   msecs_age / 1000, msecs_age % 1000);
+	warn_or_seq_printf(seq, "  comm \"%s\", pid %d, jiffies %lu\n",
+			   object->comm, object->pid, object->jiffies);
 	hex_dump_object(seq, object);
 	warn_or_seq_printf(seq, "  backtrace:\n");