All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup/kmemcheck: No need to annotate base anymore
@ 2011-07-26 17:05 Steven Rostedt
  2011-07-26 17:38 ` Michal Hocko
  0 siblings, 1 reply; 16+ messages in thread
From: Steven Rostedt @ 2011-07-26 17:05 UTC (permalink / raw)
  To: LKML
  Cc: Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Randy Dunlap, Andrew Morton,
	Michal Hocko, Dave Hansen

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(), the annotation
is no longer needed.

I was triggering this output:

allocated 8388608 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
kmemleak: Trying to color unknown object at 0xf5840000 as Grey
Pid: 0, comm: swapper Not tainted 3.0.0-test #12
Call Trace:
 [<c17e34e6>] ? printk+0x1d/0x1f^M
 [<c10e2941>] paint_ptr+0x4f/0x78
 [<c178ab57>] kmemleak_not_leak+0x58/0x7d
 [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
 [<c1cdb462>] kmemleak_init+0x19d/0x1e9
 [<c1cbf771>] start_kernel+0x346/0x3ec
 [<c1cbf1b4>] ? loglevel+0x18/0x18
 [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0

After a bit of debugging I tracked the object 0xf840000 (and others)
down to the cgroup code. The change from allocating base with kmalloc to
alloc_page() has the base not calling kmemleak_alloc() which adds the
pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
crt_early_log[] table. On kmemleak_init(), the entry is found in the
early_log[] but not the object_tree_root, and this error message is
displayed.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 53bffc6..955a49f 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -9,7 +9,6 @@
 #include <linux/vmalloc.h>
 #include <linux/cgroup.h>
 #include <linux/swapops.h>
-#include <linux/kmemleak.h>
 
 static void __meminit init_page_cgroup(struct page_cgroup *pc, unsigned long id)
 {
@@ -179,13 +178,6 @@ static int __meminit init_section_page_cgroup(unsigned long pfn, int nid)
 	table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
 	base = alloc_page_cgroup(table_size, nid);
 
-	/*
-	 * The value stored in section->page_cgroup is (base - pfn)
-	 * and it does not point to the memory block allocated above,
-	 * causing kmemleak false positives.
-	 */
-	kmemleak_not_leak(base);
-
 	if (!base) {
 		printk(KERN_ERR "page cgroup allocation failure\n");
 		return -ENOMEM;



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

* Re: [PATCH] cgroup/kmemcheck: No need to annotate base anymore
  2011-07-26 17:05 [PATCH] cgroup/kmemcheck: No need to annotate base anymore Steven Rostedt
@ 2011-07-26 17:38 ` Michal Hocko
  2011-07-26 17:41   ` Steven Rostedt
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Hocko @ 2011-07-26 17:38 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Randy Dunlap, Andrew Morton,
	Dave Hansen

On Tue 26-07-11 13:05:11, 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(), the annotation
> is no longer needed.
> 
> I was triggering this output:
> 
> allocated 8388608 bytes of page_cgroup
> please try 'cgroup_disable=memory' option if you don't want memory cgroups
> kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> Call Trace:
>  [<c17e34e6>] ? printk+0x1d/0x1f^M
>  [<c10e2941>] paint_ptr+0x4f/0x78
>  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
>  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
>  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
>  [<c1cbf771>] start_kernel+0x346/0x3ec
>  [<c1cbf1b4>] ? loglevel+0x18/0x18
>  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
> 
> After a bit of debugging I tracked the object 0xf840000 (and others)
> down to the cgroup code. The change from allocating base with kmalloc to
> alloc_page() has the base not calling kmemleak_alloc() which adds the
> pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> crt_early_log[] table. On kmemleak_init(), the entry is found in the
> early_log[] but not the object_tree_root, and this error message is
> displayed.

We can still fall back to vmalloc allocation (even though it is really
not probable that alloc_pages_exact_nid would fail that early).
Is vmalloc a problem here? (sorry I am not familiar with kmemleak
internals) The original code didn't distinguish kmalloc vs. vmalloc.

> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
> index 53bffc6..955a49f 100644
> --- a/mm/page_cgroup.c
> +++ b/mm/page_cgroup.c
> @@ -9,7 +9,6 @@
>  #include <linux/vmalloc.h>
>  #include <linux/cgroup.h>
>  #include <linux/swapops.h>
> -#include <linux/kmemleak.h>
>  
>  static void __meminit init_page_cgroup(struct page_cgroup *pc, unsigned long id)
>  {
> @@ -179,13 +178,6 @@ static int __meminit init_section_page_cgroup(unsigned long pfn, int nid)
>  	table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
>  	base = alloc_page_cgroup(table_size, nid);
>  
> -	/*
> -	 * The value stored in section->page_cgroup is (base - pfn)
> -	 * and it does not point to the memory block allocated above,
> -	 * causing kmemleak false positives.
> -	 */
> -	kmemleak_not_leak(base);
> -
>  	if (!base) {
>  		printk(KERN_ERR "page cgroup allocation failure\n");
>  		return -ENOMEM;
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

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

* Re: [PATCH] cgroup/kmemcheck: No need to annotate base anymore
  2011-07-26 17:38 ` Michal Hocko
@ 2011-07-26 17:41   ` Steven Rostedt
  2011-07-26 17:44     ` Steven Rostedt
  0 siblings, 1 reply; 16+ messages in thread
From: Steven Rostedt @ 2011-07-26 17:41 UTC (permalink / raw)
  To: Michal Hocko
  Cc: LKML, Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Randy Dunlap, Andrew Morton,
	Dave Hansen, Catalin Marinas

On Tue, 2011-07-26 at 19:38 +0200, Michal Hocko wrote:
> On Tue 26-07-11 13:05:11, 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(), the annotation
> > is no longer needed.
> > 
> > I was triggering this output:
> > 
> > allocated 8388608 bytes of page_cgroup
> > please try 'cgroup_disable=memory' option if you don't want memory cgroups
> > kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> > Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> > Call Trace:
> >  [<c17e34e6>] ? printk+0x1d/0x1f^M
> >  [<c10e2941>] paint_ptr+0x4f/0x78
> >  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
> >  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
> >  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
> >  [<c1cbf771>] start_kernel+0x346/0x3ec
> >  [<c1cbf1b4>] ? loglevel+0x18/0x18
> >  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
> > 
> > After a bit of debugging I tracked the object 0xf840000 (and others)
> > down to the cgroup code. The change from allocating base with kmalloc to
> > alloc_page() has the base not calling kmemleak_alloc() which adds the
> > pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> > crt_early_log[] table. On kmemleak_init(), the entry is found in the
> > early_log[] but not the object_tree_root, and this error message is
> > displayed.
> 
> We can still fall back to vmalloc allocation (even though it is really
> not probable that alloc_pages_exact_nid would fail that early).
> Is vmalloc a problem here? (sorry I am not familiar with kmemleak
> internals) The original code didn't distinguish kmalloc vs. vmalloc.
> 

Good question. I forgot to add the maintainer of kmemleak to the Cc
list. (fixed here).

-- Steve

> > 
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > 
> > diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
> > index 53bffc6..955a49f 100644
> > --- a/mm/page_cgroup.c
> > +++ b/mm/page_cgroup.c
> > @@ -9,7 +9,6 @@
> >  #include <linux/vmalloc.h>
> >  #include <linux/cgroup.h>
> >  #include <linux/swapops.h>
> > -#include <linux/kmemleak.h>
> >  
> >  static void __meminit init_page_cgroup(struct page_cgroup *pc, unsigned long id)
> >  {
> > @@ -179,13 +178,6 @@ static int __meminit init_section_page_cgroup(unsigned long pfn, int nid)
> >  	table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
> >  	base = alloc_page_cgroup(table_size, nid);
> >  
> > -	/*
> > -	 * The value stored in section->page_cgroup is (base - pfn)
> > -	 * and it does not point to the memory block allocated above,
> > -	 * causing kmemleak false positives.
> > -	 */
> > -	kmemleak_not_leak(base);
> > -
> >  	if (!base) {
> >  		printk(KERN_ERR "page cgroup allocation failure\n");
> >  		return -ENOMEM;
> > 
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> 



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

* Re: [PATCH] cgroup/kmemcheck: No need to annotate base anymore
  2011-07-26 17:41   ` Steven Rostedt
@ 2011-07-26 17:44     ` Steven Rostedt
  2011-07-26 18:17       ` [PATCH v2] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations Steven Rostedt
  0 siblings, 1 reply; 16+ messages in thread
From: Steven Rostedt @ 2011-07-26 17:44 UTC (permalink / raw)
  To: Michal Hocko
  Cc: LKML, Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Randy Dunlap, Andrew Morton,
	Dave Hansen, Catalin Marinas

On Tue, 2011-07-26 at 13:41 -0400, Steven Rostedt wrote:

> > We can still fall back to vmalloc allocation (even though it is really
> > not probable that alloc_pages_exact_nid would fail that early).
> > Is vmalloc a problem here? (sorry I am not familiar with kmemleak
> > internals) The original code didn't distinguish kmalloc vs. vmalloc.
> > 
> 
> Good question. I forgot to add the maintainer of kmemleak to the Cc
> list. (fixed here).

Depending on the answer, I suspect that the result will be to keep the
not_leak call, and just add a call directly to kmemleak_alloc() in the
page_alloc() side.

I'll have a patch ready on hand when we find out :)

-- Steve



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

* [PATCH v2] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 17:44     ` Steven Rostedt
@ 2011-07-26 18:17       ` Steven Rostedt
  2011-07-26 18:43         ` Michal Hocko
  0 siblings, 1 reply; 16+ messages in thread
From: Steven Rostedt @ 2011-07-26 18:17 UTC (permalink / raw)
  To: Michal Hocko
  Cc: LKML, Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap

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.

I was triggering this output:

allocated 8388608 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory
cgroups
kmemleak: Trying to color unknown object at 0xf5840000 as Grey
Pid: 0, comm: swapper Not tainted 3.0.0-test #12
Call Trace:
 [<c17e34e6>] ? printk+0x1d/0x1f^M
 [<c10e2941>] paint_ptr+0x4f/0x78
 [<c178ab57>] kmemleak_not_leak+0x58/0x7d
 [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
 [<c1cdb462>] kmemleak_init+0x19d/0x1e9
 [<c1cbf771>] start_kernel+0x346/0x3ec
 [<c1cbf1b4>] ? loglevel+0x18/0x18
 [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0

After a bit of debugging I tracked the object 0xf840000 (and others)
down to the cgroup code. The change from allocating base with kmalloc to
alloc_page() has the base not calling kmemleak_alloc() which adds the
pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
crt_early_log[] table. On kmemleak_init(), the entry is found in the
early_log[] but not the object_tree_root, and this error message is
displayed.

If alloc_page() fails then it defaults back to vmalloc() which still
uses the kmemleak_alloc() which makes us still need the
kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
directly if the alloc_page() succeeds.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 53bffc6..79c0e00 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -135,8 +135,10 @@ static void *__meminit alloc_page_cgroup(size_t size, int nid)
 	void *addr = NULL;
 
 	addr = alloc_pages_exact_nid(nid, size, GFP_KERNEL | __GFP_NOWARN);
-	if (addr)
+	if (addr) {
+		kmemleak_alloc(addr, size, 1, GFP_KERNEL | __GFP_NOWARN);
 		return addr;
+	}
 
 	if (node_state(nid, N_HIGH_MEMORY))
 		addr = vmalloc_node(size, nid);



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

* Re: [PATCH v2] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 18:17       ` [PATCH v2] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations Steven Rostedt
@ 2011-07-26 18:43         ` Michal Hocko
  2011-07-26 19:04           ` Steven Rostedt
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Hocko @ 2011-07-26 18:43 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap

On Tue 26-07-11 14:17:29, 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.
> 
> I was triggering this output:
> 
> allocated 8388608 bytes of page_cgroup
> please try 'cgroup_disable=memory' option if you don't want memory
> cgroups
> kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> Call Trace:
>  [<c17e34e6>] ? printk+0x1d/0x1f^M
>  [<c10e2941>] paint_ptr+0x4f/0x78
>  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
>  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
>  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
>  [<c1cbf771>] start_kernel+0x346/0x3ec
>  [<c1cbf1b4>] ? loglevel+0x18/0x18
>  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
> 
> After a bit of debugging I tracked the object 0xf840000 (and others)
> down to the cgroup code. The change from allocating base with kmalloc to
> alloc_page() has the base not calling kmemleak_alloc() which adds the
> pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> crt_early_log[] table. On kmemleak_init(), the entry is found in the
> early_log[] but not the object_tree_root, and this error message is
> displayed.
> 
> If alloc_page() fails then it defaults back to vmalloc() which still
> uses the kmemleak_alloc() which makes us still need the
> kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
> directly if the alloc_page() succeeds.

OK, so you are making the allocation [kv]malloc like wrt. kmemleak.
I can see that kmalloc_order does the exactly same thing and there are
couple of oders that do it as well so I guess this should be correct.

> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Maybe just a nit. What about making 
gfp_t flags = GFP_KERNEL | __GFP_NOWARN;
and use it at both places?

Anyway feel free to add my:
Reviewed-by: Michal Hocko <mhocko@suse.cz>

> 
> diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
> index 53bffc6..79c0e00 100644
> --- a/mm/page_cgroup.c
> +++ b/mm/page_cgroup.c
> @@ -135,8 +135,10 @@ static void *__meminit alloc_page_cgroup(size_t size, int nid)
>  	void *addr = NULL;
>  
>  	addr = alloc_pages_exact_nid(nid, size, GFP_KERNEL | __GFP_NOWARN);
> -	if (addr)
> +	if (addr) {
> +		kmemleak_alloc(addr, size, 1, GFP_KERNEL | __GFP_NOWARN);
>  		return addr;
> +	}
>  
>  	if (node_state(nid, N_HIGH_MEMORY))
>  		addr = vmalloc_node(size, nid);
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

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

* Re: [PATCH v2] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 18:43         ` Michal Hocko
@ 2011-07-26 19:04           ` Steven Rostedt
  2011-07-26 19:19             ` [PATCH v3] " Steven Rostedt
                               ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Steven Rostedt @ 2011-07-26 19:04 UTC (permalink / raw)
  To: Michal Hocko
  Cc: LKML, Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap

On Tue, 2011-07-26 at 20:43 +0200, Michal Hocko wrote:

> Maybe just a nit. What about making 
> gfp_t flags = GFP_KERNEL | __GFP_NOWARN;
> and use it at both places?

I actually thought about that, but was too lazy to do it ;)


> 
> Anyway feel free to add my:
> Reviewed-by: Michal Hocko <mhocko@suse.cz>
> 

Thanks, I'll send out a v3 with the updates.

-- Steve



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

* [PATCH v3] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 19:04           ` Steven Rostedt
@ 2011-07-26 19:19             ` Steven Rostedt
  2011-07-26 22:13               ` Johannes Weiner
                                 ` (3 more replies)
  2011-07-27  2:10             ` [PATCH v3 RESEND] " Steven Rostedt
       [not found]             ` <1311707088.21143.0.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
  2 siblings, 4 replies; 16+ messages in thread
From: Steven Rostedt @ 2011-07-26 19:19 UTC (permalink / raw)
  To: Michal Hocko
  Cc: LKML, Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap

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.

I was triggering this output:

allocated 8388608 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
kmemleak: Trying to color unknown object at 0xf5840000 as Grey
Pid: 0, comm: swapper Not tainted 3.0.0-test #12
Call Trace:
 [<c17e34e6>] ? printk+0x1d/0x1f^M
 [<c10e2941>] paint_ptr+0x4f/0x78
 [<c178ab57>] kmemleak_not_leak+0x58/0x7d
 [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
 [<c1cdb462>] kmemleak_init+0x19d/0x1e9
 [<c1cbf771>] start_kernel+0x346/0x3ec
 [<c1cbf1b4>] ? loglevel+0x18/0x18
 [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0

After a bit of debugging I tracked the object 0xf840000 (and others)
down to the cgroup code. The change from allocating base with kmalloc to
alloc_page() has the base not calling kmemleak_alloc() which adds the
pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
crt_early_log[] table. On kmemleak_init(), the entry is found in the
early_log[] but not the object_tree_root, and this error message is
displayed.

If alloc_page() fails then it defaults back to vmalloc() which still
uses the kmemleak_alloc() which makes us still need the
kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
directly if the alloc_page() succeeds.

Reviewed-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

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);



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

* Re: [PATCH v3] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 19:19             ` [PATCH v3] " Steven Rostedt
@ 2011-07-26 22:13               ` Johannes Weiner
  2011-07-26 23:03               ` Minchan Kim
                                 ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Johannes Weiner @ 2011-07-26 22:13 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Michal Hocko, LKML, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap

On Tue, Jul 26, 2011 at 03:19:16PM -0400, 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.
> 
> I was triggering this output:
> 
> allocated 8388608 bytes of page_cgroup
> please try 'cgroup_disable=memory' option if you don't want memory cgroups
> kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> Call Trace:
>  [<c17e34e6>] ? printk+0x1d/0x1f^M
>  [<c10e2941>] paint_ptr+0x4f/0x78
>  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
>  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
>  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
>  [<c1cbf771>] start_kernel+0x346/0x3ec
>  [<c1cbf1b4>] ? loglevel+0x18/0x18
>  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
> 
> After a bit of debugging I tracked the object 0xf840000 (and others)
> down to the cgroup code. The change from allocating base with kmalloc to
> alloc_page() has the base not calling kmemleak_alloc() which adds the
> pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> crt_early_log[] table. On kmemleak_init(), the entry is found in the
> early_log[] but not the object_tree_root, and this error message is
> displayed.
> 
> If alloc_page() fails then it defaults back to vmalloc() which still
> uses the kmemleak_alloc() which makes us still need the
> kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
> directly if the alloc_page() succeeds.
> 
> Reviewed-by: Michal Hocko <mhocko@suse.cz>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

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

* Re: [PATCH v3] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 19:19             ` [PATCH v3] " Steven Rostedt
  2011-07-26 22:13               ` Johannes Weiner
@ 2011-07-26 23:03               ` Minchan Kim
  2011-07-27  0:55               ` KAMEZAWA Hiroyuki
  2011-08-12  9:58               ` Catalin Marinas
  3 siblings, 0 replies; 16+ messages in thread
From: Minchan Kim @ 2011-07-26 23:03 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Michal Hocko, LKML, Johannes Weiner, KAMEZAWA Hiroyuki,
	Daisuke Nishimura, Balbir Singh, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap

On Wed, Jul 27, 2011 at 4:19 AM, Steven Rostedt <rostedt@goodmis.org> 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.
>
> I was triggering this output:
>
> allocated 8388608 bytes of page_cgroup
> please try 'cgroup_disable=memory' option if you don't want memory cgroups
> kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> Call Trace:
>  [<c17e34e6>] ? printk+0x1d/0x1f^M
>  [<c10e2941>] paint_ptr+0x4f/0x78
>  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
>  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
>  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
>  [<c1cbf771>] start_kernel+0x346/0x3ec
>  [<c1cbf1b4>] ? loglevel+0x18/0x18
>  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
>
> After a bit of debugging I tracked the object 0xf840000 (and others)
> down to the cgroup code. The change from allocating base with kmalloc to
> alloc_page() has the base not calling kmemleak_alloc() which adds the
> pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> crt_early_log[] table. On kmemleak_init(), the entry is found in the
> early_log[] but not the object_tree_root, and this error message is
> displayed.
>
> If alloc_page() fails then it defaults back to vmalloc() which still
> uses the kmemleak_alloc() which makes us still need the
> kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
> directly if the alloc_page() succeeds.
>
> Reviewed-by: Michal Hocko <mhocko@suse.cz>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>

-- 
Kind regards,
Minchan Kim

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

* Re: [PATCH v3] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 19:19             ` [PATCH v3] " Steven Rostedt
  2011-07-26 22:13               ` Johannes Weiner
  2011-07-26 23:03               ` Minchan Kim
@ 2011-07-27  0:55               ` KAMEZAWA Hiroyuki
  2011-08-12  9:58               ` Catalin Marinas
  3 siblings, 0 replies; 16+ messages in thread
From: KAMEZAWA Hiroyuki @ 2011-07-27  0:55 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Michal Hocko, LKML, Johannes Weiner, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap

On Tue, 26 Jul 2011 15:19:16 -0400
Steven Rostedt <rostedt@goodmis.org> 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.
> 
> I was triggering this output:
> 
> allocated 8388608 bytes of page_cgroup
> please try 'cgroup_disable=memory' option if you don't want memory cgroups
> kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> Call Trace:
>  [<c17e34e6>] ? printk+0x1d/0x1f^M
>  [<c10e2941>] paint_ptr+0x4f/0x78
>  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
>  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
>  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
>  [<c1cbf771>] start_kernel+0x346/0x3ec
>  [<c1cbf1b4>] ? loglevel+0x18/0x18
>  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
> 
> After a bit of debugging I tracked the object 0xf840000 (and others)
> down to the cgroup code. The change from allocating base with kmalloc to
> alloc_page() has the base not calling kmemleak_alloc() which adds the
> pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> crt_early_log[] table. On kmemleak_init(), the entry is found in the
> early_log[] but not the object_tree_root, and this error message is
> displayed.
> 
> If alloc_page() fails then it defaults back to vmalloc() which still
> uses the kmemleak_alloc() which makes us still need the
> kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
> directly if the alloc_page() succeeds.
> 
> Reviewed-by: Michal Hocko <mhocko@suse.cz>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


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

* [PATCH v3 RESEND] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
       [not found]             ` <1311707088.21143.0.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
@ 2011-07-27  2:10               ` Steven Rostedt
  0 siblings, 0 replies; 16+ messages in thread
From: Steven Rostedt @ 2011-07-27  2:10 UTC (permalink / raw)
  To: LKML, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: Catalin Marinas, Daisuke Nishimura, Dave Hansen, Michal Hocko,
	Randy Dunlap, Minchan Kim, Johannes Weiner, Andrew Morton,
	Paul Menage, Balbir Singh

[ Resending with CGROUP maintainers Cc'd this time ]

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.

I was triggering this output:

allocated 8388608 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
kmemleak: Trying to color unknown object at 0xf5840000 as Grey
Pid: 0, comm: swapper Not tainted 3.0.0-test #12
Call Trace:
 [<c17e34e6>] ? printk+0x1d/0x1f^M
 [<c10e2941>] paint_ptr+0x4f/0x78
 [<c178ab57>] kmemleak_not_leak+0x58/0x7d
 [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
 [<c1cdb462>] kmemleak_init+0x19d/0x1e9
 [<c1cbf771>] start_kernel+0x346/0x3ec
 [<c1cbf1b4>] ? loglevel+0x18/0x18
 [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0

After a bit of debugging I tracked the object 0xf840000 (and others)
down to the cgroup code. The change from allocating base with kmalloc to
alloc_page() has the base not calling kmemleak_alloc() which adds the
pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
crt_early_log[] table. On kmemleak_init(), the entry is found in the
early_log[] but not the object_tree_root, and this error message is
displayed.

If alloc_page() fails then it defaults back to vmalloc() which still
uses the kmemleak_alloc() which makes us still need the
kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
directly if the alloc_page() succeeds.

Reviewed-by: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>
Reviewed-by: Minchan Kim <minchan.kim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
Signed-off-by: Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>

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);

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

* [PATCH v3 RESEND] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 19:04           ` Steven Rostedt
  2011-07-26 19:19             ` [PATCH v3] " Steven Rostedt
@ 2011-07-27  2:10             ` Steven Rostedt
       [not found]               ` <1311732644.21143.5.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
  2011-07-29 13:31               ` Steven Rostedt
       [not found]             ` <1311707088.21143.0.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
  2 siblings, 2 replies; 16+ messages in thread
From: Steven Rostedt @ 2011-07-27  2:10 UTC (permalink / raw)
  To: LKML, containers
  Cc: Johannes Weiner, KAMEZAWA Hiroyuki, Daisuke Nishimura,
	Balbir Singh, Minchan Kim, Andrew Morton, Dave Hansen,
	Catalin Marinas, Randy Dunlap, Michal Hocko, Paul Menage,
	LiZefan

[ Resending with CGROUP maintainers Cc'd this time ]

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.

I was triggering this output:

allocated 8388608 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
kmemleak: Trying to color unknown object at 0xf5840000 as Grey
Pid: 0, comm: swapper Not tainted 3.0.0-test #12
Call Trace:
 [<c17e34e6>] ? printk+0x1d/0x1f^M
 [<c10e2941>] paint_ptr+0x4f/0x78
 [<c178ab57>] kmemleak_not_leak+0x58/0x7d
 [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
 [<c1cdb462>] kmemleak_init+0x19d/0x1e9
 [<c1cbf771>] start_kernel+0x346/0x3ec
 [<c1cbf1b4>] ? loglevel+0x18/0x18
 [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0

After a bit of debugging I tracked the object 0xf840000 (and others)
down to the cgroup code. The change from allocating base with kmalloc to
alloc_page() has the base not calling kmemleak_alloc() which adds the
pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
crt_early_log[] table. On kmemleak_init(), the entry is found in the
early_log[] but not the object_tree_root, and this error message is
displayed.

If alloc_page() fails then it defaults back to vmalloc() which still
uses the kmemleak_alloc() which makes us still need the
kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
directly if the alloc_page() succeeds.

Reviewed-by: Michal Hocko <mhocko@suse.cz>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

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);




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

* Re: [PATCH v3 RESEND] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
       [not found]               ` <1311732644.21143.5.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
@ 2011-07-29 13:31                 ` Steven Rostedt
  0 siblings, 0 replies; 16+ messages in thread
From: Steven Rostedt @ 2011-07-29 13:31 UTC (permalink / raw)
  To: LKML
  Cc: Catalin Marinas,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Daisuke Nishimura, Dave Hansen, Michal Hocko, Randy Dunlap,
	Minchan Kim, Johannes Weiner, Andrew Morton, Paul Menage,
	Balbir Singh

Andrew,

On Tue, 2011-07-26 at 22:10 -0400, Steven Rostedt wrote:
> [ Resending with CGROUP maintainers Cc'd this time ]

Paul sent me a note saying that these patches usually go through -mm,
want to take them?

Thanks,

-- Steve

> 
> 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.
> 
> I was triggering this output:
> 
> allocated 8388608 bytes of page_cgroup
> please try 'cgroup_disable=memory' option if you don't want memory cgroups
> kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> Call Trace:
>  [<c17e34e6>] ? printk+0x1d/0x1f^M
>  [<c10e2941>] paint_ptr+0x4f/0x78
>  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
>  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
>  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
>  [<c1cbf771>] start_kernel+0x346/0x3ec
>  [<c1cbf1b4>] ? loglevel+0x18/0x18
>  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
> 
> After a bit of debugging I tracked the object 0xf840000 (and others)
> down to the cgroup code. The change from allocating base with kmalloc to
> alloc_page() has the base not calling kmemleak_alloc() which adds the
> pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> crt_early_log[] table. On kmemleak_init(), the entry is found in the
> early_log[] but not the object_tree_root, and this error message is
> displayed.
> 
> If alloc_page() fails then it defaults back to vmalloc() which still
> uses the kmemleak_alloc() which makes us still need the
> kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
> directly if the alloc_page() succeeds.
> 
> Reviewed-by: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>
> Reviewed-by: Minchan Kim <minchan.kim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Acked-by: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
> Signed-off-by: Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>
> 
> 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);
> 
> 

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

* Re: [PATCH v3 RESEND] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-27  2:10             ` [PATCH v3 RESEND] " Steven Rostedt
       [not found]               ` <1311732644.21143.5.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
@ 2011-07-29 13:31               ` Steven Rostedt
  1 sibling, 0 replies; 16+ messages in thread
From: Steven Rostedt @ 2011-07-29 13:31 UTC (permalink / raw)
  To: LKML
  Cc: containers, Johannes Weiner, KAMEZAWA Hiroyuki,
	Daisuke Nishimura, Balbir Singh, Minchan Kim, Andrew Morton,
	Dave Hansen, Catalin Marinas, Randy Dunlap, Michal Hocko,
	Paul Menage, LiZefan

Andrew,

On Tue, 2011-07-26 at 22:10 -0400, Steven Rostedt wrote:
> [ Resending with CGROUP maintainers Cc'd this time ]

Paul sent me a note saying that these patches usually go through -mm,
want to take them?

Thanks,

-- Steve

> 
> 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.
> 
> I was triggering this output:
> 
> allocated 8388608 bytes of page_cgroup
> please try 'cgroup_disable=memory' option if you don't want memory cgroups
> kmemleak: Trying to color unknown object at 0xf5840000 as Grey
> Pid: 0, comm: swapper Not tainted 3.0.0-test #12
> Call Trace:
>  [<c17e34e6>] ? printk+0x1d/0x1f^M
>  [<c10e2941>] paint_ptr+0x4f/0x78
>  [<c178ab57>] kmemleak_not_leak+0x58/0x7d
>  [<c108ae9f>] ? __rcu_read_unlock+0x9/0x7d
>  [<c1cdb462>] kmemleak_init+0x19d/0x1e9
>  [<c1cbf771>] start_kernel+0x346/0x3ec
>  [<c1cbf1b4>] ? loglevel+0x18/0x18
>  [<c1cbf0aa>] i386_start_kernel+0xaa/0xb0
> 
> After a bit of debugging I tracked the object 0xf840000 (and others)
> down to the cgroup code. The change from allocating base with kmalloc to
> alloc_page() has the base not calling kmemleak_alloc() which adds the
> pointer to the object_tree_root, but kmemleak_not_leak() adds it to the
> crt_early_log[] table. On kmemleak_init(), the entry is found in the
> early_log[] but not the object_tree_root, and this error message is
> displayed.
> 
> If alloc_page() fails then it defaults back to vmalloc() which still
> uses the kmemleak_alloc() which makes us still need the
> kmemleak_not_leak() call. The solution is to call the kmemleak_alloc()
> directly if the alloc_page() succeeds.
> 
> Reviewed-by: Michal Hocko <mhocko@suse.cz>
> Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> 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);
> 
> 



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

* Re: [PATCH v3] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations
  2011-07-26 19:19             ` [PATCH v3] " Steven Rostedt
                                 ` (2 preceding siblings ...)
  2011-07-27  0:55               ` KAMEZAWA Hiroyuki
@ 2011-08-12  9:58               ` Catalin Marinas
  3 siblings, 0 replies; 16+ messages in thread
From: Catalin Marinas @ 2011-08-12  9:58 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Michal Hocko, LKML, Johannes Weiner, KAMEZAWA Hiroyuki,
	Daisuke Nishimura, Balbir Singh, Minchan Kim, Andrew Morton,
	Dave Hansen, Randy Dunlap

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@arm.com>

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

end of thread, other threads:[~2011-08-12 10:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26 17:05 [PATCH] cgroup/kmemcheck: No need to annotate base anymore Steven Rostedt
2011-07-26 17:38 ` Michal Hocko
2011-07-26 17:41   ` Steven Rostedt
2011-07-26 17:44     ` Steven Rostedt
2011-07-26 18:17       ` [PATCH v2] cgroup/kmemcheck: Annotate alloc_page() for cgroup allocations Steven Rostedt
2011-07-26 18:43         ` Michal Hocko
2011-07-26 19:04           ` Steven Rostedt
2011-07-26 19:19             ` [PATCH v3] " Steven Rostedt
2011-07-26 22:13               ` Johannes Weiner
2011-07-26 23:03               ` Minchan Kim
2011-07-27  0:55               ` KAMEZAWA Hiroyuki
2011-08-12  9:58               ` Catalin Marinas
2011-07-27  2:10             ` [PATCH v3 RESEND] " Steven Rostedt
     [not found]               ` <1311732644.21143.5.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
2011-07-29 13:31                 ` Steven Rostedt
2011-07-29 13:31               ` Steven Rostedt
     [not found]             ` <1311707088.21143.0.camel-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
2011-07-27  2:10               ` Steven Rostedt

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.