From patchwork Fri Jan 24 07:35:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13949034 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 4D505C02181 for ; Fri, 24 Jan 2025 07:46:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6EE628004A; Fri, 24 Jan 2025 02:46:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CF88D280049; Fri, 24 Jan 2025 02:46:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B98EE28004A; Fri, 24 Jan 2025 02:46:49 -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 97287280049 for ; Fri, 24 Jan 2025 02:46:49 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5914A80A2F for ; Fri, 24 Jan 2025 07:46:49 +0000 (UTC) X-FDA: 83041563738.13.FB30176 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf03.hostedemail.com (Postfix) with ESMTP id 1812A2000C for ; Fri, 24 Jan 2025 07:46:46 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf03.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=1737704807; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h7g+slmzehx27fWM3LRrwjskXwYl5mnp3YVL9gKL+cw=; b=IV/V8W3rDDQ6cItE3K+7GZ3Kwx4BAMmaZZ/qXAIXnMnu8PiEFLNrpgB9jx3afJ+3LXcIEs ni2lc9uSAPWK9Rga4YsBzXWEn2nJCb0TAovFfpPnGuGQEo6DjM/nhUmuNZY5WkaLK1ieaz jDE+ifTJJ2bztqNZanA5bfFq4WNhozo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf03.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=1737704807; a=rsa-sha256; cv=none; b=2OHdLhJkTgygj4s4K0rrlvl8IgYXmS0zzqDPVt6z9FInI1yxbhENrb1j2g86bCo5L0Ro+8 XYyhMBPgrrXjzx9o1v2YkCLyJ7/g1v6Ro7sBsTgTUC5W2TpyFSaBplFKqYPfGH/RR4mkLl yrXuximpGAtV9rIuqqkP2S0Y2PBjCYg= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YfVH53nQBz4f3jss for ; Fri, 24 Jan 2025 15:45:53 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 08EA11A1384 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--.58969S3; Fri, 24 Jan 2025 15:46:08 +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 1/4] memcg: use OFP_PEAK_UNSET instead of -1 Date: Fri, 24 Jan 2025 07:35:11 +0000 Message-Id: <20250124073514.2375622-2-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--.58969S3 X-Coremail-Antispam: 1UD129KBjvdXoWrZFWrJF43Cw1xWrW5WrW8Crg_yoWfZrbE9F WkKr1DZF15J3yakw1FyrySvrsYkF1UGa43Kw45tw13AFyDtasYvF1vqrsY9w1kuFsxtry3 Cwnaqayqgw12gjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbDkYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r18M2 8IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F 4j6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0 oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7V C0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j 6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8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c90Htziu741ilH1Yd5Z+yGB6CafeTwX7otr6yDKJaOS8Hvw/oYGvhjOsVcIdvWItBgXd+8VWEZ1XNC8xupNMm2P34XSm0n5xWCmKW7RtLVooZBv9YztQvOazlu8kf6JqsElIfshF6c4rUjsLESY8xH72mAfju2Pa8h3YuLxdtbUpRaq/r5v0zGsWxcmh1WW+EYe8QKpMTk5oM1AlQqamzkzDQYeb1QkmJ8ZaC9C0HN2BSWbQTaVstAJaSeOde/TBvpjEdiyM2Ip2+nHYGup2pgBOy6chTZOEATMf7NRgjktdLOgFeAQ2xTf8EyBYb0XhlzCku88rt0cghDHEAZyez6J27GYe3TYMvO1LFmcMqrpweNBmnD1T9hI2aJnNOK3yYl1+dT5X+cm7zLuPuGupOaNy72OoPqhWXvPsiOjcgPF9PrZeHXaACT3L58OTvg2zY84S05PZ3hZcghChIUPl3VkHlpoVTnlW Vl7KOtgm DZ3qpVxx3EUbXzuw7nI2YdF1wrQox7+ePPcHcY2vuBJYpuHkdV5k80ZAALl0sfZdAqLP6qZlYc4XM1wlfcchZD1CYq2kM5649StQqAjQG/5XNa+Bl0O43d35cG9zYyNRS3qGI2gpERIbCga76c0c4zY1XsbGQYBkGzSy4B9KJy8s8NxCeaGMB3Jnuia0mYSiBm6EH4PAHM8YFIbLPU4y1ARSvlbub36o00X3Fzo2daZn8e/m2b0ARNqmH4DIgWaGsCM69ZFxWjvmiDh6ddeUub8u75pKzQizskJgQ6gnyfv3+OOIG/hq/I/DWfk+v0EbndHC5ru/dgei1aOyHOAkKikEy3hm0JnI2q1AkYeq8QkfP6A8= 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 The 'OFP_PEAK_UNSET' has been defined, use it instead of '-1'. Signed-off-by: Chen Ridong Reviewed-by: Michal Koutný Acked-by: David Finkel Acked-by: Shakeel Butt Acked-by: Johannes Weiner --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 46f8b372d212..05a32c860554 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4004,7 +4004,7 @@ static ssize_t peak_write(struct kernfs_open_file *of, char *buf, size_t nbytes, WRITE_ONCE(peer_ctx->value, usage); /* initial write, register watcher */ - if (ofp->value == -1) + if (ofp->value == OFP_PEAK_UNSET) list_add(&ofp->list, watchers); WRITE_ONCE(ofp->value, usage); From patchwork Fri Jan 24 07:35:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13949033 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 948DBC0218B for ; Fri, 24 Jan 2025 07:46:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29C6E280044; Fri, 24 Jan 2025 02:46:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09C8C280039; Fri, 24 Jan 2025 02:46:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF9A4280044; Fri, 24 Jan 2025 02:46:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 992D2280039 for ; Fri, 24 Jan 2025 02:46:18 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 55CAB45991 for ; Fri, 24 Jan 2025 07:46:18 +0000 (UTC) X-FDA: 83041562436.23.C53A050 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by imf09.hostedemail.com (Postfix) with ESMTP id B2853140007 for ; Fri, 24 Jan 2025 07:46:15 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=none (imf09.hostedemail.com: domain of chenridong@huaweicloud.com has no SPF policy when checking 45.249.212.56) smtp.mailfrom=chenridong@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737704776; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d7CIj29+cQZlmSdNWoIYc4ubeJw4gRHGR/eh+nyjA40=; b=20XmLYMTllYL9JRvCMsoKA54etfeeIGoJSFIAUstJfZBSrPlUIuYVbzcmOfpLznW7eNJVy DjH6riimZh/n2iHJNPIFIM3r4SxKsEYks+blZ/vpaFZLPcYISVPOSYC0to3yEmYLq428dA UmT8GiATpWfgb81XaC33ErDZVdiuPxA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=none (imf09.hostedemail.com: domain of chenridong@huaweicloud.com has no SPF policy when checking 45.249.212.56) smtp.mailfrom=chenridong@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737704776; a=rsa-sha256; cv=none; b=fKFslE3VCjAkA3j6uSbRzHS9xNmnvTyyBmpW3q06yspqsJxrxeR0fwky+I608x0LfiVf5K x6eaVNaa1ROF/X8wvY0eB+gKR2jmCO1rs4qSCsA1SHB17EOJ6TmLPNZ4441/BmFpe3oKZX Da0+MvX3ySDUbZyMhV9aFdcDz3g+O2c= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4YfVH02fb9z4f3jYJ for ; Fri, 24 Jan 2025 15:45:48 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 140CA1A1065 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--.58969S4; Fri, 24 Jan 2025 15:46:08 +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 2/4] memcg: call the free function when allocation of pn fails Date: Fri, 24 Jan 2025 07:35:12 +0000 Message-Id: <20250124073514.2375622-3-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--.58969S4 X-Coremail-Antispam: 1UD129KBjvJXoW7WFWUXFWUuF45JF1UKF17ZFb_yoW8tFW3pa nxKa45Z3y5Ar4UWa1fKa4jva4rZa18Xw4UWryxXw1IkF1aqwnYqr12yw1F9r98CFWfXrnr trn8Aw1xK39FkrUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2AFwI 0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IUbJD G5UUUUU== X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B2853140007 X-Stat-Signature: g8jripqj5mt1hj1999tk87mrrtc3wbjn X-Rspam-User: X-HE-Tag: 1737704775-279971 X-HE-Meta: U2FsdGVkX18pHdb/SSIBXi3+cK0Jgmh2cIJ2qgzGyemGe4zb3ngI5k9t0/np/Ukz2Fp92PAbu/ufFSVmJYd+b7W12wJ/o9XLMZXFOgWLM3a6gPuFcgRpe+6fXCwmImZ3ikWitHXNLqUobScRCtG2+r22APoSilguBH+/+OAxEZ8vBrS5L0Pt4qBMdxkXAksuDW1RynIttbQAYvodjVOvKNZxpH3wPNgR5Mf5UnX+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ogofilter, 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 The 'free_mem_cgroup_per_node_info' function is used to free the 'mem_cgroup_per_node' struct. Using 'pn' as the input for the free_mem_cgroup_per_node_info function will be much clearer. Call 'free_mem_cgroup_per_node_info' when 'alloc_mem_cgroup_per_node_info' fails, to free 'pn' as a whole, which makes the code more cohesive. Signed-off-by: Chen Ridong Reviewed-by: Michal Koutný Acked-by: Shakeel Butt Acked-by: Johannes Weiner --- mm/memcontrol.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 05a32c860554..98f84a9fa228 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3424,6 +3424,16 @@ struct mem_cgroup *mem_cgroup_get_from_ino(unsigned long ino) } #endif +static void free_mem_cgroup_per_node_info(struct mem_cgroup_per_node *pn) +{ + if (!pn) + return; + + free_percpu(pn->lruvec_stats_percpu); + kfree(pn->lruvec_stats); + kfree(pn); +} + static bool alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) { struct mem_cgroup_per_node *pn; @@ -3448,23 +3458,10 @@ static bool alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) memcg->nodeinfo[node] = pn; return true; fail: - kfree(pn->lruvec_stats); - kfree(pn); + free_mem_cgroup_per_node_info(pn); return false; } -static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) -{ - struct mem_cgroup_per_node *pn = memcg->nodeinfo[node]; - - if (!pn) - return; - - free_percpu(pn->lruvec_stats_percpu); - kfree(pn->lruvec_stats); - kfree(pn); -} - static void __mem_cgroup_free(struct mem_cgroup *memcg) { int node; @@ -3472,7 +3469,7 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg) obj_cgroup_put(memcg->orig_objcg); for_each_node(node) - free_mem_cgroup_per_node_info(memcg, node); + free_mem_cgroup_per_node_info(memcg->nodeinfo[node]); memcg1_free_events(memcg); kfree(memcg->vmstats); free_percpu(memcg->vmstats_percpu); From patchwork Fri Jan 24 07:35:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13949032 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 01D8FC0218B for ; Fri, 24 Jan 2025 07:46:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B49728002E; Fri, 24 Jan 2025 02:46:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A90A280039; 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 488A728002E; Fri, 24 Jan 2025 02:46:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 04967280039 for ; Fri, 24 Jan 2025 02:46:16 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 85C2E160EC9 for ; Fri, 24 Jan 2025 07:46:16 +0000 (UTC) X-FDA: 83041562352.16.47E155F Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf28.hostedemail.com (Postfix) with ESMTP id 2196BC0007 for ; Fri, 24 Jan 2025 07:46:13 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=none; spf=none (imf28.hostedemail.com: domain of chenridong@huaweicloud.com has no SPF policy when checking 45.249.212.51) 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=C8bF7wjCk+mtY3eBs/iy7sO2fjY2uHRA9TT6+EiiZUI=; b=S9Kx8BZeJhAJJwRpmy0RLb+Z0/hJv74ovvajTMbY9UChGuQ7FGKsp0PNutc/E8/Ovkj83z 4QG4kqZg0InsMrh97ooMM5NyJbnnsPL8+8Ruv8ZzEmRjEZQKT0Xiv0T5p534hqGJf94Hzq jDrArJ3UU6GnM2UZO4svxI4A6B8ejx8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=none; spf=none (imf28.hostedemail.com: domain of chenridong@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=chenridong@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737704774; a=rsa-sha256; cv=none; b=lljFUDwpLPoNfdLDCLQp1uux6xW5dMgWY6p4PIfo8WB3kcGhti6ki7TbTIooRjZjjof7Ub EFxw5VeIMVxFJhDy3KL+BdqyX34xVYTorwAyPiBwaSDIh+lTtUDADuOyvuCLHpUfqTH8mS EeUaGcQZroPdhzenBNlen6JsJbbnMXM= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YfVH54gQPz4f3jsy for ; Fri, 24 Jan 2025 15:45:53 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 293F81A1020 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--.58969S5; 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 3/4] memcg: factor out the replace_stock_objcg function Date: Fri, 24 Jan 2025 07:35:13 +0000 Message-Id: <20250124073514.2375622-4-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--.58969S5 X-Coremail-Antispam: 1UD129KBjvJXoW7trykJFWUuF1fWryrKF4UJwb_yoW5JF1fpa 9rKas8Jr48AFW2gan8Ga17Zr1fXF4vvFnFkr4Iqw1xCFnIgFn0q342yFyjya4kJr93tF4x Jr4qyFsFkayUJ37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8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kRqq2P6WilyUtyobPDbn1ZfoqawKrn6B/6mJ8AJo7jV9eVlkIO4dfd6maGp7I7uT+q1rCwJm9kftnZ5elRC1kdO+YwZkZYENeujLiKUN35DH6GnmBb3qGH7JdFDz4ygMxWa5NSNPvLlC+ikTwWXT7jesoW/BkMLfFR6X1aSpV4rI7DxLQ/6l8cbcc30r/I3jh7Iy/QzZ4UTzljHg6ZrAXvDa+aMJvvUG/iW1C0E67WS1OGC8HG/+ZQkYQArxlWftxrRfO75qM3+0MQUD/d3eta1ijLz2Ju99tTO4lOqt9ej61v5tAnkDncYd/obDk2dvLPjG/DY/qYlAxh8Qmj4z+4kEd+7p2MAinL+BYblQNAjcGXwWyJoDCBE0wExbr0CFXieeOk+GOI1gXG1eeGIXw7e86yai49i8vg3cw/oxTRdUbxFZ7B0BoFZpMbymyXvbeJuR1vFAocD3sSdLSjKi+pTIl8ikeIUpyE4sNJTUbjyhbqzi3m4a1O0d/C4KTvu/gmdzBPop79qdZh8+YlEBHCpCiWiv rClTTl4H sFeJyhR8L/dE5sne9u9yE+IS+2zI0u1ZVn6IDfNtYETwwCuNhjc7+bwXjJ29GOlw1X0+HNJOI32JdluJxsi8aeFrtLZ+y7/ftLjmvwoxAyaQNydGBWF8XfwncXLa3cAfnEZ7C6NVDVAowEagK/QmgAvxGdtbqut1Lk5YOKDnvSeCzakMn4Hfph7CO65VTpm+rb5qQqKz1FvdRuwFAWmgv0wPcRaPFFwWY8qBT7bXpIpJT5g/KafVbU9qdN4XOf/SZD/+p 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 Factor out the 'replace_stock_objcg' function to make the code more cohesive. Signed-off-by: Chen Ridong Reviewed-by: Roman Gushchin Acked-by: Shakeel Butt Acked-by: Johannes Weiner --- mm/memcontrol.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 98f84a9fa228..b10e0a8f3375 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2691,6 +2691,20 @@ void __memcg_kmem_uncharge_page(struct page *page, int order) obj_cgroup_put(objcg); } +/* Replace the stock objcg with objcg, return the old objcg */ +static struct obj_cgroup *replace_stock_objcg(struct memcg_stock_pcp *stock, + struct obj_cgroup *objcg) +{ + struct obj_cgroup *old = NULL; + + old = drain_obj_stock(stock); + obj_cgroup_get(objcg); + stock->nr_bytes = atomic_read(&objcg->nr_charged_bytes) + ? atomic_xchg(&objcg->nr_charged_bytes, 0) : 0; + WRITE_ONCE(stock->cached_objcg, objcg); + return old; +} + static void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, enum node_stat_item idx, int nr) { @@ -2708,11 +2722,7 @@ static void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, * changes. */ if (READ_ONCE(stock->cached_objcg) != objcg) { - old = drain_obj_stock(stock); - obj_cgroup_get(objcg); - stock->nr_bytes = atomic_read(&objcg->nr_charged_bytes) - ? atomic_xchg(&objcg->nr_charged_bytes, 0) : 0; - WRITE_ONCE(stock->cached_objcg, objcg); + old = replace_stock_objcg(stock, objcg); stock->cached_pgdat = pgdat; } else if (stock->cached_pgdat != pgdat) { /* Flush the existing cached vmstat data */ @@ -2866,11 +2876,7 @@ static void refill_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes, stock = this_cpu_ptr(&memcg_stock); if (READ_ONCE(stock->cached_objcg) != objcg) { /* reset if necessary */ - old = drain_obj_stock(stock); - obj_cgroup_get(objcg); - WRITE_ONCE(stock->cached_objcg, objcg); - stock->nr_bytes = atomic_read(&objcg->nr_charged_bytes) - ? atomic_xchg(&objcg->nr_charged_bytes, 0) : 0; + old = replace_stock_objcg(stock, objcg); allow_uncharge = true; /* Allow uncharge when objcg changes */ } stock->nr_bytes += nr_bytes; 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)