From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AECCEC432C1 for ; Tue, 24 Sep 2019 14:36:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C92D214AF for ; Tue, 24 Sep 2019 14:36:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C92D214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 176496B0005; Tue, 24 Sep 2019 10:36:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 125A76B0007; Tue, 24 Sep 2019 10:36:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03AAA6B000E; Tue, 24 Sep 2019 10:36:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id D76F16B0005 for ; Tue, 24 Sep 2019 10:36:02 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 6C585181AC9B6 for ; Tue, 24 Sep 2019 14:36:02 +0000 (UTC) X-FDA: 75970063764.06.doll82_6ee336ec51e57 X-HE-Tag: doll82_6ee336ec51e57 X-Filterd-Recvd-Size: 3784 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Sep 2019 14:36:01 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BF31EAD35; Tue, 24 Sep 2019 14:36:00 +0000 (UTC) Date: Tue, 24 Sep 2019 16:36:00 +0200 From: Michal Hocko To: Mircea CIRJALIU - MELIU Cc: "linux-mm@kvack.org" , "cl@linux.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] slab, memcontrol: undefined reference to `memcg_kmem_get_cache' Message-ID: <20190924143600.GY23050@dhcp22.suse.cz> References: <20190924120400.GN23050@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 > Date: Tue Jul 26 15:24:21 2016 -0700 > Although I had the same problem before with other header files. > -- Michal Hocko SUSE Labs