From 2ac6eb449f04acdb567198cc11238b825d020772 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Thu, 27 Aug 2009 14:29:15 +0100 Subject: [PATCH] --- yaml --- r: 157411 b: refs/heads/master c: 189d84ed54bbb05aac5b24d9d784d86c4d37f807 h: refs/heads/master i: 157409: 1f7f93e0604f5d2ff41681cf32ea808fa8a65c8d 157407: 264d8e78cba2fec20327150db6a02d6520cfacd7 v: v3 --- [refs] | 2 +- trunk/Documentation/kmemleak.txt | 1 + trunk/mm/kmemleak.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 2d0417773c04..5e0f4772df0b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: af98603dad87e393d2fc57117fe8a2aa6d620a0c +refs/heads/master: 189d84ed54bbb05aac5b24d9d784d86c4d37f807 diff --git a/trunk/Documentation/kmemleak.txt b/trunk/Documentation/kmemleak.txt index 89068030b01b..c223785339b5 100644 --- a/trunk/Documentation/kmemleak.txt +++ b/trunk/Documentation/kmemleak.txt @@ -42,6 +42,7 @@ Memory scanning parameters can be modified at run-time by writing to the scan= - set the automatic memory scanning period in seconds (default 600, 0 to stop the automatic scanning) scan - trigger a memory scan + dump= - dump information about the object found at Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on the kernel command line. diff --git a/trunk/mm/kmemleak.c b/trunk/mm/kmemleak.c index 6debe0d80e64..c977f7a2f0e4 100644 --- a/trunk/mm/kmemleak.c +++ b/trunk/mm/kmemleak.c @@ -331,6 +331,7 @@ static void dump_object_info(struct kmemleak_object *object) object->comm, object->pid, object->jiffies); pr_notice(" min_count = %d\n", object->min_count); pr_notice(" count = %d\n", object->count); + pr_notice(" flags = 0x%lx\n", object->flags); pr_notice(" backtrace:\n"); print_stack_trace(&trace, 4); } @@ -1307,6 +1308,27 @@ static int kmemleak_release(struct inode *inode, struct file *file) return seq_release(inode, file); } +static int dump_str_object_info(const char *str) +{ + unsigned long flags; + struct kmemleak_object *object; + unsigned long addr; + + addr= simple_strtoul(str, NULL, 0); + object = find_and_get_object(addr, 0); + if (!object) { + pr_info("Unknown object at 0x%08lx\n", addr); + return -EINVAL; + } + + spin_lock_irqsave(&object->lock, flags); + dump_object_info(object); + spin_unlock_irqrestore(&object->lock, flags); + + put_object(object); + return 0; +} + /* * File write operation to configure kmemleak at run-time. The following * commands can be written to the /sys/kernel/debug/kmemleak file: @@ -1318,6 +1340,7 @@ static int kmemleak_release(struct inode *inode, struct file *file) * scan=... - set the automatic memory scanning period in seconds (0 to * disable it) * scan - trigger a memory scan + * dump=... - dump information about the object found at the given address */ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf, size_t size, loff_t *ppos) @@ -1358,6 +1381,8 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf, } } else if (strncmp(buf, "scan", 4) == 0) kmemleak_scan(); + else if (strncmp(buf, "dump=", 5) == 0) + ret = dump_str_object_info(buf + 5); else ret = -EINVAL;