Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1058581rdb; Mon, 4 Sep 2023 01:20:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlOg6broPXDwWoU8p1H1NX1xP5Bskeg7ftxFe7TmwWFSSQQ5lLQrnrvfITU0zfSjQKUNDJ X-Received: by 2002:a17:906:3091:b0:99b:e464:bf49 with SMTP id 17-20020a170906309100b0099be464bf49mr6388564ejv.51.1693815610828; Mon, 04 Sep 2023 01:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693815610; cv=none; d=google.com; s=arc-20160816; b=GErcs2poZw6Gs5SZzmCmquexZHiR8cLqc8nOO8xpMzwyew0X5Q+KmPcqtCEdvf3OHt jrjTvaAMl0Q40JH06GharxrWl8znSAsMOEv1Xr0wqa8trQp/JYAzJ5F76zHmKWZcslXh 5ZmAGdRMwK8IiTmTkwothnRcqJg9eXRFwsEktspcO6zCedyHl3knT872zZulj0CVRe5I 01JXR75IhDwRE9+EP1+nHLBvr6yuvv6UlpuKkSJW119nvLgm5ud9g+HfVdvXmhCxTgfa zSlg2KB0lvUy9cdqS4si6bEWgQUWR/bjrm8ZP8fGubfMnpoowa2MRDjX82ZedNEjlRRc 1tYA== 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 :message-id:date:subject:cc:to:from; bh=2iCMb8BsxWT5xTZ1yWeznnxmcAPjq93oj3Y4b4grViM=; fh=+cNWoxZRXG6SVycG2GNjp+4cRNvJwrJ8xk8oqzSYD7Q=; b=fqtvbCPRJ5eu0GrWHyauM71QIRHSiB6xfwvucCGbUVW1k0+1w/zemQNWTFJfYIxFBk nXaVLERyIPeLY8YJGoHtAUb333rHJ/OB9GHrDnBWkdWjzUdLVqfOQg3sAno2sgSmqcgR d8He+5C0njGH2idl1h2BLrAb00GINDxNjFY5VDbvmTKG7/0TdCq4ScRpdK1ELt56co2e 7I32KsfZEx3atofH2Tct3MxGGZDCTOcNPsjegqoKWDqpGelgurB+8aeWsVom6uE3dg34 /C9/admrEi2FVvepnqFPHWQpqA8ZGy/M8Z6BWsGPfDi9dgqYiLZRL0TUzIEDs8VTk7oW WwoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a170906374c00b0099316613780si5599526ejc.1038.2023.09.04.01.19.45; Mon, 04 Sep 2023 01:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351926AbjIBJNZ (ORCPT + 99 others); Sat, 2 Sep 2023 05:13:25 -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: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.25.1