From patchwork Fri Jan 17 01:46:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13942785 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 7390FC02187 for ; Fri, 17 Jan 2025 01:57:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2FAF6B0085; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A6E766B0096; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 595CF6B0085; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 215866B0089 for ; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CD514A14F6 for ; Fri, 17 Jan 2025 01:57:43 +0000 (UTC) X-FDA: 83015282406.18.AA0BDBA Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf27.hostedemail.com (Postfix) with ESMTP id 6AB7E4000C for ; Fri, 17 Jan 2025 01:57:39 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=1737079062; 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=UPKc7ft2JpOg+OAKWpamlj/AW0n8d8vPesZcgRRiI6s=; b=vqfdCb/O0zTWB9L8PekKdPBo9VCHsK/drwN2wvM7elhPVby7FZQjsuFkCINCcsJXNiKSqc KRat+dnklwo+fgde8ASfmWct6CSqx+sfi1HCuLr0cYmtJAG1XV0e1Sb7n8xjLJUsM0XSof RdYpFCIc+bRs+oWWkpQcu/rBX3B6tYI= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=1737079062; a=rsa-sha256; cv=none; b=U54h/La4ZS2AsyslRRigXiufPJUEFcMafzt/tLnQnmthS4RsMZQ+IZdeFO2EgzdX3SZtm5 laAMHS0Ak+oYHUZDopDuWYSl2TiFREJBJCeimBpZ/3I7NiJqZNIxuYiiMsWdYDn2CPUa3o o8/dBeClkE/nd6dgATTFNHZhHRBdg4A= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YZ2t64tBMz4f3jsv for ; Fri, 17 Jan 2025 09:57:18 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id E79071A176F for ; Fri, 17 Jan 2025 09:57:33 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP2 (Coremail) with SMTP id Syh0CgCnsWT7uIln8NWrBA--.20802S3; Fri, 17 Jan 2025 09:57:33 +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 v3 next 1/5] memcg: use OFP_PEAK_UNSET instead of -1 Date: Fri, 17 Jan 2025 01:46:41 +0000 Message-Id: <20250117014645.1673127-2-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250117014645.1673127-1-chenridong@huaweicloud.com> References: <20250117014645.1673127-1-chenridong@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgCnsWT7uIln8NWrBA--.20802S3 X-Coremail-Antispam: 1UD129KBjvdXoWrZFWrJF43Cw1xWF1xWr4Uurg_yoWfGFX_uF WkKr1DZr15J3ySk3Z0yrySvrnayF1UX347Kw45tw13AFyqqasYvF1vqr4vvw1kXr47try3 Cwsaqayqgw12gjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbDAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r18M2 8IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7AKxV WUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jjuWdU UUUU= X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6AB7E4000C X-Stat-Signature: hc6tyw6udamnjberqffyxj4ricqhogf3 X-Rspam-User: X-HE-Tag: 1737079059-979051 X-HE-Meta: U2FsdGVkX19UaxwqQaAg95/3tck6X0/V+TaeximQeCC0PkFNMw9mghe/xBu/d5xxHFbm/Mf8E5M12In8y0kDjwmNVp/SG9EnatdWDVMtRT8/NXsmD/4FC0/Li5/dzumKyAfQUzmfjOnEuwqenpSSqqOZY9j7KiK7/WkRqKUE9Fr15IWXdr/ajpc9q7b0UOWMRyYilWyvAlJ8sYadCBYjsamMpR7DLPu2TjNDibDnG4fGvEXghRW4ZzaTDsn/o3zVDDyCWgIFQILgpcKff99H3ycXCs2sQfTm96lzT0y/xV00xhBiAogqMPMViIqNLnk2ZHCYMgiweWZKxJaEHgzu6dqb9mKeP8BsZBla/lHwUEszzey0k0x2aW9ryP4V8fMwzOG/kLiSrozb/igtLUJwSVU/6KQwTiaIXV76EIZHxMVTRtFd63h8FFwK/Ev7v4JEhTkbNS+/PlSn/ah69MpcAzdMF5b8k96nlIFuNDhCZrwSRP0O05f6uDAkn2vOI/8FjsQTUXupCvOf2quBOYwUzGdAHKEosV8mFOVaWkLF0Gyx58ResFuxIRGLfR5II+bIwNj65dvjWbfnOMYmdwEwWiRceI46w5Y5YRZE+Lkz/PjKp3l7ybwsNPoxi3TYBc4pb7BoV6Re62zkz0PFmRuE1QdUKLFJ5FIeFD8Q13ZZb4HrqhmiUVdTrFWkIovSI+P+RV1Q2gUcZRen5I1DBvAX+9xWYappsksKiN2X7RvDh1otVL4kLnCkMJwLEXUR3gU7oT9r1pX+vYMkrZ2Te14NyLfue+ld9Sg/9c1p0TVtUQc3GYKUFy2E/u+IacEWp1h4353oGEgeiI/5qOFz4yT/KV/vVIp1laytPN3hz0UEo9rUxQ5zcXdtQVx9ViaB4ugtIGcoDRcUn1eawZNfODfHDD7I03Fj/67aQLoOz73ldnwHZZcOpZoUBTe1Tdgk9nIubZc6OrVKpwNF4q9ijRG euOs3ku9 g3I1bxLSUqkspQvuwpkNe76yZLDDSBq3K1c81+PcZR3QhUYox5aSktUpBh9bFkKBwJUDdNBtI0K7px3vF3OBMotW0hNvoGqJ+SsDezQIKxcCF8QOf0BiXfbFwtJ8T7WRhUS5Qi2FrR0z8dl0+tYq8qnaQCgHdgk1t9tA7X4C6gPpkmd98WAx2rnZXQwjwjOlpzqRBfRXecy/fgo5XMPHlDD9O189krSouw8ODA81X2u8oKGsmQc16b85ZzegqlXxEZvny61WlLpQmW/roTz6NIhfX+EoGVclnL7El8G7Rj3hMN4Y= 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 17 01:46:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13942786 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 4D47AC02188 for ; Fri, 17 Jan 2025 01:57:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E64686B008A; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C1BA06B0095; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B0B86B0089; Thu, 16 Jan 2025 20:57:44 -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 2453B6B008A for ; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D29A91C8475 for ; Fri, 17 Jan 2025 01:57:43 +0000 (UTC) X-FDA: 83015282406.21.2B3C708 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf01.hostedemail.com (Postfix) with ESMTP id 8937F4000A for ; Fri, 17 Jan 2025 01:57:39 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.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=1737079062; a=rsa-sha256; cv=none; b=CYLz6zlcDd+HySg+cg3jQ+Fhea8P0Sss0qiTBpC/nEnH7WVKSuFdArCebJececWCNQR/IJ kR+w6cWKk4F7Jfh7M4b+5HW8jPU3ft/ev8tuX2YO3t3KXkf0J0LAw5k4VjmTJ1QOCr+w3D zefUyr6aGf6HSoYuvoJWZPiGxaZf0Ko= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.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=1737079062; 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=2psctKiVePjiZ4h0wf9BJ41NNOvoxDC8B6IHotnpCWU=; b=v3xUg3PKofabJz2WARxXH5CRN72BJHtSpp1Yxf6bUPnTnsXe+ZL05BT7cUL/OgrsaP1vzz pc+lAnjNraVdKuuXxVjHjKhRGW73htomBZlfzTWPvU5k8x98/hl2fW1UM2Dr3Ya/arVnLq dCWj1QAq22gq/VL/+kPHphKDOalmYBM= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YZ2t02LFtz4f3kvl for ; Fri, 17 Jan 2025 09:57:12 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 0A0DA1A0D8F for ; Fri, 17 Jan 2025 09:57:34 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP2 (Coremail) with SMTP id Syh0CgCnsWT7uIln8NWrBA--.20802S4; Fri, 17 Jan 2025 09:57:33 +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 v3 next 2/5] memcg: call the free function when allocation of pn fails Date: Fri, 17 Jan 2025 01:46:42 +0000 Message-Id: <20250117014645.1673127-3-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250117014645.1673127-1-chenridong@huaweicloud.com> References: <20250117014645.1673127-1-chenridong@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgCnsWT7uIln8NWrBA--.20802S4 X-Coremail-Antispam: 1UD129KBjvJXoW7WFWUuFykKFWktw1xCr13CFg_yoW8trWrpa nxKa45Z3y5Jr4UWa1fKa4jva4rZa18Xw4UWryxXw1IkF1aqwnYqr12yw1F9r98CFyfXrnr trn8Aw1xK39FkrUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPFb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2AFwI 0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUob18 DUUUU X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8937F4000A X-Stat-Signature: 5am8coenmkje6mppfuup6efpa69ptnrm X-HE-Tag: 1737079059-188633 X-HE-Meta: U2FsdGVkX1+J4JEfB6TvOJEk7YkNukY0d7ZCeqRx74xcbfIlOWoD2mOA7xKcxRIGDY5MoW5r04nRvxA99yYr7/+m0v3phYBqWXZN1g4p6d9dC31rucCYKjmF+t/QC5BDjXKkIrRSjahH2qCTVmusoIf3TrJwSVLoS1S+GrlOaAsTO+FlaAEFfarfE1Ycerd6WIlrbFSctAZj1xry2vdDSyz69Ys2NibTWb/E2NzCllw1xOXR80YqO9Y6VFpXEQm/Be+lcjJQvouVpNN+PG6sFS6eQyWLDAjkdvKKbTrb57DP0jdIJ2g+QDM0UTugN0Vn4DvOaNkbkrnfThykhY6q3UDuRJzC4zLVhgEii+MS4xIAO5WCxXyOPhcAXEoOKerYL2TyOolakhgYzX3EUSn4YskwtXBnB+idsEBnz8DqXCwtisFWs0AjgxsDfz5vxBRU7gsIDneCG5C/mpxAx56DLEeoHKD76j96plsA+jmOd/P6t8lGObdUyMzY9OwLuD4IelIqvHI1n5UwaMbHiIY220jD6eR+EWlTAU+BVCVsmEvdNjAbty/vSo5pMp3D74yyBahEw9EQOeIKFyyqzz1vuWvc/hMYzaOYSCHx+eRk7wWHOwbUKHVGJU9d2lf4nZA88g/UXbn9slQbIhConKDx/w8lDtXQPNC8ke50JuGyYVVoND6uUhz1mcB+lMQrciZLPgvh+8bWdMvUWkrtp83C64I+W04ndZiYjhZprLWGNH+c+/ONFh+xE5M8wth/V5E1NxeEI+LkVnJg4juN2mx5bn5WtRg1XZSYkIcOOYyMXfVFZbWVUb1ka2hnGZA3JlRdmPiQC+DrJN2B06TuufBQzJIjlSBwpe6TfhtU94bCs0PpU059ea99AXx1go6tNFjMq/YNue4nqjFG80KyzUuYoKM09BD+bU4cu3sIEuZ4hL9geHtgoLOZHgXaA6mP1Up9X9IRWVIfICreb938Sah 7BetzKkx S7J/OznuN6g2x1jMD7Dt+VRypiCQq4lh3EnMjr4rIIvubU1fgxbgma9b+a4S3+iZVS7bqi7b9lRIpWpnR234hECJvVgaTX0gf5bDYHoI2DQ1lpYjDhz4bGULCg1VnKYE1b+SfnjESA/BSt4rUxkKmNUCnx0oygeaoAKrSWzH/flyOcwwJFnGjB34IyJyekNY7w95IJpBh0PSONd37j0Azuv5aeyTZLr2yIEdj 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 '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 17 01:46:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13942788 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 1B232C02188 for ; Fri, 17 Jan 2025 01:57:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C9796B008C; Thu, 16 Jan 2025 20:57:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0AA1E6B0092; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF1286B0089; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B30566B008C for ; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C5A71464D1 for ; Fri, 17 Jan 2025 01:57:43 +0000 (UTC) X-FDA: 83015282406.24.EFF094D Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by imf20.hostedemail.com (Postfix) with ESMTP id 829551C0007 for ; Fri, 17 Jan 2025 01:57:39 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=chenridong@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737079062; a=rsa-sha256; cv=none; b=55rgg4dyNVpl7uEcYcYb+5x5SnE5d9DXQZMNdQVzuz6NPEcJVL6DH6Ut9aP5CRkYuBAO+q bGL28K3MSTF3r0imKWQ5RfUbSVy9J70r8mDpZVoG8+nwYVqyXXxL1aSgMSRozAQy//OO3k /oL4HP7j5BytggT4PGJrRBtdgM3BQ7w= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.56 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=1737079062; 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=L6rEP3U/zDd80hEB74hZcIOTyTo/xR/mGDs42QRyIDo=; b=FeHjdCRJUce2ypKn4mGn2EDvLKeZ2v79OLt7ce2QohvtHBBlAphQK8oTaCkOWnogUfJ//4 dH3kMXvmcXwIqhBincOsxIwD0JQtfWL2IhNKgZcHX3qTaoqrTgp9+rfMNDtRUIsLV7vOAR WbLMwUX1L+SQv+bACvH49ZOQ+Fh5UwI= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4YZ2t14vsLz4f3l6r for ; Fri, 17 Jan 2025 09:57:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 25E101A0E08 for ; Fri, 17 Jan 2025 09:57:34 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP2 (Coremail) with SMTP id Syh0CgCnsWT7uIln8NWrBA--.20802S5; Fri, 17 Jan 2025 09:57:33 +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 v3 next 3/5] memcg: factor out the replace_stock_objcg function Date: Fri, 17 Jan 2025 01:46:43 +0000 Message-Id: <20250117014645.1673127-4-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250117014645.1673127-1-chenridong@huaweicloud.com> References: <20250117014645.1673127-1-chenridong@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgCnsWT7uIln8NWrBA--.20802S5 X-Coremail-Antispam: 1UD129KBjvJXoW7tryDAw47ur15CF4UuF1xZrb_yoW5Jr17pF srKas8Jr48AFW2gan8Ga17Zr1fXF4vqFnFkr4Iqw1xCFnIgF1Yq342yFyjya4kJr9xtF4x Jr4qyFsrGayUJ37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2AFwI 0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IUbd- BtUUUUU== X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ X-Rspam-User: X-Rspamd-Queue-Id: 829551C0007 X-Rspamd-Server: rspam10 X-Stat-Signature: yqgoc1dxkgzutxpfbdbnxxrmahpzz4e1 X-HE-Tag: 1737079059-67278 X-HE-Meta: U2FsdGVkX19tzYJLvdTptW1PWxiv1ZPT8gE4HK4zM3gTEmb/UEFIDfgR9p6UTsRVR6KnyZeKLo9DaUiW8vElzB5ZSyXZ7AWweaqm2IqU0VJOB3CsfpfChhN05A5TfTSu92aQGmD0zkCQz7AnYQicImxi1AIccECCPmXGZ2WcsQKv/rTF9h5QByF5TpJbVZX6uZ3zZ1lErqfl30ylqHjkZOVFj0yhQZRNdYU5AFpV6A6HfsJ0T/wvPBph4a4sUEDaKlpwRWTcAHojmuX3C1GW7/EZcH4lKsOEGczjHOx9KyC8G/NtmlgjS3Nl671Fsm5Hr5jbIQTXwNYb4GfpvYixmjACLGYm2sFF2m2bO6KSF3Ok8zBZ/t0MUHfkJUtQuHmFvbs6MOQuMkfKQ3TcJogV0jWyKv5aksshIsgy4EnuX+rx85Yuco3bgs+BW82Y6FsUPcc5G2gyli9ORyJNkkY+aMvfc4UmSkevd/eRFqz+rMEjnobW0K5eHfRLqkJRJJwKzgFdrRZqfxat8nQtMzW9Ri8wrKDTy7RPeMkA8zCaGan6bcg70IPTX0WUGWXkmz/Cah1OqRhG5nHj5Hm9TQPbglsw08MW3aEk9eymIWi7MlHJNdNK1/sozdtEuZ1bwH3HmM+GxbzoY4FpdagfCLq917S+gbWd2aEp6nG/PnqrZhPz300EG9DBRrKWaXpD6uyiX36U2/nB0R1J2Cnjyq0VduxsVRdxLYcfz/bOmybiEag14TFAfRxfU4mwbLnClzV8HTtbCptDLaNwOlYtfue8V2EVYhwXphrigmNMIJkop+KeTk0LSthDvnW4FRfXYghnzhnIeL+x7ck1/zRhlFw3syogkXWuBDJckAMLhc3gwpGkFrNZNMfTufm6fBM6+NkDMy9fBsurXWvR/RP6U9XCtTeyEI7wEK6m4wvjAvEiFYLKdOsZ5O/qxMtE3gL88SbWq6dW3cqhmy2ZGQ4rOJl eAgqAkbz UhAhz4lvkD/3jma7crhNy25tVhZr0kw8AkKhM06fCI16O4BnJnnutEIO+n2Of2hE0kVA4WRnlZ9cj3ID1+36IMgfc4ZQzGRRFkBSecMjnTHEmDx0zatHlPk/aA8GI8L+iB9N7ic/APVOoUMDKlnH7LTO8op0Fz25oMc4LGoXyZwNvJcqQofqcmm5RLdIElhfHFdp2I9jvTPCEYyGFvHAtPhGp+g== 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 17 01:46:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13942787 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 467A4C02187 for ; Fri, 17 Jan 2025 01:57:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2120E6B0089; Thu, 16 Jan 2025 20:57:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC94D6B0098; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABB986B008A; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 306086B0092 for ; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E8370161530 for ; Fri, 17 Jan 2025 01:57:43 +0000 (UTC) X-FDA: 83015282406.11.061A2E4 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf23.hostedemail.com (Postfix) with ESMTP id 07401140010 for ; Fri, 17 Jan 2025 01:57:39 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf23.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=1737079062; a=rsa-sha256; cv=none; b=Rm32LWl/nrwXqJA2+fXAvF85CVrDRjl0WAsaDK4+1uRn1Ta1W3lMdXk5UsIKcwrDFO8cF6 XOmqgXEYKI7luXyU26Iza+y5HuWvnFTnC0Z5pOR5ar0hoNeugfjMLngXQA7uMjRlTsophZ 91BMXSY6RMuP89Qi341fAaQsEuj9QzU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf23.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=1737079062; 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=uc7fuHJxjtRSUKrDsMWSn+mR1ozjU1KS6GIgp7TxyME=; b=c2o5nD6fn8Bpxtsgi0I3yIFiq8rmKs5WfJI4hVSP4UPH69r/h9cirm6VE4jVWyv6I2V0Mx R9cguFGSq210C37pj8VoBrSW0soeGCCtU1+ZdM/pXcsvZhLRPCjMwiMQkBM2+xxdM4i1mY 4kPK+8NkqgKB6FjnLRo27y4z12sB8pQ= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YZ2t045Qwz4f3l24 for ; Fri, 17 Jan 2025 09:57:12 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 47EAA1A0E11 for ; Fri, 17 Jan 2025 09:57:34 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP2 (Coremail) with SMTP id Syh0CgCnsWT7uIln8NWrBA--.20802S6; Fri, 17 Jan 2025 09:57:34 +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 v3 next 4/5] memcg: factor out stat(event)/stat_local(event_local) reading functions Date: Fri, 17 Jan 2025 01:46:44 +0000 Message-Id: <20250117014645.1673127-5-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250117014645.1673127-1-chenridong@huaweicloud.com> References: <20250117014645.1673127-1-chenridong@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgCnsWT7uIln8NWrBA--.20802S6 X-Coremail-Antispam: 1UD129KBjvJXoWxKw4Dtw4kKrWDAw4fZFW3trb_yoWxtFy7pF sxtayY93y3J3yFgr13KFWUZ34rAw1xX3y5JrWxJ3yfZasxt3W5W3ZxKFW7ZrW5Cr95XF13 Jayqyr1DJ3y2qa7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPSb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2 AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r 43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF 7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7I UbXAw7UUUUU== X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 07401140010 X-Stat-Signature: siscpra7wwcdtrezzxj36natrryucyth X-HE-Tag: 1737079059-230550 X-HE-Meta: U2FsdGVkX1/xsby+tP7419vdlJFuCwpmCNETbjcnkjsymj6sOy36e8h9AEeckv4yY1QYqOuF5rF3qgphW/d7RwOeHCTCu2zpO3JO3ukMjavn1DJDhFXtgb8DeSn373XB5aBWW09hIfdq0SSCfsroQpwILu1iVYRUZNMuIS4aVYfvRHGj8lvNv3Q6wprpTONfTOhfUzLaP+4Mi5vsJhzIY4UotQJHL90t5Z8ohVuGRUtD+k5FPueoaFZhlqR4UN5s0IheBZl/xBUeCKwzxgwi9A3g79By6RKgpX+zUinjwTwTjlB8nJhv+IHfO/UgZLlo1u7inybM0Nf8CfCgRyNfNiKx4FJrTWfInb3UXtOh2/Og67AGV7Kw5Dph7Dxd8cz2t/eo2gtWQSvGdPzeb3uqkKha0ZSfTZze5kB1AL/3F/iLj6HVqBxGyz4G0KCtu41TWa7dB7CIatPrsevEUUsEevNB9KXvRPDukd8OyilSkp0YLnj/1/5gsJtyGUCi/VdINaiAy2TXFq+SA3cFIJnUhQTHJyToGf0TNDuzjqfArm/Zn4HPF6jcjB3QNRJw166/kbVP6e1ImDpIPeZ9VOdBK+1jrpioimHlcMsVWAVf3+CxCOjM/3KCESW7bMdILwVj5rlAG6FVGoM7adWHgogJJmQhx7b1jFjUhWNDA0JhWzbNYHpxxaqGWWD/3PUKVks2A69aGRoKX+UWpNDhwVll6frJR9SN8AfYE21Zqzrb/884PKVBplsyWnq9xEuzvb18g6I42vMr9PyV7cBDYqUzJ/3/iM/8QlKRVSqJEQWXrZvmQgAYq/SxDF64aCwGp6DyTjVSdwvobM7YDubRc6wztwEmWvKJKCpw0sF+ZsleuwcHXUDnCkCZt7C1TjysyOxIcyDULBIoIw5e3yDd++rG7hd2OaPLIvNiW4q42EMvhuCe55ZrPCbd8r4aE8VAVZYuuOYdbnDBPzyH9ioGmco VFccqBdK oJ5MCb1IjXTvCq4Oe9GRo6tzpJlQ57ocner0jBEWAa0/Nf2dBTVHNFajNHNwv5uMcHbbaRuhXOdEx8FctLSmG/+oFK0sTbdDDpK8QAkackwwfgwGxTrkE5vGR5kO1j4MhTusVPZCp+Z1/DqkcMU2BPMMXDK0RwduTo1KXdnxz5uvimDnWwmJaj1rwJQ== 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 only difference between 'lruvec_page_state' and 'lruvec_page_state_local' is that they read 'state' and 'state_local', respectively. Factor out an inner functions to make the code more concise. Do the same for reading 'memcg_page_stat' and 'memcg_events'. Signed-off-by: Chen Ridong --- include/linux/memcontrol.h | 31 +++++++++++++++--- mm/memcontrol-v1.h | 14 ++++++-- mm/memcontrol.c | 67 +++++++------------------------------- 3 files changed, 49 insertions(+), 63 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6e74b8254d9b..ec469c5f7491 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -936,10 +936,33 @@ static inline void mod_memcg_page_state(struct page *page, rcu_read_unlock(); } -unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx); -unsigned long lruvec_page_state(struct lruvec *lruvec, enum node_stat_item idx); -unsigned long lruvec_page_state_local(struct lruvec *lruvec, - enum node_stat_item idx); +unsigned long __memcg_page_state(struct mem_cgroup *memcg, int idx, bool local); + +/* idx can be of type enum memcg_stat_item or node_stat_item. */ +static inline unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) +{ + return __memcg_page_state(memcg, idx, true); +} + +static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) +{ + return __memcg_page_state(memcg, idx, false); +} + +unsigned long __lruvec_page_state(struct lruvec *lruvec, + enum node_stat_item idx, bool local); + +static inline unsigned long lruvec_page_state(struct lruvec *lruvec, + enum node_stat_item idx) +{ + return __lruvec_page_state(lruvec, idx, false); +} + +static inline unsigned long lruvec_page_state_local(struct lruvec *lruvec, + enum node_stat_item idx) +{ + return __lruvec_page_state(lruvec, idx, true); +} void mem_cgroup_flush_stats(struct mem_cgroup *memcg); void mem_cgroup_flush_stats_ratelimited(struct mem_cgroup *memcg); diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h index 144d71b65907..f68c0064d674 100644 --- a/mm/memcontrol-v1.h +++ b/mm/memcontrol-v1.h @@ -59,9 +59,17 @@ 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_events(struct mem_cgroup *memcg, int event, bool local); +static inline unsigned long memcg_events(struct mem_cgroup *memcg, int event) +{ + return __memcg_events(memcg, event, false); +} + +static inline unsigned long memcg_events_local(struct mem_cgroup *memcg, int event) +{ + return __memcg_events(memcg, event, true); +} + 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); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b10e0a8f3375..404bbdfa352f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -375,7 +375,8 @@ struct lruvec_stats { long state_pending[NR_MEMCG_NODE_STAT_ITEMS]; }; -unsigned long lruvec_page_state(struct lruvec *lruvec, enum node_stat_item idx) +unsigned long __lruvec_page_state(struct lruvec *lruvec, + enum node_stat_item idx, bool local) { struct mem_cgroup_per_node *pn; long x; @@ -389,30 +390,8 @@ unsigned long lruvec_page_state(struct lruvec *lruvec, enum node_stat_item idx) return 0; pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); - x = READ_ONCE(pn->lruvec_stats->state[i]); -#ifdef CONFIG_SMP - if (x < 0) - x = 0; -#endif - return x; -} - -unsigned long lruvec_page_state_local(struct lruvec *lruvec, - enum node_stat_item idx) -{ - struct mem_cgroup_per_node *pn; - long x; - int i; - - if (mem_cgroup_disabled()) - return node_page_state(lruvec_pgdat(lruvec), idx); - - i = memcg_stats_index(idx); - if (WARN_ONCE(BAD_STAT_IDX(i), "%s: missing stat item %d\n", __func__, idx)) - return 0; - - pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); - x = READ_ONCE(pn->lruvec_stats->state_local[i]); + x = local ? READ_ONCE(pn->lruvec_stats->state_local[i]) : + READ_ONCE(pn->lruvec_stats->state[i]); #ifdef CONFIG_SMP if (x < 0) x = 0; @@ -651,7 +630,7 @@ static void flush_memcg_stats_dwork(struct work_struct *w) queue_delayed_work(system_unbound_wq, &stats_flush_dwork, FLUSH_TIME); } -unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) +unsigned long __memcg_page_state(struct mem_cgroup *memcg, int idx, bool local) { long x; int i = memcg_stats_index(idx); @@ -659,7 +638,9 @@ unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) if (WARN_ONCE(BAD_STAT_IDX(i), "%s: missing stat item %d\n", __func__, idx)) return 0; - x = READ_ONCE(memcg->vmstats->state[i]); + x = local ? READ_ONCE(memcg->vmstats->state_local[i]) : + READ_ONCE(memcg->vmstats->state[i]); + #ifdef CONFIG_SMP if (x < 0) x = 0; @@ -706,23 +687,6 @@ void __mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx, trace_mod_memcg_state(memcg, idx, val); } -/* 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) -{ - long x; - int i = memcg_stats_index(idx); - - if (WARN_ONCE(BAD_STAT_IDX(i), "%s: missing stat item %d\n", __func__, idx)) - return 0; - - x = READ_ONCE(memcg->vmstats->state_local[i]); -#ifdef CONFIG_SMP - if (x < 0) - x = 0; -#endif - return x; -} - static void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, int val) @@ -859,24 +823,15 @@ void __count_memcg_events(struct mem_cgroup *memcg, enum vm_event_item idx, memcg_stats_unlock(); } -unsigned long memcg_events(struct mem_cgroup *memcg, int event) -{ - int i = memcg_events_index(event); - - if (WARN_ONCE(BAD_STAT_IDX(i), "%s: missing stat item %d\n", __func__, event)) - return 0; - - return READ_ONCE(memcg->vmstats->events[i]); -} - -unsigned long memcg_events_local(struct mem_cgroup *memcg, int event) +unsigned long __memcg_events(struct mem_cgroup *memcg, int event, bool local) { int i = memcg_events_index(event); if (WARN_ONCE(BAD_STAT_IDX(i), "%s: missing stat item %d\n", __func__, event)) return 0; - return READ_ONCE(memcg->vmstats->events_local[i]); + return local ? READ_ONCE(memcg->vmstats->events_local[i]) : + READ_ONCE(memcg->vmstats->events[i]); } struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) From patchwork Fri Jan 17 01:46:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ridong X-Patchwork-Id: 13942783 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 E8230C02183 for ; Fri, 17 Jan 2025 01:57:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B26B6B0093; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5654C6B0088; Thu, 16 Jan 2025 20:57:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 369C96B0093; Thu, 16 Jan 2025 20:57:44 -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 114C26B0085 for ; Thu, 16 Jan 2025 20:57:44 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B801FB10F5 for ; Fri, 17 Jan 2025 01:57:43 +0000 (UTC) X-FDA: 83015282406.27.647D4D9 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 201C4180004 for ; Fri, 17 Jan 2025 01:57:38 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.51 as permitted sender) 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=1737079062; 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=ofYV2Voduavy/Nz9tPCRlp5NZ9NgfHZOoHuPJiDoAR4=; b=mFiYBgg0SYO8ihyuc/QgD//kf+sbeLPkmpxLeQz49E7DaT/4H7soEJINRvMoziZTfXV4y5 vhWHVkfSbmgaIgf53AZhe739gwKTDHg2UEhGdX/kk+S7aJ9HcF/WxeEE3NZCfTYL1Dsa8m 489AkaTrsIlFH/cS/iGz+UTC1tc2jKU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737079062; a=rsa-sha256; cv=none; b=j3mLQfPTSMhfLXISeYsUkZWUalcmqfYo1UWP46u/3Re0XNsb+BVQGlGey4O1G9HWgA7dpe WjJY5qy3gtTFDQA0OS+r3d3uCBvPrwVDwHJKSqmYCj4ptb7QxOW3Tem8eewXmveODZHTEu bcp8fAW3WjVF6kb9ZBRI1bmOyvRUbwg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of chenridong@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=chenridong@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YZ2t70L0rz4f3jt6 for ; Fri, 17 Jan 2025 09:57:19 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 4FC6C1A119B for ; Fri, 17 Jan 2025 09:57:34 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP2 (Coremail) with SMTP id Syh0CgCnsWT7uIln8NWrBA--.20802S7; Fri, 17 Jan 2025 09:57:34 +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 v3 next 5/5] memcg: move the 'local' functions to memcontrol-v1.c Date: Fri, 17 Jan 2025 01:46:45 +0000 Message-Id: <20250117014645.1673127-6-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250117014645.1673127-1-chenridong@huaweicloud.com> References: <20250117014645.1673127-1-chenridong@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgCnsWT7uIln8NWrBA--.20802S7 X-Coremail-Antispam: 1UD129KBjvJXoWxWr4Dur4rJr4UCryUtFyUGFg_yoWrGryUpF n3Ga13Kw47Jw45WF1akFyUu3s3Zw1fXrW5t3yxt34xZa43twn0gasIgrZ8ZrW5GrWFqFsx J3yYyr1kJ3yUtaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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-Stat-Signature: 9yuoamrnxzjfrk4i3gcd4fyxtbm6n1sy X-Rspamd-Queue-Id: 201C4180004 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1737079058-653465 X-HE-Meta: U2FsdGVkX18PMorM6abcdfViqgJrvyJhDh5YeH3cPqtXMR1H8MDWezrlEr3hmDCe5k8uSWkzH7qs0dCFlVGtj9FoBUEInCfmmyEiqcXU/HtX8+uJev1SauemrYUTB5kjhFJN9iLgWBEUX9ElFLCxJ1VB8EiWAdmENNITRBOBzErgAhiebALVckAPLGNDVxXpOfalfEnLZlbbpkyx9PmU40vMiGuKd9RC7BsimZwNSwTDVXmc1o9zqY2FKDjk/Nb9V2UZB3dbf3fu/L2gMqJxb54slpwCbDBOhRP0jTcOF8WafLhB7nwmMy+/ulRJfbAFtrNIRZ9zJtgg6Sv1SIeeDJoWqF7CRipcAzyWMOwmjHmw1j+1ka5ps0ku5HxFq4MAA0AzvLY2lSSgXDaBPDHUgmLPXBktLDCSLZhOYIRUvimPcfnb7BpZp73J9QIGikY6kwnQ0Y/FQbe5eLRaECESA+DNzV8KjIf5dAOgqkv9ZuoJulD+OdEYyYL5YbCVRL3lE6vUK08RWyokXGkF57g3jnwDttJNYTafnfGjhUGLwygFqAHW1rU7L5IfDy/TFzIwfEyIa0nuz8WGMl22V3IQOZ8KLgv8Qtocc9oTqhvg+O529UHkMPhw6j2R3TNOK6NJREuggkfFmfXcadsJfEnB7V28FSJU3OkpwfffmXKjvqQw/sXTi7/HXj3dr6H1pjWSNu2poSCm9HKno4zcxDxLnJL7UAwKf8+1RBZbXO9nH/8HAHV7ilOkDKxdrnyvkMU+qUhF9CsvtWOn1D1cVnX6X1zaWRMOGg7N5eBhy5OoRgfhL/EKTu60zAjVaVOSlJTPjF3mUa2rcDyCCqOSJwXpcP9hoI+dSpscryQx6zMgPXlNUTrR95EB/VuBOd5CVn849Gc1x30zvn+EzFBavBMy3HcQrcLon/yI8g47B0M4pLOAC/3I85LsE1mb/YjFhlLzbeCGfqONJgl2yyfeK0y pgpom8IN KVe57BmunLGG5935kekGEXy2Ph589Q75RnIfhwB2YEjFpFpbas/skILjL/cS/RntE4/N0G7K27DUBy+MeW88qAc2njtXdixtAjnnW8AORbykhQbsv5pn6Pyhjru+mp80WTb1B 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 Move the 'local' functions, which are only used in memcg v1, to the memcontrol-v1.c. Signed-off-by: Chen Ridong Acked-by: Johannes Weiner --- include/linux/memcontrol.h | 6 ------ mm/memcontrol-v1.c | 17 +++++++++++++++++ mm/memcontrol-v1.h | 7 +------ mm/memcontrol.c | 8 +------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ec469c5f7491..6895b2958835 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -938,12 +938,6 @@ static inline void mod_memcg_page_state(struct page *page, unsigned long __memcg_page_state(struct mem_cgroup *memcg, int idx, bool local); -/* idx can be of type enum memcg_stat_item or node_stat_item. */ -static inline unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) -{ - return __memcg_page_state(memcg, idx, true); -} - static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) { return __memcg_page_state(memcg, idx, false); diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c index 2be6b9112808..2e8529b63366 100644 --- a/mm/memcontrol-v1.c +++ b/mm/memcontrol-v1.c @@ -106,6 +106,23 @@ static struct lockdep_map memcg_oom_lock_dep_map = { DEFINE_SPINLOCK(memcg_oom_lock); +static unsigned long memcg_events_local(struct mem_cgroup *memcg, int event) +{ + return __memcg_events(memcg, event, true); +} + +/* idx can be of type enum memcg_stat_item or node_stat_item. */ +static unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) +{ + return __memcg_page_state(memcg, idx, true); +} + +static 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); +} + static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz, struct mem_cgroup_tree_per_node *mctz, unsigned long new_usage_in_excess) diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h index f68c0064d674..d76e9a47adaa 100644 --- a/mm/memcontrol-v1.h +++ b/mm/memcontrol-v1.h @@ -65,13 +65,8 @@ static inline unsigned long memcg_events(struct mem_cgroup *memcg, int event) return __memcg_events(memcg, event, false); } -static inline unsigned long memcg_events_local(struct mem_cgroup *memcg, int event) -{ - return __memcg_events(memcg, event, true); -} - +int memcg_page_state_output_unit(int item); 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 */ diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 404bbdfa352f..3f32d4ab55b3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1367,7 +1367,7 @@ static int memcg_page_state_unit(int item) } /* Translate stat items to the correct unit for memory.stat output */ -static int memcg_page_state_output_unit(int item) +int memcg_page_state_output_unit(int item) { /* * Workingset state is actually in pages, but we export it to userspace @@ -1402,12 +1402,6 @@ unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item) memcg_page_state_output_unit(item); } -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); -} - #ifdef CONFIG_HUGETLB_PAGE static bool memcg_accounts_hugetlb(void) {