diff options
Diffstat (limited to 'mm/kmemleak.c')
-rw-r--r-- | mm/kmemleak.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index f5042b4a7b95..c17dbc76fb72 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
@@ -1421,6 +1421,28 @@ static int dump_str_object_info(const char *str) | |||
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | /* | 1423 | /* |
1424 | * We use grey instead of black to ensure we can do future scans on the same | ||
1425 | * objects. If we did not do future scans these black objects could | ||
1426 | * potentially contain references to newly allocated objects in the future and | ||
1427 | * we'd end up with false positives. | ||
1428 | */ | ||
1429 | static void kmemleak_clear(void) | ||
1430 | { | ||
1431 | struct kmemleak_object *object; | ||
1432 | unsigned long flags; | ||
1433 | |||
1434 | rcu_read_lock(); | ||
1435 | list_for_each_entry_rcu(object, &object_list, object_list) { | ||
1436 | spin_lock_irqsave(&object->lock, flags); | ||
1437 | if ((object->flags & OBJECT_REPORTED) && | ||
1438 | unreferenced_object(object)) | ||
1439 | object->min_count = 0; | ||
1440 | spin_unlock_irqrestore(&object->lock, flags); | ||
1441 | } | ||
1442 | rcu_read_unlock(); | ||
1443 | } | ||
1444 | |||
1445 | /* | ||
1424 | * File write operation to configure kmemleak at run-time. The following | 1446 | * File write operation to configure kmemleak at run-time. The following |
1425 | * commands can be written to the /sys/kernel/debug/kmemleak file: | 1447 | * commands can be written to the /sys/kernel/debug/kmemleak file: |
1426 | * off - disable kmemleak (irreversible) | 1448 | * off - disable kmemleak (irreversible) |
@@ -1431,6 +1453,8 @@ static int dump_str_object_info(const char *str) | |||
1431 | * scan=... - set the automatic memory scanning period in seconds (0 to | 1453 | * scan=... - set the automatic memory scanning period in seconds (0 to |
1432 | * disable it) | 1454 | * disable it) |
1433 | * scan - trigger a memory scan | 1455 | * scan - trigger a memory scan |
1456 | * clear - mark all current reported unreferenced kmemleak objects as | ||
1457 | * grey to ignore printing them | ||
1434 | * dump=... - dump information about the object found at the given address | 1458 | * dump=... - dump information about the object found at the given address |
1435 | */ | 1459 | */ |
1436 | static ssize_t kmemleak_write(struct file *file, const char __user *user_buf, | 1460 | 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, | |||
1472 | } | 1496 | } |
1473 | } else if (strncmp(buf, "scan", 4) == 0) | 1497 | } else if (strncmp(buf, "scan", 4) == 0) |
1474 | kmemleak_scan(); | 1498 | kmemleak_scan(); |
1499 | else if (strncmp(buf, "clear", 5) == 0) | ||
1500 | kmemleak_clear(); | ||
1475 | else if (strncmp(buf, "dump=", 5) == 0) | 1501 | else if (strncmp(buf, "dump=", 5) == 0) |
1476 | ret = dump_str_object_info(buf + 5); | 1502 | ret = dump_str_object_info(buf + 5); |
1477 | else | 1503 | else |