Re: [PATCH -mmotm] mm: fix kmemcheck.c build errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 05, 2014 at 01:01:02PM -0700, Andrew Morton wrote:
> On Fri,  5 Sep 2014 16:28:06 +0900 Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> wrote:
> 
> > mm-slab_common-move-kmem_cache-definition-to-internal-header.patch
> > in mmotm makes following build failure.
> > 
> > ../mm/kmemcheck.c:70:7: error: dereferencing pointer to incomplete type
> > ../mm/kmemcheck.c:83:15: error: dereferencing pointer to incomplete type
> > ../mm/kmemcheck.c:95:8: error: dereferencing pointer to incomplete type
> > ../mm/kmemcheck.c:95:21: error: dereferencing pointer to incomplete type
> > 
> > ../mm/slab.h: In function 'cache_from_obj':
> > ../mm/slab.h:283:2: error: implicit declaration of function
> > 'memcg_kmem_enabled' [-Werror=implicit-function-declaration]
> > 
> > Add header files to fix kmemcheck.c build errors.
> > 
> > [iamjoonsoo.kim@xxxxxxx] move up memcontrol.h header
> > to fix build failure if CONFIG_MEMCG_KMEM=y too.
> 
> Looking at this line
> 
> > Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> 
> and at this line
> 
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
> 
> I am suspecting that this patch was authored by Randy.  But there was
> no From: line at start-of-changelog to communicate this?
> 
> > diff --git a/mm/slab.h b/mm/slab.h
> > index 13845d0..963a3f8 100644
> > --- a/mm/slab.h
> > +++ b/mm/slab.h
> > @@ -37,6 +37,8 @@ struct kmem_cache {
> >  #include <linux/slub_def.h>
> >  #endif
> >  
> > +#include <linux/memcontrol.h>
> > +
> >  /*
> >   * State of the slab allocator.
> >   *
> 
> It seems a bit wrong to include a fairly high-level memcontol.h into a
> fairly low-level slab.h, but I expect it will work.
> 
> I can't really see how
> mm-slab_common-move-kmem_cache-definition-to-internal-header.patch
> caused the breakage.  I don't know how you were triggering this build
> failure - please always include such info in the changelogs.

Hello,

Sorry for all mistakes.
Here goes new one having proper commit description and authorship.

------------>8------------------
>From d2026b2cf932ae459fb421a66923288352993e74 Mon Sep 17 00:00:00 2001
From: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Date: Fri, 5 Sep 2014 16:18:13 +0900
Subject: [PATCH] mm/slab: fix kmemcheck.c build errors

If we turn on CONFIG_KMEMCHECK,
mm-slab_common-move-kmem_cache-definition-to-internal-header.patch
in mmotm makes following build failure.

../mm/kmemcheck.c:70:7: error: dereferencing pointer to incomplete type
../mm/kmemcheck.c:83:15: error: dereferencing pointer to incomplete type
../mm/kmemcheck.c:95:8: error: dereferencing pointer to incomplete type
../mm/kmemcheck.c:95:21: error: dereferencing pointer to incomplete type

Reason for this failure is that kmemcheck uses internal fields of struct
kmem_cache and above patch moves these struct kmem_cache definitions to
mm/slab.h, so kmemcheck which only includes include/linux/slab.h can't
dereference them.

Add header file mm/slab.h in kmemcheck.c to fix kmemcheck.c build errors.

There is one more problem revealing from this change.
mm/slab.h uses memcg's internal fields so it needs memcontrol.h. Util now,
only sl[aou]b use mm/slab.h header, and they luckilly include memcontrol.h
through swap.h so no problems happen. Unfortunately, kmemcheck doesn't
include memcontrol.h so problem happens if we add mm/slab.h in kmemcheck.c.
To fix it too, add memcontrol.h into mm/slab.h.

[iamjoonsoo.kim@xxxxxxx] add commit description and move up memcontrol.h
header to fix build failure if CONFIG_MEMCG_KMEM=y too.
Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
---
 mm/kmemcheck.c |    1 +
 mm/slab.h      |    2 ++
 2 files changed, 3 insertions(+)

diff --git a/mm/kmemcheck.c b/mm/kmemcheck.c
index fd814fd..cab58bb 100644
--- a/mm/kmemcheck.c
+++ b/mm/kmemcheck.c
@@ -2,6 +2,7 @@
 #include <linux/mm_types.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include "slab.h"
 #include <linux/kmemcheck.h>
 
 void kmemcheck_alloc_shadow(struct page *page, int order, gfp_t flags, int node)
diff --git a/mm/slab.h b/mm/slab.h
index 13845d0..963a3f8 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -37,6 +37,8 @@ struct kmem_cache {
 #include <linux/slub_def.h>
 #endif
 
+#include <linux/memcontrol.h>
+
 /*
  * State of the slab allocator.
  *
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-next" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux