From patchwork Mon May 4 13:17:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11525961 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 0489A1668 for ; Mon, 4 May 2020 13:18:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BFF722073B for ; Mon, 4 May 2020 13:18:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HiZ1c3Ob" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFF722073B 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 E1E158E0011; Mon, 4 May 2020 09:18:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DCE018E0003; Mon, 4 May 2020 09:18:01 -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 CBBF18E0011; Mon, 4 May 2020 09:18:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id B42158E0003 for ; Mon, 4 May 2020 09:18:01 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7187B16E23 for ; Mon, 4 May 2020 13:18:01 +0000 (UTC) X-FDA: 76779089562.10.boot72_28ea8527e7631 X-Spam-Summary: 2,0,0,bd19001c054c92b4,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.210.194:@gmail.com:.lbl8.mailshell.net-62.50.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:82,LUA_SUMMARY:none X-HE-Tag: boot72_28ea8527e7631 X-Filterd-Recvd-Size: 5501 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 May 2020 13:18:01 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id r14so5496357pfg.2 for ; Mon, 04 May 2020 06:18:00 -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=ibNyLhO/Vg70XxoLLRJ0iNiBompft8y81y9fVgp77pE=; b=HiZ1c3ObqxzPnlLbHz30BsgQFopnwvjU77lKJng0gtENsMEkNck+NefW8ivD+9xeJe 8n3G0FNNs0SCfdoxHa/Qx+JIgoxl58EkcSNJHnk3idrhHFyarhcWyoc1Mc0Q740SNQiN BEnCVjc+ME0ys8H8HO+RuoCgRiLuAY9vtE6r+Iy/FuKwSHTBrJqtdAXxodQFhcMpL7YK ckz/q7T1MjEAsLzo1uTEXkCtbR3bPUs/H70Y58pzgBpB4PiWeammdPCH5aKz6zZzubR9 /osNHNg8EqcaQd1FX48IwsyXIeIU6zJuuxbzJO9kQBShmPJxFCNXsoAMBWRGL/ZiZZrl 6hCQ== 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=ibNyLhO/Vg70XxoLLRJ0iNiBompft8y81y9fVgp77pE=; b=gfy2xFzWi7PByNLFVyIf0yeu+EkWxb6WZpGu3Z5LCNcbkpI9ly8PMEbc32M0AsbSFX 9GYymyxFId7LQwKw+2Ue4fRbWmzBG1ndrnlSy/nkR7gRNJN+LO1YBFAbVZ4GVvZC/KjR Isl52PNdhzmiZ0kGUPLVOYJTaJxNMaTu9cM7dH3Z0henn3ptVKBMaNDOJPKWUPPH6PXp hjtv3I4DiUEctstKnI3E/oAV1OMxLBwQuReb1sGJLpcOjSudJ60MQqg33YeL+dF3Se64 HNUBYDGrscg9VBPbhZEFC91XgPKSymTwegT2adFK8ln3srfRFCdScm215joazopvqgsy zWLg== X-Gm-Message-State: AGi0Pub4pBrWHwBFTG1ACE0B5MJkwob2bNi71+5uBSOwBpohAb5cGLE2 jgyHcRa2h+630BF3O71+rPw= X-Google-Smtp-Source: APiQypL1vC+VrCtj7rNWVTHlLJDL8w88Zp790lLbSET47J0/4jG/PcOpajdwtvjVnppyEKV8ZqcgUQ== X-Received: by 2002:a65:688d:: with SMTP id e13mr16013690pgt.261.1588598279852; Mon, 04 May 2020 06:17:59 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id b16sm8878369pft.191.2020.05.04.06.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 06:17:59 -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 v2] mm, memcg: add workingset_restore in memory.stat Date: Mon, 4 May 2020 09:17:39 -0400 Message-Id: <20200504131739.11246-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 --- Documentation/admin-guide/cgroup-v2.rst | 3 +++ mm/memcontrol.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index bcc80269bb6a..0733b659e757 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1329,6 +1329,9 @@ PAGE_SIZE multiple when read back. workingset_activate Number of refaulted pages that were immediately activated + workingset_restore + Number of transitioning of refaulted pages + 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));