From patchwork Thu Feb 6 06:24:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11367677 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 D8A301398 for ; Thu, 6 Feb 2020 06:24:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5C1F20838 for ; Thu, 6 Feb 2020 06:24:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S6UT1M/B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5C1F20838 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 EE1936B0010; Thu, 6 Feb 2020 01:24:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E914A6B0032; Thu, 6 Feb 2020 01:24:46 -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 D803F6B0036; Thu, 6 Feb 2020 01:24:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id BF2E66B0010 for ; Thu, 6 Feb 2020 01:24:46 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 768D4181AEF15 for ; Thu, 6 Feb 2020 06:24:46 +0000 (UTC) X-FDA: 76458713772.02.lunch18_299db48beee27 X-Spam-Summary: 2,0,0,a9933d8c11927e6e,d41d8cd98f00b204,laoar.shao@gmail.com,:david@redhat.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: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.215.196:@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:23,LUA_SUMMARY:none X-HE-Tag: lunch18_299db48beee27 X-Filterd-Recvd-Size: 5515 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Feb 2020 06:24:45 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id z7so2211008pgk.7 for ; Wed, 05 Feb 2020 22:24:45 -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=/1bdNiZJIydaWvbrtyH2cphn9JXElXk4UNnoRdYAoVM=; b=S6UT1M/BpxTAsLy7VAYYrV0XE+HCnpjf5/tIb0M/BJzc81azLQsQPDULX4l0jBQ+x+ knwojt+ABNutej6LLsdLCsKPksWVNt2QlTOXd6+WbqV9WIVBSIFD7y431wcnyqsAfJMx 9AodrNAaKaHcGtFzrH5aix931reqqGQ1AWMObD+kF23tdZ9kGKmaI4mtRdHo6wtyxFj5 ueUJh4NEMVWAyRS3+o9fmYyrTda2YfgThtZZrOPbEGrWxUPLbgH7W2MyivYCaa6TG7g3 9u21VuOWj88Qb6P54JNHEtviAFqUaydn47sxv8sOdFEr1bUdBU1MVv2aJQhPIx1MJFkB FRfA== 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=/1bdNiZJIydaWvbrtyH2cphn9JXElXk4UNnoRdYAoVM=; b=VF5E//isrRI4zE22M2C1m14GlcdR6/lF+x8ls4cuLwATqY/UouRQCeeS5c/UylSQhi SljojitbQZaXM88NgZ8biizs12oGyQ1au1YBe0r+HVImrWqLbDOxAG/Ck0Xw0TX8Elif ImFQ7o1wsriDEXGDW1hSHT8VCEzK9XzC4KRbNI56g3HYRouIBPxkL1xbyZzCxLQCusbu iwLy8nBrqZjIKq41wOIPLq6gMxjf1iZDxkVrG3nw6OgjI/M1+P5qPhNk0myHb0GERFxC nCzUhCjlcbdAl5Enfld647h3FmBJexZQmLjbQGNtkBA45VOYQFfGZm88nonzsVQWq911 X6GQ== X-Gm-Message-State: APjAAAWYrS3ZYdbDbY8zba7YAxJ9IktW1hatGkf//MRDo5IdLkHVJYhR ZewxQrgzUL89w4oV01FmIXM= X-Google-Smtp-Source: APXvYqwIakWMoDr+aJ+5xLAxwuk0XHTwsxRnX3XgoW2voWoUAyyMSlo5Ll/Q/fokLjEGKMb+jxXcLg== X-Received: by 2002:a63:2782:: with SMTP id n124mr1940907pgn.188.1580970284570; Wed, 05 Feb 2020 22:24:44 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id i68sm1644186pfe.173.2020.02.05.22.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2020 22:24:43 -0800 (PST) From: Yafang Shao To: david@redhat.com, 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 v2] mm, memcg: fix build error around the usage of kmem_caches Date: Thu, 6 Feb 2020 01:24:20 -0500 Message-Id: <1580970260-2045-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 | 3 ++- mm/slab_common.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6f6dc8712e39..a94b1a737bc0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4723,7 +4723,8 @@ static struct cftype mem_cgroup_legacy_files[] = { .write = mem_cgroup_reset, .read_u64 = mem_cgroup_read_u64, }, -#if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG) +#if defined(CONFIG_MEMCG_KMEM) && \ + (defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG)) { .name = "kmem.slabinfo", .seq_start = memcg_slab_start, 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);