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 */