From patchwork Tue Mar 9 10:07:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12124593 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 5D154C433E6 for ; Tue, 9 Mar 2021 10:09:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0A29365257 for ; Tue, 9 Mar 2021 10:09:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A29365257 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A03188D00D9; Tue, 9 Mar 2021 05:09:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D9A48D007F; Tue, 9 Mar 2021 05:09:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87ACF8D00D9; Tue, 9 Mar 2021 05:09:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 6D0698D007F for ; Tue, 9 Mar 2021 05:09:12 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 31B741DF6 for ; Tue, 9 Mar 2021 10:09:12 +0000 (UTC) X-FDA: 77899912944.06.9015344 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf20.hostedemail.com (Postfix) with ESMTP id 82A3DD6 for ; Tue, 9 Mar 2021 10:09:08 +0000 (UTC) Received: by mail-pl1-f169.google.com with SMTP id ba1so6336630plb.1 for ; Tue, 09 Mar 2021 02:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qTJbj+bHGwrcKPZVFV0B4s52LD4dHzSLrz0c48QpEbw=; b=RQ7Divm2aZh0WH7Jb+9JI+tZWXNMnj7ERXR0m2p0ZrH5HGUbl95JJHc5qrbLDMX88A U1c1JYkCCQkCAcHgQG3HP3EqJnZhZKEatO2LtpGTlRepR0TdBd2cpbyXDJ6KHne88CZq yA7lzE50UMOg0cmwYEjiYQywg/3kAb5JSTGNQv+qrpF4o/VL+nZ+gJzkYNO3A9o8jcdW 3it+YVkUr/vMIAD9xZx3/LSTlT7CcKfxWnD4L9TAQP2F5JHBIBA8trYPiaAiWpBdtrvh a06q0VnUXD1JkJ2Q1Cx65wokztExnw8cmvMWi/iPc0OGAWNgSzFhFYIHyxUBalvhHrJu 4W4Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=qTJbj+bHGwrcKPZVFV0B4s52LD4dHzSLrz0c48QpEbw=; b=Fa1egyHkG6Qyfsi6Q0MKR3q3BKNq6wYw8gX9bVi6JEYgegE14DxGCLwtvPdfuT6v0h j3Im535CC7XZa73y4plfLeLGcp8mFonfmb3bgdxpnOwZ7ss8Qu7/4TFTb9/Vet5nyHwi MewhduTETYWP7/L8Z3A9SSxcbPYAorOK/NNCvyYDR9B+TYoLxX8W+cbME72TjH3lQTn4 bjjPnjbLYVbyKocvtpbpFKig9NylvWgu0LBcaHmQxhmmVmrcFOmeEXeI12VJUD1HsJ8Q AcTHXNt3ENB5G2TdbG5OmbpN7+/W+EGJ4tvIg+ep9+yz9e7HGMzzWfornivcG2P2Iuak vgtg== X-Gm-Message-State: AOAM532C/cHGGvKjuL68AFCq1FFXa7vn41kr+MiKKQ6T0PF1AQvkwrQ4 Aqn02Sv2TnRZYXTi1iJsWpCM/w== X-Google-Smtp-Source: ABdhPJyWchdqh/CYZ41KxFNRdvzk6t/duAn74ceMdAR046SE1ztNLZF+5rYZjR2B0CD2D+CIelI8cg== X-Received: by 2002:a17:902:9691:b029:e3:dd4b:f6bb with SMTP id n17-20020a1709029691b02900e3dd4bf6bbmr3130697plp.77.1615284550974; Tue, 09 Mar 2021 02:09:10 -0800 (PST) Received: from localhost.localdomain ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id a70sm9258424pfa.202.2021.03.09.02.09.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Mar 2021 02:09:10 -0800 (PST) From: Muchun Song To: guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, shakeelb@google.com, vdavydov.dev@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH v3 4/4] mm: memcontrol: move PageMemcgKmem to the scope of CONFIG_MEMCG_KMEM Date: Tue, 9 Mar 2021 18:07:17 +0800 Message-Id: <20210309100717.253-5-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210309100717.253-1-songmuchun@bytedance.com> References: <20210309100717.253-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 82A3DD6 X-Stat-Signature: dsiztnerzoqbmp7j5f5tmzxz4xoj3p7e Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mail-pl1-f169.google.com; client-ip=209.85.214.169 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615284548-993981 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: The page only can be marked as kmem when CONFIG_MEMCG_KMEM is enabled. So move PageMemcgKmem() to the scope of the CONFIG_MEMCG_KMEM. As a bonus, on !CONFIG_MEMCG_KMEM build some code can be compiled out. Signed-off-by: Muchun Song Acked-by: Roman Gushchin Reviewed-by: Shakeel Butt Acked-by: Johannes Weiner --- include/linux/memcontrol.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 07c449af9c0f..d3ca8c8e7fc3 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -469,6 +469,7 @@ static inline struct mem_cgroup *page_memcg_check(struct page *page) return (struct mem_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); } +#ifdef CONFIG_MEMCG_KMEM /* * PageMemcgKmem - check if the page has MemcgKmem flag set * @page: a pointer to the page struct @@ -483,7 +484,6 @@ static inline bool PageMemcgKmem(struct page *page) return page->memcg_data & MEMCG_DATA_KMEM; } -#ifdef CONFIG_MEMCG_KMEM /* * page_objcgs - get the object cgroups vector associated with a page * @page: a pointer to the page struct @@ -544,6 +544,11 @@ static inline struct obj_cgroup *page_objcg(struct page *page) return (struct obj_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); } #else +static inline bool PageMemcgKmem(struct page *page) +{ + return false; +} + static inline struct obj_cgroup **page_objcgs(struct page *page) { return NULL;