From nobody Thu Dec 18 22:01:32 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40CB4CA0FF7 for ; Sat, 2 Sep 2023 09:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351934AbjIBJN0 (ORCPT ); Sat, 2 Sep 2023 05:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231882AbjIBJNZ (ORCPT ); Sat, 2 Sep 2023 05:13:25 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 927939F; Sat, 2 Sep 2023 02:13:21 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 sync= ing 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[] =3D { WORKINGSET_REFAULT_ANON, WORKINGSET_REFAULT_FILE, MEMCG_SWAP, +#ifdef CONFIG_SWAP + NR_SWAPCACHE, +#endif }; =20 static const char *const memcg1_stat_names[] =3D { @@ -4083,6 +4086,9 @@ static const char *const memcg1_stat_names[] =3D { "workingset_refault_anon", "workingset_refault_file", "swap", +#ifdef CONFIG_SWAP + "swapcached", +#endif }; =20 /* Universal VM events cgroup1 shows, original sort order */ --=20 2.25.1