public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: catalin.marinas@arm.com, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, Jim Cromie <jim.cromie@gmail.com>
Subject: [PATCH 1/3] kmemleak: drop (age <increasing>) from leak record
Date: Tue, 25 Apr 2023 16:24:44 -0600	[thread overview]
Message-ID: <20230425222446.170486-2-jim.cromie@gmail.com> (raw)
In-Reply-To: <20230425222446.170486-1-jim.cromie@gmail.com>

Displaying age is pretty, but counter-productive; 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

Further, age is not an intrinsic property of the leak, its an artifact
of when it was scanned, and relative age is embedded in leak order.

While userspace could work around the always-changing output, ISTM
none could be relying upon age in any important way, and having
idempotent output is just better.

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

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index a2d34226e3c8..f025c7bc845b 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");
 
-- 
2.40.0


  reply	other threads:[~2023-04-25 22:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 22:24 [PATCH 0/3] kmemleak report format changes Jim Cromie
2023-04-25 22:24 ` Jim Cromie [this message]
2023-04-25 22:24 ` [PATCH 2/3] kmemleak: add checksum to backtrace report Jim Cromie
2023-04-25 22:24 ` [PATCH 3/3] kmemleak-test: drop __init to get better backtrace Jim Cromie
2023-04-28 17:11   ` Catalin Marinas
2023-04-28 17:25 ` [PATCH 0/3] kmemleak report format changes Catalin Marinas
2023-11-11  0:19   ` jim.cromie
2023-11-16 17:56     ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230425222446.170486-2-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox