From patchwork Sat Sep 2 10:07:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13373052 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 59793CA0FF7 for ; Sat, 2 Sep 2023 09:13:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B9CB8D0012; Sat, 2 Sep 2023 05:13:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 469A28D0002; Sat, 2 Sep 2023 05:13:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 358948D0012; Sat, 2 Sep 2023 05:13:28 -0400 (EDT) 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 22C798D0002 for ; Sat, 2 Sep 2023 05:13:28 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C9D798014E for ; Sat, 2 Sep 2023 09:13:27 +0000 (UTC) X-FDA: 81191094054.18.912FF0C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id 7215F2001E for ; Sat, 2 Sep 2023 09:13:23 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693646005; 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: references; bh=2iCMb8BsxWT5xTZ1yWeznnxmcAPjq93oj3Y4b4grViM=; b=kE6OCsWGlpwfDp2jXCu5KL5X0aQ3QYu0TY8N3iER5FyXn6aTAMVLbg8C8bSztfNGsHn0HJ h6iuNuIov4T4JEq5IYcVaDq2tGII+OGYxRax3CMqr+fHbWi1Eru88OWXs5djXP/8M8dDje 5C+K0hWdKpSgzGYkLTuSgCuMOyjBvlM= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693646005; a=rsa-sha256; cv=none; b=ufMaCPmB0oY2AmpkBSd3Y23wnVytPrBsrNj0yPP08nJHy2nruId1WerOUFkWbBFj7PWGNy hD+24tqsAFposYHeG/owDgCZdQ55zMtL3uGm/POPLX8ny8ZKkpdf5pu54DpCh9V81KGm3C SKcswjFmlCP4kWT/itazWc6Jec2NjoI= Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rd8JR3q4XzVk8J; Sat, 2 Sep 2023 17:10:47 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 2 Sep 2023 17:13:17 +0800 From: Liu Shixin To: Yosry Ahmed , Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Kefeng Wang , Andrew Morton CC: , , , , Liu Shixin Subject: [PATCH] mm, memcg: expose swapcache stat for memcg v1 Date: Sat, 2 Sep 2023 18:07:28 +0800 Message-ID: <20230902100728.3850149-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: mx77fwa3pxqwuf81yjeost3yeny9qqtc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7215F2001E X-HE-Tag: 1693646003-576314 X-HE-Meta: U2FsdGVkX18pLxo+AXf5e0rFrA6fhQEAjo4Ojd8vZ2hbFUqallQyzmlZ6lWz6KB7Sm1Gz6lRloZbr5sTmPCL/jxD0esDCFlxIDn+0Cn67kTJaLqH5FQYzQ6UYoF1XUCWGmWDlFblohj/Ex0Gh3SDNuxOSIBpV5ic5ilIjSPAlmQVZryZTUcL+725nbGsM5W7t2MAKXpGAtKa+lIdYTqzeMBYERNsR5YElQISOH9yhapd0S6GeWScjRf6VpyF6OR07EqEnirM6Ezabh43u1REOmpcCHe8cudY0Kq62pOs3JLVvy/nyvRvxxQ5mxexRHlTiUxAISLci3RRjaQC6pDBR0so4b+DUW5H7carJN1BLS+ZRLZ93WxIWfaNNcguxXfdLAlumnae5o1f/t6DZUVoa2vHFmboIiIzesuC5iNH1Wi0eJ2OIxf23SnXa9W5P6kaewu1pYP2R8zC104CD5qlO15WPQsL00F/eiFIXmVD3YyZ/XxJyVD80SuG42DfFz0Myt6y/MIxvEG9wsn8TvNNnYTaVh9RazUIZhElCsGUu9It0CNYwekh7cQnxk9X4ZmnosuEGy/cGN0EuyquYeHhM9e28/v4jQtwJiBM7pNiZ280P7fWJFc0SmO14EwuSwCdDcnINuggHUelHIUdshMXtw6GkRSk9Q3xadBGmacPtDn9Yyljis0QRJ7vmiSp5fngMHLVheavheryC9E7+eV7FKisHaSeL7LpgkNsgZHhsU/iLRyA3euv4OvQkd+0b9l9M5gRBFdzSrZkeQD/YT98RlR08kQBf0IX2o5TP4ah7WkU+lE5ycaJMa7ZK9VdADmEnqYBZiaV6N3NxMyCCYi4HR5K0+cFQMem5vcPHD7H3dhg7od6qObEWChYmbE7aPP7jrwLos4PKF25nsR4JJvYuebCvkOn5G0Dnr+DOgtC/FpB7lK+AIUNXn7/UfpWAS1PvQpV6EPfPZCAtc1CgZv z63pKfjJ 6+L0hiI76p2g8M0k7ikWYfpZjgtfScgbPQlDnAqDeEw8MKeWMWK012rLgkmh+2uf7UonncRXWgi/vYfXuKZvxlLImviOSXcPl3lmebfpn2cbLCMYPRyJMbIovLebWmkco3FmjHaMT54YflDQ0RPW74eU/LVybazps9PYlsheGpbGw37g= 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: Since commit b6038942480e ("mm: memcg: add swapcache stat for memcg v2") adds swapcache stat for the cgroup v2, it seems there is no reason to hide it in memcg v1. Conversely, with swapcached it is more accurate to evaluate the available memory for memcg. Suggested-by: Yosry Ahmed Signed-off-by: Liu Shixin --- Documentation/admin-guide/cgroup-v1/memory.rst | 1 + mm/memcontrol.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst index fabaad3fd9c2..fb4abe0dc228 100644 --- a/Documentation/admin-guide/cgroup-v1/memory.rst +++ b/Documentation/admin-guide/cgroup-v1/memory.rst @@ -546,6 +546,7 @@ memory.stat file includes following statistics: event happens each time a page is unaccounted from the cgroup. swap # of bytes of swap usage + swapcached # of bytes of swap cached in memory dirty # of bytes that are waiting to get written back to the disk. writeback # of bytes of file/anon cache that are queued for syncing to disk. diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c465829db92b..619acf479be7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4068,6 +4068,9 @@ static const unsigned int memcg1_stats[] = { WORKINGSET_REFAULT_ANON, WORKINGSET_REFAULT_FILE, MEMCG_SWAP, +#ifdef CONFIG_SWAP + NR_SWAPCACHE, +#endif }; static const char *const memcg1_stat_names[] = { @@ -4083,6 +4086,9 @@ static const char *const memcg1_stat_names[] = { "workingset_refault_anon", "workingset_refault_file", "swap", +#ifdef CONFIG_SWAP + "swapcached", +#endif }; /* Universal VM events cgroup1 shows, original sort order */