kmemleak: Show the age of an unreferenced object
authorCatalin Marinas <catalin.marinas@arm.com>
Wed, 28 Oct 2009 13:33:12 +0000 (13:33 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 28 Oct 2009 17:07:54 +0000 (17:07 +0000)
The jiffies shown for unreferenced objects isn't always meaningful to
people debugging kernel memory leaks. This patch adds the age as well to
the displayed information.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
mm/kmemleak.c

index f06c0921e4721646669d1bcc5d78574949fb3bfd..ce79d91eeef78c1deb8f244335b07fb98f59df12 100644 (file)
@@ -346,11 +346,13 @@ static void print_unreferenced(struct seq_file *seq,
                               struct kmemleak_object *object)
 {
        int i;
+       unsigned int msecs_age = jiffies_to_msecs(jiffies - object->jiffies);
 
        seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n",
                   object->pointer, object->size);
-       seq_printf(seq, "  comm \"%s\", pid %d, jiffies %lu\n",
-                  object->comm, object->pid, object->jiffies);
+       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);
        hex_dump_object(seq, object);
        seq_printf(seq, "  backtrace:\n");