From patchwork Mon May 4 15:35:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11526557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 047D592A for ; Mon, 4 May 2020 15:35:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C3F10206D7 for ; Mon, 4 May 2020 15:35:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XU77sguO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3F10206D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F17768E004E; Mon, 4 May 2020 11:35:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC8368E0024; Mon, 4 May 2020 11:35:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDD368E004E; Mon, 4 May 2020 11:35:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id C20528E0024 for ; Mon, 4 May 2020 11:35:50 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7EDED180AD80F for ; Mon, 4 May 2020 15:35:50 +0000 (UTC) X-FDA: 76779436860.02.map83_500ddd9ae0f45 X-Spam-Summary: 2,0,0,676877ad22270bf2,d41d8cd98f00b204,laoar.shao@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1535:1542:1711:1730:1747:1777:1792:1801:2393:2559:2562:2693:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:6261:6653:7514:7903:8603:9010:9413:9707:10004:11026:11232:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13132:13161:13229:13231:14093:14130:14181:14394:14687:14721:21080:21444:21451:21627:21666:21740:21984:21990:30034:30054:30056:30069:30091,0,RBL:209.85.215.194:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: map83_500ddd9ae0f45 X-Filterd-Recvd-Size: 5563 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 May 2020 15:35:49 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id n11so8597580pgl.9 for ; Mon, 04 May 2020 08:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aIHOYIBTFKXQFWPbPqk25KsM7qt5wm0F/bf2FKOov2M=; b=XU77sguOkIP7960stC10qHNv0QSObNskE/tXrRw9VXb0ogtVvtjfPKyOZDNC2t2frK 3gfCxvC7UNNPvRxQG65UA8Q6uKee1r9GNt4gpXIbY/TKPRwvbZgkiCUyyjhC631TEyk9 a2jCzzbHWE18V4IHSlDIyglzTGrHaRcYY7N2aVFvSMr/w42I0BuozxbtdtzsFmuJOCXq swcHraLWsc5tN+zgI66Rn3X0rIPPGEG9xRwdrrgWqxshw7S3pCOyK4H0WcFNnmURrk4p TsWGYYkBcliQDdYxWeKoyzwx8qa4ql3hzE7HqhL1ayxVlnuNAi0QBd3/LCDWl3CtS0FC ZSgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aIHOYIBTFKXQFWPbPqk25KsM7qt5wm0F/bf2FKOov2M=; b=C9b0oM5ajUPgmUE7MjRJzI83TXkte1ACSmvOWSp6UvKz4+UL4PfnqEvP94sbKA1WKi wXaQYfHk2k9QcgokDKgyeO00B+34QLtxYbuJHgio/yOnFaZ2jXBkpRfi+2jf4gYtRish NoEQhf6ayrkTjthHE2W0EkJSwjPaXHgBUaw3pd81J7ck3n7tTl2VdPkKW+OHWKZv2C2n inXpzK1Rw7HHiuXral05sSGIS8b23bUSYgl3SH//ynAqevO5BRC9h/8dXZQhteTI/Aje MfiaqwnZ4WMBOxnpS4KkHzXlQ6X5hYSF2gIyIlLcI2BFze0TivMSx4Kzk8skiFjnH+mK V7qA== X-Gm-Message-State: AGi0PuapFB9ZazmVqFoKVLKaWnmjZn30sIDOPh/s6tPmpMcIba8OcKjN EXFLaaKnWQM364ia3L8VICo= X-Google-Smtp-Source: APiQypJDpmRi2fJz/JZSchXAQp8boHebXEr0gGTk+eo2lWzU2JtiKGmy2ppZj3ue1WTEFvuif+WaHA== X-Received: by 2002:aa7:9e07:: with SMTP id y7mr18357847pfq.257.1588606548822; Mon, 04 May 2020 08:35:48 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v1sm9130070pfn.212.2020.05.04.08.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 08:35:48 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org Cc: mhocko@kernel.org, hannes@cmpxchg.org, linux-mm@kvack.org, Yafang Shao Subject: [PATCH v3] mm, memcg: add workingset_restore in memory.stat Date: Mon, 4 May 2020 11:35:22 -0400 Message-Id: <20200504153522.11553-1-laoar.shao@gmail.com> X-Mailer: git-send-email 2.18.1 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: There's a new workingset counter introduced in commit 1899ad18c607 ("mm: workingset: tell cache transitions from workingset thrashing"). With the help of this counter we can know the workingset is transitioning or thrashing. To leverage the benifit of this counter to memcg, we should introduce it into memory.stat. Then we could know the workingset of the workload inside a memcg better. Bellow is the verification of this new counter in memory.stat. Read a file into the memory and then read it again to make these pages be active. The size of this file is 1G. (memory.max is greater than file size) The counters in memory.stat will be, inactive_file 0 active_file 1073639424 workingset_refault 0 workingset_activate 0 workingset_restore 0 workingset_nodereclaim 0 Trigger the memcg reclaim by setting a lower value to memory.high, and then some pages will be demoted into inactive list, and then some pages in the inactive list will be evicted into the storage. inactive_file 498094080 active_file 310063104 workingset_refault 0 workingset_activate 0 workingset_restore 0 workingset_nodereclaim 0 Then recover the memory.high and read the file into memory again. As a result of it, the transitioning will occur. Bellow is the result of this transitioning, inactive_file 498094080 active_file 575397888 workingset_refault 64746 workingset_activate 64746 workingset_restore 64746 workingset_nodereclaim 0 Signed-off-by: Yafang Shao Acked-by: Johannes Weiner Acked-by: Michal Hocko Acked-by: Chris Down --- Documentation/admin-guide/cgroup-v2.rst | 4 ++++ mm/memcontrol.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index bcc80269bb6a..5f12f203822e 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1329,6 +1329,10 @@ PAGE_SIZE multiple when read back. workingset_activate Number of refaulted pages that were immediately activated + workingset_restore + Number of restored pages which have been detected as an active + workingset before they got reclaimed. + workingset_nodereclaim Number of times a shadow node has been reclaimed diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5beea03dd58a..0395e479995b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1451,6 +1451,8 @@ static char *memory_stat_format(struct mem_cgroup *memcg) memcg_page_state(memcg, WORKINGSET_REFAULT)); seq_buf_printf(&s, "workingset_activate %lu\n", memcg_page_state(memcg, WORKINGSET_ACTIVATE)); + seq_buf_printf(&s, "workingset_restore %lu\n", + memcg_page_state(memcg, WORKINGSET_RESTORE)); seq_buf_printf(&s, "workingset_nodereclaim %lu\n", memcg_page_state(memcg, WORKINGSET_NODERECLAIM));