From patchwork Wed Feb 5 17:03:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11366643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0A4492A for ; Wed, 5 Feb 2020 17:04:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 89D1E21927 for ; Wed, 5 Feb 2020 17:04:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="brNPJ8bc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89D1E21927 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 922716B0005; Wed, 5 Feb 2020 12:04:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8F9236B0006; Wed, 5 Feb 2020 12:04:41 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8105B6B0007; Wed, 5 Feb 2020 12:04:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6A38C6B0005 for ; Wed, 5 Feb 2020 12:04:41 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E5E1610FC5 for ; Wed, 5 Feb 2020 17:04:40 +0000 (UTC) X-FDA: 76456697520.01.shop80_221d4df4b3e3b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 2BCDF18033D23 for ; Wed, 5 Feb 2020 17:03:55 +0000 (UTC) X-Spam-Summary: 2,0,0,92cc069a4f105ba1,d41d8cd98f00b204,laoar.shao@gmail.com,:tj@kernel.org:vdavydov.dev@gmail.com:hannes@cmpxchg.org:mhocko@kernel.org:akpm@linux-foundation.org:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com:cgroups@vger.kernel.org::laoar.shao@gmail.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1500:1535:1542:1711:1730:1747:1777:1792:1801:2393:2559:2562:2693:2902:2915:3138:3139:3140:3141:3142:3353:3865:3866:3867:3870:3871:3872:3874:4321:4605:5007:6261:6653:7514:7903:7904:9413:10004:11026:11473:11658:11914:12043:12294:12296:12297:12438:12517:12519:12555:12679:12895:14181:14394:14687:14721:21080:21444:21451:21627:21666:21939:21972:21990:30012:30029:30054:30070,0,RBL:209.85.210.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: shop80_221d4df4b3e3b X-Filterd-Recvd-Size: 5592 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Wed, 5 Feb 2020 17:03:54 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id y5so1502561pfb.11 for ; Wed, 05 Feb 2020 09:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BpKT67FLDttHow1r3K4wuKV8cB597M2lQmxM3PivZvk=; b=brNPJ8bc7c6wFuqJgrS1FFBkILkxYNu0YhqjEyJ1g6cXJT7J7RE1XxdExWiWTzVNQ2 O16cxlFkBHFKZAdktZey/jmg6fFkZ393oJzaucgu9b8RGTBsTVlIHogCWnIw61Sg2yGu OdKiBSAx+cx2fGz9i5Lny5MWk+HwwyxwAicOtQ27Jf3PVoy21aOiJPxGG7qvtx805Ixi b+m5JOOUL1SI5HIQ5rhWj5JDMJXGEoTwcU7gSB5RKAmN6y09v+pYZtUyqmjzgI2NnutI eAadYYs8sScqxUHq1dOfRz6EMyFO8F/qMMatvhbXRCInJZcGuKBfleOiEc0lCCzbgcsJ /G3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BpKT67FLDttHow1r3K4wuKV8cB597M2lQmxM3PivZvk=; b=QMjZgGjySCOa6A92c9XV2cIAT24BmKnAqx4zC8C3Ek6XqpFwOoXpZEX4EmSMKG1cUH FzU4ikNPHASWA5vCVJPvjqBNP9mfPN2xCrsZ7BtMP05e85i+ETYuhoqJCm8tAn5/sCtR kc3SwfffUnX9HBwc5coCwpckZBhFoA4uG1mJEcSn802OxLiY2UfQafvfuI6RVMFI/rnn wy/kqbLxrJ4e47jVAWoJreed/B6wtWaffuBjNHZTtIeYbaY+Q8zLVK+TTdDG8oE2HBji FJ2EeEpw2ubddAmZ6u+K4JP7y27cDvYxbw5sxbB5sAFsh7cBXU8eeLS1o9pjx+MaN8ML v03A== X-Gm-Message-State: APjAAAU4y1G56iLjs1VurIUCnMY+0wlpuiCDH4JldL8+PviEhNCKQKVf srutpO/5tjvdm1/+aJ4QLTw= X-Google-Smtp-Source: APXvYqxn6FeaB04gqdT1mPp5BP8n4x4iJSO9O3ISmNzIV2riJ/yQZ+OASfMH90A2V1+KNeE4TTkVuA== X-Received: by 2002:a63:d658:: with SMTP id d24mr23059303pgj.73.1580922233345; Wed, 05 Feb 2020 09:03:53 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id i3sm51209pfg.94.2020.02.05.09.03.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2020 09:03:51 -0800 (PST) From: Yafang Shao To: tj@kernel.org, vdavydov.dev@gmail.com Cc: hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, cgroups@vger.kernel.org, linux-mm@kvack.org, Yafang Shao Subject: [PATCH] mm, memcg: fix build error around the usage of kmem_caches Date: Wed, 5 Feb 2020 12:03:35 -0500 Message-Id: <1580922215-5272-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: When I manually set default n to MEMCG_KMEM in init/Kconfig, bellow error occurs, mm/slab_common.c: In function 'memcg_slab_start': mm/slab_common.c:1530:30: error: 'struct mem_cgroup' has no member named 'kmem_caches' return seq_list_start(&memcg->kmem_caches, *pos); ^ mm/slab_common.c: In function 'memcg_slab_next': mm/slab_common.c:1537:32: error: 'struct mem_cgroup' has no member named 'kmem_caches' return seq_list_next(p, &memcg->kmem_caches, pos); ^ mm/slab_common.c: In function 'memcg_slab_show': mm/slab_common.c:1551:16: error: 'struct mem_cgroup' has no member named 'kmem_caches' if (p == memcg->kmem_caches.next) ^ CC arch/x86/xen/smp.o mm/slab_common.c: In function 'memcg_slab_start': mm/slab_common.c:1531:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ mm/slab_common.c: In function 'memcg_slab_next': mm/slab_common.c:1538:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ That's because kmem_caches is defined only when CONFIG_MEMCG_KMEM is set, while memcg_slab_start() will use it no matter CONFIG_MEMCG_KMEM is defined or not. By the way, the reason I mannuly undefined CONFIG_MEMCG_KMEM is to verify whether my some other code change is still stable when CONFIG_MEMCG_KMEM is not set. Unfortunately, the existing code has been already unstable since v4.11. Fixes: bc2791f857e1 ("slab: link memcg kmem_caches on their associated memory cgroup") Cc: Tejun Heo Cc: Vladimir Davydov Signed-off-by: Yafang Shao --- mm/memcontrol.c | 2 ++ mm/slab_common.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6f6dc8712e39..43f0125b45bb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4723,6 +4723,7 @@ static struct cftype mem_cgroup_legacy_files[] = { .write = mem_cgroup_reset, .read_u64 = mem_cgroup_read_u64, }, +#ifdef CONFIG_MEMCG_KMEM #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG) { .name = "kmem.slabinfo", @@ -4731,6 +4732,7 @@ static struct cftype mem_cgroup_legacy_files[] = { .seq_stop = memcg_slab_stop, .seq_show = memcg_slab_show, }, +#endif #endif { .name = "kmem.tcp.limit_in_bytes", diff --git a/mm/slab_common.c b/mm/slab_common.c index 1907cb2903c7..5282f881d2f5 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1521,7 +1521,7 @@ void dump_unreclaimable_slab(void) mutex_unlock(&slab_mutex); } -#if defined(CONFIG_MEMCG) +#if defined(CONFIG_MEMCG_KMEM) void *memcg_slab_start(struct seq_file *m, loff_t *pos) { struct mem_cgroup *memcg = mem_cgroup_from_seq(m);