Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4466725rdb; Fri, 15 Sep 2023 03:13:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVPcLeyqHI/+5D+VcPyN8i/TSX5tCXNYc18jJjm2uAZdN4OH16mX4ZwdlFA+EmKnuNTEc0 X-Received: by 2002:a05:6870:1606:b0:1d6:5c40:11b6 with SMTP id b6-20020a056870160600b001d65c4011b6mr1332558oae.14.1694772797577; Fri, 15 Sep 2023 03:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694772797; cv=none; d=google.com; s=arc-20160816; b=sOJy5XoKNTl5q41Pm+dpLEYw+WtHdIVcQlZpAWtuXmP6oFIGRv0nd/nlzrNtm8THDz iCCYTEis8x4w0yTQYtq2JubT+dXY1XXj+oo9u6kHUH06MSWn5uW11oUteMzrK9Alj71Z Vu6snBK6Z6rCUHBBnjadwJr85xaeqmsdVgzMUBdm4bk/xiuxzgi58dOxZxTeWwzkXw4V ujrTWhZCupPL4TZ9yr9+EcMgE0SZbCF593XTXEUi74QJ9Hr66G+GplThUWsKnZxsspOq meWS+Adt+bnes8vQgIjd/eaHckdk0/jYcmaji4z7NupphuB7iJPAWDrJ+KrpZS8EmNxt 8c/A== 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 Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id j10-20020a63fc0a000000b0055ffed90cc9si2938343pgi.609.2023.09.15.03.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 03:13:17 -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 7BC8F836C01F; Fri, 15 Sep 2023 03:07:24 -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 S234180AbjIOKHW (ORCPT + 99 others); Fri, 15 Sep 2023 06:07:22 -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=20Koutn=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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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:24 -0700 (PDT) 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 */ -- 2.25.1