All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak
@ 2018-08-13 13:19 Christophe Leroy
  2018-10-04  6:14 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2018-08-13 13:19 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

When a process allocates a hugepage, the following leak is
reported by kmemleak. This is a false positive which is
due to the pointer to the table being stored in the PGD
as physical memory address and not virtual memory pointer.

unreferenced object 0xc30f8200 (size 512):
  comm "mmap", pid 374, jiffies 4872494 (age 627.630s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<e32b68da>] huge_pte_alloc+0xdc/0x1f8
    [<9e0df1e1>] hugetlb_fault+0x560/0x8f8
    [<7938ec6c>] follow_hugetlb_page+0x14c/0x44c
    [<afbdb405>] __get_user_pages+0x1c4/0x3dc
    [<b8fd7cd9>] __mm_populate+0xac/0x140
    [<3215421e>] vm_mmap_pgoff+0xb4/0xb8
    [<c148db69>] ksys_mmap_pgoff+0xcc/0x1fc
    [<4fcd760f>] ret_from_syscall+0x0/0x38

See commit a984506c542e2 ("powerpc/mm: Don't report PUDs as
memory leaks when using kmemleak") for detailed explanation.

To fix that, this patch tells kmemleak to ignore the allocated
hugepage table.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/mm/hugetlbpage.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index e87f9ef9115b..7296a42eb62e 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -19,6 +19,7 @@
 #include <linux/moduleparam.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
+#include <linux/kmemleak.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
@@ -112,6 +113,8 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
 		for (i = i - 1 ; i >= 0; i--, hpdp--)
 			*hpdp = __hugepd(0);
 		kmem_cache_free(cachep, new);
+	} else {
+		kmemleak_ignore(new);
 	}
 	spin_unlock(ptl);
 	return 0;
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak
  2018-08-13 13:19 [PATCH] powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak Christophe Leroy
@ 2018-10-04  6:14 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2018-10-04  6:14 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, linux-kernel

On Mon, 2018-08-13 at 13:19:52 UTC, Christophe Leroy wrote:
> When a process allocates a hugepage, the following leak is
> reported by kmemleak. This is a false positive which is
> due to the pointer to the table being stored in the PGD
> as physical memory address and not virtual memory pointer.
> 
> unreferenced object 0xc30f8200 (size 512):
>   comm "mmap", pid 374, jiffies 4872494 (age 627.630s)
>   hex dump (first 32 bytes):
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace:
>     [<e32b68da>] huge_pte_alloc+0xdc/0x1f8
>     [<9e0df1e1>] hugetlb_fault+0x560/0x8f8
>     [<7938ec6c>] follow_hugetlb_page+0x14c/0x44c
>     [<afbdb405>] __get_user_pages+0x1c4/0x3dc
>     [<b8fd7cd9>] __mm_populate+0xac/0x140
>     [<3215421e>] vm_mmap_pgoff+0xb4/0xb8
>     [<c148db69>] ksys_mmap_pgoff+0xcc/0x1fc
>     [<4fcd760f>] ret_from_syscall+0x0/0x38
> 
> See commit a984506c542e2 ("powerpc/mm: Don't report PUDs as
> memory leaks when using kmemleak") for detailed explanation.
> 
> To fix that, this patch tells kmemleak to ignore the allocated
> hugepage table.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/803d690e68f0c5230183f1a42c7d50

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-04  6:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 13:19 [PATCH] powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak Christophe Leroy
2018-10-04  6:14 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.