From: Catalin Marinas <catalin.marinas@arm.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 5/6] mm: Call kmemleak directly from memblock_(alloc|free)
Date: Fri, 2 May 2014 14:41:09 +0100 [thread overview]
Message-ID: <1399038070-1540-6-git-send-email-catalin.marinas@arm.com> (raw)
In-Reply-To: <1399038070-1540-1-git-send-email-catalin.marinas@arm.com>
Kmemleak could ignore memory blocks allocated via memblock_alloc()
leading to false positives during scanning. This patch adds the
corresponding callbacks and removes kmemleak_free_* calls in
mm/nobootmem.c to avoid duplication. The kmemleak_alloc() in
mm/nobootmem.c is kept since __alloc_memory_core_early() does not use
memblock_alloc() directly.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
mm/memblock.c | 9 ++++++++-
mm/nobootmem.c | 2 --
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/mm/memblock.c b/mm/memblock.c
index e9d6ca9a01a9..8813a31d7fbd 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -681,6 +681,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
(unsigned long long)base + size - 1,
(void *)_RET_IP_);
+ kmemleak_free_part(__va(base), size);
return __memblock_remove(&memblock.reserved, base, size);
}
@@ -985,8 +986,14 @@ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size,
align = SMP_CACHE_BYTES;
found = memblock_find_in_range_node(size, align, 0, max_addr, nid);
- if (found && !memblock_reserve(found, size))
+ if (found && !memblock_reserve(found, size)) {
+ /*
+ * The min_count is set to 0 so that memblock allocations are
+ * never reported as leaks.
+ */
+ kmemleak_alloc(__va(found), size, 0, 0);
return found;
+ }
return 0;
}
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 04a9d94333a5..7ed58602e71b 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -197,7 +197,6 @@ unsigned long __init free_all_bootmem(void)
void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
unsigned long size)
{
- kmemleak_free_part(__va(physaddr), size);
memblock_free(physaddr, size);
}
@@ -212,7 +211,6 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
*/
void __init free_bootmem(unsigned long addr, unsigned long size)
{
- kmemleak_free_part(__va(addr), size);
memblock_free(addr, size);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-05-02 13:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-02 13:41 [PATCH 0/6] Kmemleak updates Catalin Marinas
2014-05-02 13:41 ` [PATCH 1/6] mm/kmemleak.c: Use %u to print ->checksum Catalin Marinas
2014-05-02 13:41 ` [PATCH 2/6] mm: Introduce kmemleak_update_trace() Catalin Marinas
2014-05-02 13:41 ` [PATCH 3/6] lib: Update the kmemleak stack trace for radix tree allocations Catalin Marinas
2014-05-02 13:48 ` Johannes Weiner
2014-05-02 13:41 ` [PATCH 4/6] mm: Update the kmemleak stack trace for mempool allocations Catalin Marinas
2014-05-02 13:41 ` Catalin Marinas [this message]
2014-05-02 13:41 ` [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging Catalin Marinas
2014-05-06 15:20 ` Sasha Levin
2014-05-06 17:05 ` Catalin Marinas
2014-05-06 18:15 ` Sasha Levin
2014-05-06 21:52 ` Catalin Marinas
2014-05-06 23:08 ` Sasha Levin
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=1399038070-1540-6-git-send-email-catalin.marinas@arm.com \
--to=catalin.marinas@arm.com \
--cc=akpm@linux-foundation.org \
--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;
as well as URLs for NNTP newsgroup(s).