Re: [PATCH v3] cgroup/kmemcheck: Annotate alloc_page() for cgroupallocations

From: Catalin Marinas
Date: Fri Aug 12 2011 - 06:02:47 EST


On Tue, Jul 26, 2011 at 08:19:16PM +0100, Steven Rostedt wrote:
> When the cgroup base was allocated with kmalloc, it was necessary to
> annotate the variable with kmemcheck_not_leak(). But because it has
> recently been changed to be allocated with alloc_page() (which skips
> kmemleak checks) causes a warning on boot up.

Sorry for the delay, too much holiday over here :)

> diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
> index 53bffc6..1eb534a 100644
> --- a/mm/page_cgroup.c
> +++ b/mm/page_cgroup.c
> @@ -133,10 +133,13 @@ struct page *lookup_cgroup_page(struct page_cgroup *pc)
> static void *__meminit alloc_page_cgroup(size_t size, int nid)
> {
> void *addr = NULL;
> + gfp_t flags = GFP_KERNEL | __GFP_NOWARN;
>
> - addr = alloc_pages_exact_nid(nid, size, GFP_KERNEL | __GFP_NOWARN);
> - if (addr)
> + addr = alloc_pages_exact_nid(nid, size, flags);
> + if (addr) {
> + kmemleak_alloc(addr, size, 1, flags);
> return addr;
> + }
>
> if (node_state(nid, N_HIGH_MEMORY))
> addr = vmalloc_node(size, nid);

The __GFP_NOWARN is already added by kmemleak_alloc but there is no harm
in leaving it.

One minor thing with the subject, unless you already submitted the
patch - it's kmemleak rather than kmemcheck (different things,
confusingly).

Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/