summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@Atheros.com>2009-09-04 17:44:51 -0700
committerCatalin Marinas <catalin.marinas@arm.com>2009-09-08 16:36:08 +0100
commit30b3710105be0ba6bbdb7d7d126af76246b02eba (patch)
tree84200b02f8230f3706744512bf4ba68341d9b889 /mm
parent4a558dd6f93d419cd318958577e25492bd09e960 (diff)
downloadop-kernel-dev-30b3710105be0ba6bbdb7d7d126af76246b02eba.zip
op-kernel-dev-30b3710105be0ba6bbdb7d7d126af76246b02eba.tar.gz
kmemleak: add clear command support
In an ideal world your kmemleak output will be small, when its not (usually during initial bootup) you can use the clear command to ingore previously reported and unreferenced kmemleak objects. We do this by painting all currently reported unreferenced objects grey. We paint them grey instead of black to allow future scans on the same objects as such objects could still potentially reference newly allocated objects in the future. To test a critical section on demand with a clean /sys/kernel/debug/kmemleak you can do: echo clear > /sys/kernel/debug/kmemleak test your kernel or modules echo scan > /sys/kernel/debug/kmemleak Then as usual to get your report with: cat /sys/kernel/debug/kmemleak Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/kmemleak.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index f5042b4..c17dbc7 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1421,6 +1421,28 @@ static int dump_str_object_info(const char *str)
}
/*
+ * We use grey instead of black to ensure we can do future scans on the same
+ * objects. If we did not do future scans these black objects could
+ * potentially contain references to newly allocated objects in the future and
+ * we'd end up with false positives.
+ */
+static void kmemleak_clear(void)
+{
+ struct kmemleak_object *object;
+ unsigned long flags;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(object, &object_list, object_list) {
+ spin_lock_irqsave(&object->lock, flags);
+ if ((object->flags & OBJECT_REPORTED) &&
+ unreferenced_object(object))
+ object->min_count = 0;
+ spin_unlock_irqrestore(&object->lock, flags);
+ }
+ rcu_read_unlock();
+}
+
+/*
* File write operation to configure kmemleak at run-time. The following
* commands can be written to the /sys/kernel/debug/kmemleak file:
* off - disable kmemleak (irreversible)
@@ -1431,6 +1453,8 @@ static int dump_str_object_info(const char *str)
* scan=... - set the automatic memory scanning period in seconds (0 to
* disable it)
* scan - trigger a memory scan
+ * clear - mark all current reported unreferenced kmemleak objects as
+ * grey to ignore printing them
* dump=... - dump information about the object found at the given address
*/
static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
@@ -1472,6 +1496,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, "clear", 5) == 0)
+ kmemleak_clear();
else if (strncmp(buf, "dump=", 5) == 0)
ret = dump_str_object_info(buf + 5);
else
OpenPOWER on IntegriCloud