From patchwork Tue Aug 16 18:58:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12945220 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 382B2C32772 for ; Tue, 16 Aug 2022 18:58:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 637F48D0001; Tue, 16 Aug 2022 14:58:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E87E6B0074; Tue, 16 Aug 2022 14:58:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AEA58D0001; Tue, 16 Aug 2022 14:58:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 387BC6B0073 for ; Tue, 16 Aug 2022 14:58:17 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1310481411 for ; Tue, 16 Aug 2022 18:58:17 +0000 (UTC) X-FDA: 79806366234.08.715E58D Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) by imf28.hostedemail.com (Postfix) with ESMTP id 9F496C01B3 for ; Tue, 16 Aug 2022 18:58:16 +0000 (UTC) Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-10ea7d8fbf7so12640768fac.7 for ; Tue, 16 Aug 2022 11:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=CzN9U8S3U5wsu3LqNuDxk2kPbUdDS4xzFtJt6PkLgao=; b=nEJGoYq9tv3G9+Ot3Wzbzv5hIglYLNiZQq9ZXoTqRMxHgwM8D52w9VWUrDhl3opKDD 5oF/RI5eAvBaSJMsNaQ0q0kQCgisTMna3oT0Irfh5bOmrLnOKEftArR+a3ajnYK0gITF neIIREcQfSomM34o4HRxg4bKaH7isikWJMKJhysVdM7jxIOpLd8JHWGZWZMWeL+QFgQ6 DfF9Dw6+rZWkljsnOwhdmsIhKU5wEUYGvU+RRxCm65xnOZLkqRd8OZlYjKrFAxwIuIEw vR/7Doj33/N+i0VuS+A/XMWQM1Kb3PZCb2sPBXCaOvEOgR/hZn5Ym/gWX/YAvkobcigl i02w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=CzN9U8S3U5wsu3LqNuDxk2kPbUdDS4xzFtJt6PkLgao=; b=s04r2+w5thVIYjHRAIUEjtx/7faYo8R2+6GnL4/GH9TagSKPXRfOIcf22yqms/iGX3 nC0ZyipbcMxsVKVubBlsQijkJtwX9dgRw+Mv+63tJ8S8Xzuz+djLLgDIIjg6d9W1uM2M ANwC7MIxEc9soa/uCvWqE9qmxC07JhLLHg1Unq23i2JQuuWvjikqkl6ut2sd89G997Rn SqvCAvqu7Q8hJQmZL+pXFruM4xCLT9SNmnOmcbtAXt9HtQU3GRcNTzebAQGyBrN2YoCv S96BqFfiUAmYdVdj3z5TP8YPz09RU4IBV7jDmAMJxWe8WdR+hqNV1vK1jB8f5XX+FvzR m6Fw== X-Gm-Message-State: ACgBeo0UM7AE7YKSLYf15M51py6G6UxEnQIw2kc4v9qnRNIHrOv9u0Zs sLzM65xVG24xEugmfeGp4dG3ryBYmUs= X-Google-Smtp-Source: AA6agR4rl0FHA6RdwufQUK92DccC/euhsF80M+P7ndnIahAy1WEgG8+guuxUAUPtBOUXE9E6R5+JNw== X-Received: by 2002:a17:90b:17c8:b0:1f5:4724:981f with SMTP id me8-20020a17090b17c800b001f54724981fmr25564246pjb.205.1660676285155; Tue, 16 Aug 2022 11:58:05 -0700 (PDT) Received: from localhost.localdomain (c-67-174-241-145.hsd1.ca.comcast.net. [67.174.241.145]) by smtp.gmail.com with ESMTPSA id n7-20020a170902e54700b0016c78aaae7fsm9471731plf.23.2022.08.16.11.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 11:58:03 -0700 (PDT) From: Yang Shi To: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, songmuchun@bytedance.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: memcg: export workingset refault stats for cgroup v1 Date: Tue, 16 Aug 2022 11:58:01 -0700 Message-Id: <20220816185801.651091-1-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660676296; a=rsa-sha256; cv=none; b=GaWf94tAPWqELxK0+uX2BT2OVkHJ4eaq5xq/nsIcaO6LpRyCfIpup58RBF2/aOL32sxlFR X5MQCYbZdpHZJ4bqMT7DU/eIGibQgnPEgnTLbSdbwiNSbDzMFvCUL9zNrsz8M5yhNkrsni m2fCXeoqbnvMBrtik1YBePTF6wCaMjI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nEJGoYq9; spf=pass (imf28.hostedemail.com: domain of shy828301@gmail.com designates 209.85.160.51 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660676296; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=CzN9U8S3U5wsu3LqNuDxk2kPbUdDS4xzFtJt6PkLgao=; b=lISrpe36oGzV/ChVf/eYuRoy87vgtNb3XVwopog10si3kgx9D0lGfz0ZjvVBeGaqsyxpWp 0npwBu10jV2GrnCtHr7bj8T97pvbx+a57RIVVBnciDtnRBXe6ItNYXev1siK41zFkxazs3 lkBHVbgPUtWCDGuY5spKuf4sblCmAcU= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9F496C01B3 X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nEJGoYq9; spf=pass (imf28.hostedemail.com: domain of shy828301@gmail.com designates 209.85.160.51 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: ex4zuas1bkp1wbph4i9e6n1kkccg363e X-HE-Tag: 1660676296-943797 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: Workingset refault stats are important and usefule metrics to measure how well reclaimer and swapping work and how healthy the services are, but they are just available for cgroup v2. There are still plenty users with cgroup v1, export the stats for cgroup v1. Signed-off-by: Yang Shi Acked-by: Shakeel Butt --- I do understand the development of cgroup v1 is actually stalled and the community is reluctant to accept new features for v1. However the workingset refault stats are really quite useful and exporting two new stats, which have been supported by v2, seems ok IMHO. So hopefully this patch could be considered. Thanks. mm/memcontrol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b69979c9ced5..e300437896dc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3975,6 +3975,8 @@ static const unsigned int memcg1_stats[] = { NR_FILE_MAPPED, NR_FILE_DIRTY, NR_WRITEBACK, + WORKINGSET_REFAULT_ANON, + WORKINGSET_REFAULT_FILE, MEMCG_SWAP, }; @@ -3988,6 +3990,8 @@ static const char *const memcg1_stat_names[] = { "mapped_file", "dirty", "writeback", + "workingset_refault_anon", + "workingset_refault_file", "swap", }; @@ -4016,7 +4020,8 @@ static int memcg_stat_show(struct seq_file *m, void *v) if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) continue; nr = memcg_page_state_local(memcg, memcg1_stats[i]); - seq_printf(m, "%s %lu\n", memcg1_stat_names[i], nr * PAGE_SIZE); + seq_printf(m, "%s %lu\n", memcg1_stat_names[i], + nr * memcg_page_state_unit(memcg1_stats[i])); } for (i = 0; i < ARRAY_SIZE(memcg1_events); i++) @@ -4047,7 +4052,7 @@ static int memcg_stat_show(struct seq_file *m, void *v) continue; nr = memcg_page_state(memcg, memcg1_stats[i]); seq_printf(m, "total_%s %llu\n", memcg1_stat_names[i], - (u64)nr * PAGE_SIZE); + (u64)nr * memcg_page_state_unit(memcg1_stats[i])); } for (i = 0; i < ARRAY_SIZE(memcg1_events); i++)