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: 140327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp934525vqi; Fri, 15 Sep 2023 03:13:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3TEeloorQJyfYLG0AKEFKwoTCt+0uD8uIpSo32E0KLfYR5/Vop9uIjN3YYPqGU+Mv1JOt X-Received: by 2002:a17:902:e84d:b0:1c3:a396:259f with SMTP id t13-20020a170902e84d00b001c3a396259fmr1252398plg.26.1694772801118; Fri, 15 Sep 2023 03:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694772801; cv=none; d=google.com; s=arc-20160816; b=Kovw9O9Rv2A3Te5+ZoVSamgfbxMTKUvxdLoU4rzSSnMIrovkLC07mcXs5r7PVU9N3W Q2WdzQANM3t0cYXCs6s8orxOmIszKDlrCcapB6qbpvzrKbHHH3WRT2rIz498AlPCxejJ 0SnvO2MZo0CoMR761SBU3ds4cMYlpI4J+YIurAXySSu5B13/xUDFB1A34H+Vy0zBYlb/ R9aJ9QWeooAfXaV2A80jBU6ZqMJqt51wl/zf4/DbBCgNPxOla31y1aYhw0z1E9waMBqw eetZMaajGv6WjS55YHyi8qFKqybD/Wc6hYMMiXQZOXlrbQPvdbAJBqqLdrUyk1m/MQAD wsbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5vnnE5HHOyYqWBv9GZkQaCbAZEU7V5jaLI/SGkJbRT8=; fh=RQkjQsTB9MN2y2EM859QwzLXjpdZ6BmsHN1X9z9wMYM=; b=yLjy1WMRCKIZCCUHPt00LaNgkYtHdbK15KdKBQKBlE89RlVpcSdxlbfVhKvD+FJ5mC kC9OaAmmdlCDOSbZc8KQAoiP2qZlveSeE4s9zq5VYgNwLsXC8j7TWZA3Es9ZIQTXvr/N YiE8i91C5fSI2HWM62fT9G0ze+nPYbb7vzLw8qolFjYS/OoG4EHE/G7GyA+yAqJtX0Eu s/n9QlK2pH1UbVz/JDKkPB1oK0M1w+fzkG+iKofiLlvB15iWGfOx82ObicHhXcqOMoIt 0LHctFAeWQb98WoAHF7Xpgyb9Brm2nKUeDAWmiWSB3RUizofOwhIAAVJxfQyo6fxjY9r lc6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id h14-20020a170902680e00b001c3f5db54acsi3066032plk.635.2023.09.15.03.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 03:13:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 010D8836C036; Fri, 15 Sep 2023 03:07:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234185AbjIOKHX (ORCPT + 32 others); Fri, 15 Sep 2023 06:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234166AbjIOKHT (ORCPT ); Fri, 15 Sep 2023 06:07:19 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55707269D for ; Fri, 15 Sep 2023 03:05:00 -0700 (PDT) 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 03:07:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777098084993481943 X-GMAIL-MSGID: 1777098084993481943 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: 140328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp934557vqi; Fri, 15 Sep 2023 03:13:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7Sdvla26sd6PlIWsIosfJbpVFvinQR6YHSQohD1EMnjMpVAwbx/QcaeHp4IBxQb5xcdsG X-Received: by 2002:a05:6a00:1a54:b0:68a:54e5:24e6 with SMTP id h20-20020a056a001a5400b0068a54e524e6mr1347452pfv.8.1694772804751; Fri, 15 Sep 2023 03:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694772804; cv=none; d=google.com; s=arc-20160816; b=R8XJyeaP8Db+FyDjH8EdgD8P5dGwei8tTaEgDo7ir60qyCgpaDNIbb1q+srMkPbYeb 0+gQ5LTsM2bIDQrf2Ad6bp7NbV2UI7EGE5cH4HQc8223QgLHo4lGjeDvxjKQomus4oXK 3r2nvZU1tZHS6Nlzh79gWXjhZzBZ0zUEMnBuUn4xWH2awhU3QdNEjaJGv+WaO/r61zp5 MJ7I+nUZKIe88zcjMoOb3VfpGzX7jGOJYwgWNh7cGn8NvJUML2ZFyiDIAcITdY3pymzd +Qp4XEb23NvEwb9Q0b14t53Nabe2TfLffTYJmdYA3UTH66stpusQavbjkzb3OXnf8uET ijRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Q6U02gIn0wqsgNK8gekwnFNbaIRS4upizejAMxY3sRY=; fh=RQkjQsTB9MN2y2EM859QwzLXjpdZ6BmsHN1X9z9wMYM=; b=X3rvWL/A48Gn9F72iuvEOF70I+D5wHLSBQ1HogQ+uXKWJ6aJliq1PuXsoQZQIlXSuC pr0xvOGAl5sw98rvm7SczSXIC60qwkYAyQDZmIRelihQC8E67/pf+L86bfjjnAcfl47J c/I/1yst6rLiWm/jleB33Au6Ds4gq2adAtpgqlRprp/fyS9TEPif2OfdspNh3xg8JDHE 38JpVNsN3dWXaxg16u5VVzg4Rn098sTMt0KnmBRjz39BGsLVSW05h5JpQuRGujcnA6yW JjWW2r3o8sV2f5UQZU0sA5SkWqHpdYKG9sinO/wTRiu0rZ9Expb6tKsSTZc3aV6CpP/R ns5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u13-20020a65670d000000b00564f934aabasi2988094pgf.112.2023.09.15.03.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 03:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 73E9B83B2D40; Fri, 15 Sep 2023 03:08:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233958AbjIOKH6 (ORCPT + 32 others); Fri, 15 Sep 2023 06:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234134AbjIOKH4 (ORCPT ); Fri, 15 Sep 2023 06:07:56 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 731263C19 for ; Fri, 15 Sep 2023 03:05:29 -0700 (PDT) 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 03:08:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777098088646566945 X-GMAIL-MSGID: 1777098088646566945 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]));