From patchwork Fri Sep 15 10:58:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13386788 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 0AE00EE644C for ; Fri, 15 Sep 2023 10:05:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90BC26B0339; Fri, 15 Sep 2023 06:05:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BBE96B033A; Fri, 15 Sep 2023 06:05:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AA4A6B033B; Fri, 15 Sep 2023 06:05:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 634236B0339 for ; Fri, 15 Sep 2023 06:05:05 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C5B83120FD9 for ; Fri, 15 Sep 2023 10:05:04 +0000 (UTC) X-FDA: 81238398528.14.EF7016C Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf24.hostedemail.com (Postfix) with ESMTP id 4AC86180027 for ; Fri, 15 Sep 2023 10:05:01 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 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=1694772302; 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=5vnnE5HHOyYqWBv9GZkQaCbAZEU7V5jaLI/SGkJbRT8=; b=jSLACVZfxSJcnAOwzrICBMEkXrDzbFfUVdH7JJbfERRFBj21fYQp4nHM6XOTTTfv5D191c NBnz+pyCJwmVvNjJeagiMOmb/uhkfMJdRnY7xeiFLfTeFkFL1tU39+ljA/dGKa+FQuUyP5 0+QhUylgm3A16t1/PAaGdKLFfzGGva0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694772302; a=rsa-sha256; cv=none; b=SCvp5vh411RGOm5OlWoBF4xUvdaoJEfCVK1VVC7dZdbAP3XYr/pbClRbkqxZhrVvDC1X9d e+rAvof2ZMa+9PXFV/CKuIM9g/SOq9NB0glb1g2C1QDsme8hxVnjuLhtE1cmRWcGz5Ocnh XTFkr8jcFcpKEjF2Meq4gOVtNtU38hE= Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Rn8p91XdYztSSb; Fri, 15 Sep 2023 18:00:49 +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; Fri, 15 Sep 2023 18:04:57 +0800 From: Liu Shixin To: Andrew Morton , Yosry Ahmed , =?utf-8?q?Michal_Koutn=C3=BD?= , Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Michal Hocko , Kefeng Wang CC: , , Liu Shixin Subject: [PATCH v2 1/2] memcg: expose swapcache stat for memcg v1 Date: Fri, 15 Sep 2023 18:58:44 +0800 Message-ID: <20230915105845.3199656-2-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915105845.3199656-1-liushixin2@huawei.com> References: <20230915105845.3199656-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4AC86180027 X-Stat-Signature: 9p4a7tor7e3sh6pzftf3krbfcb67j7mr X-HE-Tag: 1694772301-794780 X-HE-Meta: U2FsdGVkX18IvetuQOmCWCtulfkxUYKLJC0hIogGpVq9VksCrfjh5trXQSaMH77gsrUwNVGTF64E7uhaABwyaKOOou1ypMw/K2BGxv/M0H86yXSZIBD4cBWzRp38Th3O9seUt8n2o3GYLcGpg6NlcOCEqTIB3Z9d6OtHj2U6JeMh/IC7YwseFvfpdEhWuvVbR/9l4wscA0Jrr/sRhVhGqUy2iodgFQTYUZ1tLUipNNJRLFECMSAJJ+9LNFwz0tQslmu9hLUgeU/Pf1VMHKMg0dRBkiTUGEkHQmKIa4FSmzZXnv/E7ulUytSbVdv6PLyJWnV9EpFm6sL0ipfb9Uz0PudrtMstHEe0pvYxCH/2KfqVfxS77g7fbF1W/qBiF6m2G91K0Q2+Aer+GHp2q7lYdiE7C5ePTF0T/h7oFpeyuwbL7oNcWh+j56IfJoY7zFuau6ITm+tmJNMseAY5Z4PsNdZqzKhePv0wohWhKcM6WCuJ2nLu4TWyJcR13mZT9aEc6bJp7S7sP1MP1AzDClMN/0KUutaeTIZKSlqmgYW66KGxvHOTeTnQLE0y426J+7WczEKywu7Vr5rrdirtWomq+8p/7EzkWvHR7xdaIwpzt0vtv5JJeJFA5RPzM/7JemY6LvclrU75zRsUtk7G7XlQyqHfn7hb/5ghHpQKGQugtsshhHXQ7FLfXnzmg62yNggXt93Vr0VE6ACD0Qxo6C8iSHld2Gr1yYswOKf4WITE7OptXiEt3tkuOl5i8SJLbu5q2HnIj9vRUzxZavR5MHNJqKDx3T08Iv39myVrzK5Dgo0V/WERnS/womBoS8QItTjxsJKh+BYd+rHtStbNCYN5mhiOC/8PI1cI+yu+q/9Bfe0NI5DLhSw4FoqJ/1Kchmfr+uC1DzXCvTHRQl21IZw98CDyPMEvDjP/J2aQwA9WNIIUOiS29sGdMBY1cW0O3iFf4Kncmxv5oUblxO7utx9 geS5PU2h dJwSfwaOyTAcEaTynKe/Affhb3svrajafwAgpcn9MIEtKylJNgiVKE550ogYR8mLPaOsEKXOAe6KxgV9lmwGJ3cW/L4Bl3DF2BcPumnlPZwlGvWV1+znalDm3tRcMDJ4Rdovr6hsiCMdvnH0qIMXmVafZR5pZjfMXBWxv0RVvqPxJmo8= 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..78ea10c5a636 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4067,7 +4067,10 @@ static const unsigned int memcg1_stats[] = { NR_WRITEBACK, WORKINGSET_REFAULT_ANON, WORKINGSET_REFAULT_FILE, +#ifdef CONFIG_SWAP MEMCG_SWAP, + NR_SWAPCACHE, +#endif }; static const char *const memcg1_stat_names[] = { @@ -4082,7 +4085,10 @@ static const char *const memcg1_stat_names[] = { "writeback", "workingset_refault_anon", "workingset_refault_file", +#ifdef CONFIG_SWAP "swap", + "swapcached", +#endif }; /* Universal VM events cgroup1 shows, original sort order */ From patchwork Fri Sep 15 10:58:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13386789 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 8BECDEE644C for ; Fri, 15 Sep 2023 10:05:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11CE16B033A; Fri, 15 Sep 2023 06:05:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D5B86B033C; Fri, 15 Sep 2023 06:05:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFE8D6B033D; Fri, 15 Sep 2023 06:05:34 -0400 (EDT) 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 E15606B033A for ; Fri, 15 Sep 2023 06:05:34 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AC6FCA101B for ; Fri, 15 Sep 2023 10:05:34 +0000 (UTC) X-FDA: 81238399788.25.2D11DE7 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf22.hostedemail.com (Postfix) with ESMTP id 4BA4DC0019 for ; Fri, 15 Sep 2023 10:05:31 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.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=1694772332; 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=Q6U02gIn0wqsgNK8gekwnFNbaIRS4upizejAMxY3sRY=; b=RArzpeReJfQW/Ir/VRDOSEV5tIBgpXLwE9cByUnV0sbuziukfZmEaSG4QpJXdS8IbBdeO6 Vxm15AuAayloDvvmW3WBWe3DT9uP+GEUP3ekEK6zcluqZPVV45xhJGUoHOoHOCQIGI2ElV W0D+CIwOwa6J6MzEeyW4XZvw6HS74Q4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.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=1694772332; a=rsa-sha256; cv=none; b=8AzBaq6cpPoEUg2Ne0Js6Qelfc+FwjIBTMgeuKrFNoCHh6pTINEMgezo0dULOnshe6dolI ylEyd4MsS+ku60KjBUUrHceHmUltI/8MxhnubgqT8sYl5flcwqwQ+RSoxbow9G8KGV5NAC Ui/qYg+1mFL4s0KMPF8sR0L5VxeqZic= Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rn8pg1m0hzNnfy; Fri, 15 Sep 2023 18:01:15 +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; Fri, 15 Sep 2023 18:04:58 +0800 From: Liu Shixin To: Andrew Morton , Yosry Ahmed , =?utf-8?q?Michal_Koutn=C3=BD?= , Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Michal Hocko , Kefeng Wang CC: , , Liu Shixin Subject: [PATCH v2 2/2] memcg: remove unused do_memsw_account in memcg1_stat_format Date: Fri, 15 Sep 2023 18:58:45 +0800 Message-ID: <20230915105845.3199656-3-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915105845.3199656-1-liushixin2@huawei.com> References: <20230915105845.3199656-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 4BA4DC0019 X-Stat-Signature: 79hfqszgygw3fih4i1x9aji9e4csdkzq X-Rspam-User: X-HE-Tag: 1694772331-162510 X-HE-Meta: U2FsdGVkX1/uBE8g4qcgRYuadKeC5R9DKpBuq3M9zKrIQ5aGetnBpzhXrxULKgni0v13rjU3lGytUdzAbLKIEmwufJ2pHzEf5W0Ld8iKxXj/uVuQNQZNrSnsGIIMFgPydsFgL3SdCW8rQL17fuhecUv7//pbccGF2XBDk7FIeAQyRbeZaFcUJDO5MIE84utqi2ll5CWdN0nHZp6yb6yK7jKKefb60VugI+e9EskLf2CN5QMfzjEqdFu+zL+P3ITh5n/eTH8ePBkh5AJXm/1hk1jotWopeztesFPXfE8gNT/Ed32ISlKlQCALqsdcd0amXrOvksOPLumKddD9wwtURLwBWi9/0fYpMMjahhRSLFhe/ocZg20sbFI1KDX4AsJs0S6D1aF14UJ2LAtvhNOcHIRPPJo0liXrfeEfFb4irwidUC9xtlkAM4Rzx4AkFdRdVUT10ebrbTLM4MlT2PKyNfE/1QeDaHXjFxFDQK2O+SF2g15OKcO6qmZBkakN3uA6+k/0YEGsVD1/9rRygKNHBo6KVI2JfXuDvXrl574DgmzH45C6wARBAcnQLPHWY5d2mgXpp7VjGuAX2r+kyOHncDLhUY9B9wdvorazKaG7gX2jdQ6vm+celwlZ2dW3tm/99RZyvISLFNrd1tId1OLunyGzXI/wiwRgzE7RpYFDn9JZD3LFM5WlgGsB56IbjWb1uTyrjsHD8sWeWFM/EsJxvkl6v7FAThG8OidL06UXgR3atKq/vqhf+NHBtv70W/aXtt5RCqM54BpU+Es302wEa5kTixOEcVLkmhlS+6ykZc3aMpcwh+/X6rni/RYEbojSx/58BEmeiboI3RJr6x10rhhGul9R6NTljv5h70VLPvvD1PfFpBZq0/wCaZLb14CylJbBMcpE4fqztvWmQXt+hV2ynIvq16dFdVo5LYdI6e+8tKu/J12/w63i7UGw+DdenjVx4ydVv+QISOOSRdZ gEEoyLdd yY5fij73kO64qUhW41p9AYdYA2cNexkBrud11jkJ2HfI/2TZ9SYBjqjwmxxD6V0t4T0WGr+S9hCUCYtG8/lFAB1/2fh/vT1DqqvP4xqqdPB252tHwp+DUob7nac6b48GXy6Mm2k5fFcOclVIq5dNp5xJS2DyH6awjU8wQU2RCmAp7W28a4oDQqUeOM2f6/eyUbaj6NqIo9d9SCpXdfR0a1lTobI70BWB8Kz8kVggDnfmS7+NllVvbIp84brrHVCRohtJen4FrlXSotRc= 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 b25806dcd3d5("mm: memcontrol: deprecate swapaccounting=0 mode") do_memsw_account() is synonymous with !cgroup_subsys_on_dfl(memory_cgrp_subsys), It always equals true in memcg1_stat_format(). Remove the unused code. Suggested-by: Michal Koutný Signed-off-by: Liu Shixin Reviewed-by: Yosry Ahmed --- mm/memcontrol.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 78ea10c5a636..bb9a617be046 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4112,8 +4112,6 @@ static void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s) for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) { unsigned long nr; - if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) - continue; nr = memcg_page_state_local(memcg, memcg1_stats[i]); seq_buf_printf(s, "%s %lu\n", memcg1_stat_names[i], nr * memcg_page_state_unit(memcg1_stats[i])); @@ -4136,15 +4134,12 @@ static void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s) } seq_buf_printf(s, "hierarchical_memory_limit %llu\n", (u64)memory * PAGE_SIZE); - if (do_memsw_account()) - seq_buf_printf(s, "hierarchical_memsw_limit %llu\n", - (u64)memsw * PAGE_SIZE); + seq_buf_printf(s, "hierarchical_memsw_limit %llu\n", + (u64)memsw * PAGE_SIZE); for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) { unsigned long nr; - if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) - continue; nr = memcg_page_state(memcg, memcg1_stats[i]); seq_buf_printf(s, "total_%s %llu\n", memcg1_stat_names[i], (u64)nr * memcg_page_state_unit(memcg1_stats[i]));