From patchwork Fri Jan 24 07:35:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13949031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1DD4C0218C for ; Fri, 24 Jan 2025 07:46:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49346280040; Fri, 24 Jan 2025 02:46:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 42329280044; Fri, 24 Jan 2025 02:46:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09C0A280040; Fri, 24 Jan 2025 02:46:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C778328002E for ; Fri, 24 Jan 2025 02:46:16 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 79227C0E46 for ; Fri, 24 Jan 2025 07:46:16 +0000 (UTC) X-FDA: 83041562352.18.E264FAE Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf06.hostedemail.com (Postfix) with ESMTP id EFECC180008 for ; Fri, 24 Jan 2025 07:46:12 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf06.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=chenridong@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737704774; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I4Trr0/adqS+lxJEoljYu6HvbyK2/Xw4Q8MpyM3XPvQ=; b=wj1DI92WLZAsQGMEHuNTWDs1NSysGIcTGByxe/IVGMOSvCqk9elrk2KIwQxcumzoHQetBe KasWD0jkWFi7yE+71Vj6utJ96qItkr+SUTS8aHDfG1y0kxo0GrpF0YaWY+0GQ7jDbUgodQ Sgnd9MQpFZwzSMnIGss5GgrZht9fAqY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf06.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=chenridong@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737704774; a=rsa-sha256; cv=none; b=yhoyogQSUe+wAfE+7ANg/gvzUeOOvTJTglQlMpccm1zxolbmJD5+Ak52QJdlL0gfYDkcNz rMRTAMj89LEebWB0ww/irouXcC7DctbZfnsaGjuc1ZcmpIbh2Lih+nOfyq8fOOC2gQqFD0 GwHirXvB0qiZ8oAO2uzRiXGUBHygA80= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YfVGz1r5bz4f3lCf for ; Fri, 24 Jan 2025 15:45:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 397821A1391 for ; Fri, 24 Jan 2025 15:46:09 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP1 (Coremail) with SMTP id cCh0CgBHqnozRZNn89xFBw--.58969S6; Fri, 24 Jan 2025 15:46:09 +0800 (CST) From: Chen Ridong To: akpm@linux-foundation.org, mhocko@kernel.org, hannes@cmpxchg.org, yosryahmed@google.com, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, davidf@vimeo.com, vbabka@suse.cz, mkoutny@suse.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, chenridong@huawei.com, wangweiyang2@huawei.com Subject: [PATCH -v4 next 4/4] memcg: add CONFIG_MEMCG_V1 for 'local' functions Date: Fri, 24 Jan 2025 07:35:14 +0000 Message-Id: <20250124073514.2375622-5-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250124073514.2375622-1-chenridong@huaweicloud.com> References: <20250124073514.2375622-1-chenridong@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgBHqnozRZNn89xFBw--.58969S6 X-Coremail-Antispam: 1UD129KBjvJXoWxZF4xWFyxuFyUtF17ZFykAFb_yoW5ZrW7pF nxKan0q3yfJ3y5Wr1akFyUu3sayw1xX345trWxt34IvF9xtw1YgFnxCw4DZrW5CFyrXFsx J3s0yr1DJ3yYy3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPSb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2 AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r 43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF 7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7I UbXAw7UUUUU== X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EFECC180008 X-Stat-Signature: 1nsydpp19e6unwm15a56txj8s4nyii6z X-Rspam-User: X-HE-Tag: 1737704772-681081 X-HE-Meta: U2FsdGVkX1+2XbuhrI4aUcv773PFUggKhPbsk1bpO/NSfs5loMYpJYEctHCRY/2KZzpo0Mkbb2gKQVDU0ykzVEXtIQAREey7ck3XPt7BEFAP5UMitrRluiDHFU25iR2g/Zm26A50ovlAittQSB2m5LLuYk8MeCqlZUIbwy3Z6M/kjoGDXCh38eb7lhg2ii8gqicjMza5PmAhhzl7i38roD3YbEL77MXn1yfu000+bUX9/0JkQ5CEYhj6Ho7O1d5QOEelQ5rtjLCqvEMnL9rGnruN6J1RBLm0GeuXKGiEr8Qtdo5j6ujlgdKI5XfeyqqrbnNumU4DiJjQHSQ94VgicUfa+z3zrndvS7arJQSjeOvJofU5CiLFPUPMgi1AwxvWgN0o9ZMtNcMV2pqzUbQwZIer9dFksSW0n4hW8x0AD55I0EQhWVCpHniVTlNKcLC8PxbibNS+iAhf4XAo5rn505JZjgWeJ2XRr+tOOvk9hrhCnYx/fvfDA5poi/oq+80tL4UBF5C7BjNplQNL1LJM5OOAN2GrxcKu1ggF52ui6ocrYBpHvIPyNyLHb2hyCMawhQGOPmRVQehfV8W1GKEupEDkiWVMhMXsLxiDyr5r/rttopHpcn3KOHHePjrFg7ii+vHqcSFjn1UHyaNZUyAIZg36B7iTxBGtKhm8T1cnfztsPp9TxUDpTOaL4Oit9afBsQYbph+8F8hh4k6A5J/PqNeFV1CWZsyl87BrTz79tHa4Ha5SODHtPBfrc17f2dr2ew6pP6/e+8LB5dz/ETMWEk92TQu27XpglhmrVh9jpGkxY0DnIqPG+sJLFlBrN/zUhjhKPovqFZ1FDQlBj9o7TBmc8fumLAEFtu5GKPH5vS/kjVAmVmiIJ1w6mwHr2kT1U22y3NEHuUQwXVPIoRToP9ErhYaT3RlrEaIeQCXodGHolWMHFL5yTynCvWryJgthnlYjhqwdPStMk8eKW4f yhg1RYOW Li3bKj5bXmaHVtqk+9OVrzJGxU5Bs/Rva4dUxIt6RdB28TpTdGIj8TaeY1e2OVNLNKWdkhdHzqy4SvZ3/fBmBoshxSwAmLEvS9r2IuIVf5YIEyMlPj203iGKuFHIFTvZBcvMlYXTw3heF6w4lnHGlVD+h3AsTngbPN5RKatv2jDVbEcVQRaiInT0v0A== 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: List-Subscribe: List-Unsubscribe: From: Chen Ridong Add CONFIG_MEMCG_V1 for the 'local' functions, which are only used in memcg v1, so that they won't be built for v2. Signed-off-by: Chen Ridong Acked-by: Johannes Weiner Acked-by: Shakeel Butt --- mm/memcontrol-v1.h | 6 +++--- mm/memcontrol.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h index 144d71b65907..ecff454373e2 100644 --- a/mm/memcontrol-v1.h +++ b/mm/memcontrol-v1.h @@ -60,15 +60,15 @@ unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap); void drain_all_stock(struct mem_cgroup *root_memcg); unsigned long memcg_events(struct mem_cgroup *memcg, int event); -unsigned long memcg_events_local(struct mem_cgroup *memcg, int event); -unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx); unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item); -unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item); int memory_stat_show(struct seq_file *m, void *v); /* Cgroup v1-specific declarations */ #ifdef CONFIG_MEMCG_V1 +unsigned long memcg_events_local(struct mem_cgroup *memcg, int event); +unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx); +unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item); bool memcg1_alloc_events(struct mem_cgroup *memcg); void memcg1_free_events(struct mem_cgroup *memcg); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b10e0a8f3375..daa74af15b05 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -706,6 +706,7 @@ void __mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx, trace_mod_memcg_state(memcg, idx, val); } +#ifdef CONFIG_MEMCG_V1 /* idx can be of type enum memcg_stat_item or node_stat_item. */ unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) { @@ -722,6 +723,7 @@ unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) #endif return x; } +#endif static void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, @@ -869,6 +871,7 @@ unsigned long memcg_events(struct mem_cgroup *memcg, int event) return READ_ONCE(memcg->vmstats->events[i]); } +#ifdef CONFIG_MEMCG_V1 unsigned long memcg_events_local(struct mem_cgroup *memcg, int event) { int i = memcg_events_index(event); @@ -878,6 +881,7 @@ unsigned long memcg_events_local(struct mem_cgroup *memcg, int event) return READ_ONCE(memcg->vmstats->events_local[i]); } +#endif struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) { @@ -1447,11 +1451,13 @@ unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item) memcg_page_state_output_unit(item); } +#ifdef CONFIG_MEMCG_V1 unsigned long memcg_page_state_local_output(struct mem_cgroup *memcg, int item) { return memcg_page_state_local(memcg, item) * memcg_page_state_output_unit(item); } +#endif #ifdef CONFIG_HUGETLB_PAGE static bool memcg_accounts_hugetlb(void)