* [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache'
@ 2019-09-24 8:46 Mircea CIRJALIU - MELIU
2019-09-24 12:04 ` Michal Hocko
0 siblings, 1 reply; 4+ messages in thread
From: Mircea CIRJALIU - MELIU @ 2019-09-24 8:46 UTC (permalink / raw)
To: linux-mm, cl; +Cc: linux-kernel
Having CONFIG_MEMCG turned off causes these issues:
mm/slub.o: In function `slab_pre_alloc_hook':
/home/mircea/build/mm/slab.h:425: undefined reference to `memcg_kmem_get_cache'
mm/slub.o: In function `slab_post_alloc_hook':
/home/mircea/build/mm/slab.h:444: undefined reference to `memcg_kmem_put_cache'
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 1dcb763..61a1391 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1265,10 +1265,10 @@ static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
}
#endif
+#ifdef CONFIG_MEMCG_KMEM
struct kmem_cache *memcg_kmem_get_cache(struct kmem_cache *cachep);
void memcg_kmem_put_cache(struct kmem_cache *cachep);
-#ifdef CONFIG_MEMCG_KMEM
int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order);
void __memcg_kmem_uncharge(struct page *page, int order);
int __memcg_kmem_charge_memcg(struct page *page, gfp_t gfp, int order,
@@ -1329,6 +1329,14 @@ extern int memcg_expand_shrinker_maps(int new_id);
extern void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
int nid, int shrinker_id);
#else
+static inline struct kmem_cache *memcg_kmem_get_cache(struct kmem_cache *cachep)
+{
+ return cachep;
+}
+
+static inline void memcg_kmem_put_cache(struct kmem_cache *cachep)
+{
+}
static inline int memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
{
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache'
2019-09-24 8:46 [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache' Mircea CIRJALIU - MELIU
@ 2019-09-24 12:04 ` Michal Hocko
2019-09-24 14:08 ` Mircea CIRJALIU - MELIU
0 siblings, 1 reply; 4+ messages in thread
From: Michal Hocko @ 2019-09-24 12:04 UTC (permalink / raw)
To: Mircea CIRJALIU - MELIU; +Cc: linux-mm, cl, linux-kernel
On Tue 24-09-19 08:46:48, Mircea CIRJALIU - MELIU wrote:
> Having CONFIG_MEMCG turned off causes these issues:
> mm/slub.o: In function `slab_pre_alloc_hook':
> /home/mircea/build/mm/slab.h:425: undefined reference to `memcg_kmem_get_cache'
> mm/slub.o: In function `slab_post_alloc_hook':
> /home/mircea/build/mm/slab.h:444: undefined reference to `memcg_kmem_put_cache'
You should be adding your Sign-off-by to every patch you post to the
kernel mailing list (see Documentation/SubmittingPatches).
It is also really important to mention which tree does this apply to and
ideally also note which change has broken the code. In this particular
case I have tried the current Linus tree (4c07e2ddab5b) and
$ grep 'CONFIG_SLUB\|CONFIG_MEMCG' .config
# CONFIG_MEMCG is not set
CONFIG_SLUB_DEBUG=y
CONFIG_SLUB=y
CONFIG_SLUB_CPU_PARTIAL=y
# CONFIG_SLUB_DEBUG_ON is not set
# CONFIG_SLUB_STATS is not set
which means CONFIG_MEMCG_KMEM is not enabled as well. And the
compilation succeeds. What is your config file?
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache'
2019-09-24 12:04 ` Michal Hocko
@ 2019-09-24 14:08 ` Mircea CIRJALIU - MELIU
2019-09-24 14:36 ` Michal Hocko
0 siblings, 1 reply; 4+ messages in thread
From: Mircea CIRJALIU - MELIU @ 2019-09-24 14:08 UTC (permalink / raw)
To: Michal Hocko; +Cc: linux-mm, cl, linux-kernel
> On Tue 24-09-19 08:46:48, Mircea CIRJALIU - MELIU wrote:
> > Having CONFIG_MEMCG turned off causes these issues:
> > mm/slub.o: In function `slab_pre_alloc_hook':
> > /home/mircea/build/mm/slab.h:425: undefined reference to
> `memcg_kmem_get_cache'
> > mm/slub.o: In function `slab_post_alloc_hook':
> > /home/mircea/build/mm/slab.h:444: undefined reference to
> `memcg_kmem_put_cache'
>
> You should be adding your Sign-off-by to every patch you post to the kernel
> mailing list (see Documentation/SubmittingPatches).
>
> It is also really important to mention which tree does this apply to and ideally
> also note which change has broken the code. In this particular case I have
> tried the current Linus tree (4c07e2ddab5b) and $ grep
> 'CONFIG_SLUB\|CONFIG_MEMCG' .config # CONFIG_MEMCG is not set
> CONFIG_SLUB_DEBUG=y CONFIG_SLUB=y CONFIG_SLUB_CPU_PARTIAL=y
> # CONFIG_SLUB_DEBUG_ON is not set # CONFIG_SLUB_STATS is not set
>
> which means CONFIG_MEMCG_KMEM is not enabled as well. And the
> compilation succeeds. What is your config file?
The config file is not the problem (figured it out).
I am lowering the optimization level on certain files for debug purposes.
In my case: CFLAGS_slub.o += -O1 -fno-inline
The code which causes the problem looks like this:
static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s,
gfp_t flags)
{
...
if (memcg_kmem_enabled() &&
((flags & __GFP_ACCOUNT) || (s->flags & SLAB_ACCOUNT)))
return memcg_kmem_get_cache(s);
...
}
Under normal circumstances memcg_kmem_enabled() returns false and the
statement is evaluated as unreachable and removed entirely.
It seems -O1 keeps the call to memcg_kmem_get_cache().
The change that introduced this is here:
commit 452647784b2fccfdeeb976f6f842c6719fb2daac
Author: Vladimir Davydov <vdavydov@virtuozzo.com>
Date: Tue Jul 26 15:24:21 2016 -0700
Although I had the same problem before with other header files.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache'
2019-09-24 14:08 ` Mircea CIRJALIU - MELIU
@ 2019-09-24 14:36 ` Michal Hocko
0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2019-09-24 14:36 UTC (permalink / raw)
To: Mircea CIRJALIU - MELIU; +Cc: linux-mm, cl, linux-kernel
On Tue 24-09-19 14:08:33, Mircea CIRJALIU - MELIU wrote:
> > On Tue 24-09-19 08:46:48, Mircea CIRJALIU - MELIU wrote:
> > > Having CONFIG_MEMCG turned off causes these issues:
> > > mm/slub.o: In function `slab_pre_alloc_hook':
> > > /home/mircea/build/mm/slab.h:425: undefined reference to
> > `memcg_kmem_get_cache'
> > > mm/slub.o: In function `slab_post_alloc_hook':
> > > /home/mircea/build/mm/slab.h:444: undefined reference to
> > `memcg_kmem_put_cache'
> >
> > You should be adding your Sign-off-by to every patch you post to the kernel
> > mailing list (see Documentation/SubmittingPatches).
> >
> > It is also really important to mention which tree does this apply to and ideally
> > also note which change has broken the code. In this particular case I have
> > tried the current Linus tree (4c07e2ddab5b) and $ grep
> > 'CONFIG_SLUB\|CONFIG_MEMCG' .config # CONFIG_MEMCG is not set
> > CONFIG_SLUB_DEBUG=y CONFIG_SLUB=y CONFIG_SLUB_CPU_PARTIAL=y
> > # CONFIG_SLUB_DEBUG_ON is not set # CONFIG_SLUB_STATS is not set
> >
> > which means CONFIG_MEMCG_KMEM is not enabled as well. And the
> > compilation succeeds. What is your config file?
>
> The config file is not the problem (figured it out).
> I am lowering the optimization level on certain files for debug purposes.
> In my case: CFLAGS_slub.o += -O1 -fno-inline
>
> The code which causes the problem looks like this:
> static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s,
> gfp_t flags)
> {
> ...
>
> if (memcg_kmem_enabled() &&
> ((flags & __GFP_ACCOUNT) || (s->flags & SLAB_ACCOUNT)))
> return memcg_kmem_get_cache(s);
>
> ...
> }
>
> Under normal circumstances memcg_kmem_enabled() returns false and the
> statement is evaluated as unreachable and removed entirely.
> It seems -O1 keeps the call to memcg_kmem_get_cache().
OK, this makes more sense now. Is it the only problem to make your
kernel compile with O1? We do rely on dead code elimination quite
heavily. I do not think we want add a lot of code for something that we
are unlikely to be able to support. This particular patch is quite small
but I am not really supper happy to add more boilerplate code...
> The change that introduced this is here:
> commit 452647784b2fccfdeeb976f6f842c6719fb2daac
> Author: Vladimir Davydov <vdavydov@virtuozzo.com>
> Date: Tue Jul 26 15:24:21 2016 -0700
> Although I had the same problem before with other header files.
>
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-24 14:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 8:46 [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache' Mircea CIRJALIU - MELIU
2019-09-24 12:04 ` Michal Hocko
2019-09-24 14:08 ` Mircea CIRJALIU - MELIU
2019-09-24 14:36 ` Michal Hocko
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).