* Re: [PATCH] mm/z3fold: silence kmemleak false positives of slots
[not found] <20200522220052.2225-1-cai@lca.pw>
@ 2020-05-26 9:11 ` Catalin Marinas
0 siblings, 0 replies; only message in thread
From: Catalin Marinas @ 2020-05-26 9:11 UTC (permalink / raw)
To: Qian Cai; +Cc: akpm, vitaly.wool, linux-mm, linux-kernel
On Fri, May 22, 2020 at 06:00:52PM -0400, Qian Cai wrote:
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 8c3bb5e508b8..460b0feced26 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -43,6 +43,7 @@
> #include <linux/spinlock.h>
> #include <linux/zpool.h>
> #include <linux/magic.h>
> +#include <linux/kmemleak.h>
>
> /*
> * NCHUNKS_ORDER determines the internal allocation granularity, effectively
> @@ -215,6 +216,8 @@ static inline struct z3fold_buddy_slots *alloc_slots(struct z3fold_pool *pool,
> (gfp & ~(__GFP_HIGHMEM | __GFP_MOVABLE)));
>
> if (slots) {
> + /* It will be freed separately in free_handle(). */
> + kmemleak_not_leak(slots);
> memset(slots->slot, 0, sizeof(slots->slot));
> slots->pool = (unsigned long)pool;
> rwlock_init(&slots->lock);
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
An alternative would have been a kmemleak_alloc(zhdr, sizeof(*zhdr), 1)
in init_z3fold_page() and a corresponding kmemleak_free() in
free_z3fold_page() (if !headless) since kmemleak doesn't track page
allocations. The advantage is that it would track the slots in case
there is a leak. But if the code is clear enough that the slots are
freed, just keep the kmemleak_not_leak() annotation.
--
Catalin
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-26 9:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20200522220052.2225-1-cai@lca.pw>
2020-05-26 9:11 ` [PATCH] mm/z3fold: silence kmemleak false positives of slots Catalin Marinas
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).