linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Mircea CIRJALIU - MELIU <mcirjaliu@bitdefender.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"cl@linux.com" <cl@linux.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache'
Date: Tue, 24 Sep 2019 16:36:00 +0200	[thread overview]
Message-ID: <20190924143600.GY23050@dhcp22.suse.cz> (raw)
In-Reply-To: <DB7PR02MB39799BF26E394AE30D710308BB840@DB7PR02MB3979.eurprd02.prod.outlook.com>

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


      reply	other threads:[~2019-09-24 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24  8:46 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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190924143600.GY23050@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mcirjaliu@bitdefender.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox