From patchwork Sat May 2 14:18:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11523923 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 C2DE114B4 for ; Sat, 2 May 2020 14:19:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8F54D24956 for ; Sat, 2 May 2020 14:19:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W0j+pEP1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F54D24956 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 D0FEB8E0005; Sat, 2 May 2020 10:19:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CC0A78E0001; Sat, 2 May 2020 10:19:11 -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 BD6438E0005; Sat, 2 May 2020 10:19:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id A3C708E0001 for ; Sat, 2 May 2020 10:19:11 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 63BD9180AD806 for ; Sat, 2 May 2020 14:19:11 +0000 (UTC) X-FDA: 76771986102.28.hen19_15fee4b917c4b X-Spam-Summary: 2,0,0,08273e9375f0de57,d41d8cd98f00b204,laoar.shao@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1542:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:4321:4605:5007:6261:6653:7514:7903:8603:9010:9413:9707:10004:11026:11658:11914: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:30054:30056:30069,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.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:23,LUA_SUMMARY:none X-HE-Tag: hen19_15fee4b917c4b X-Filterd-Recvd-Size: 4791 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Sat, 2 May 2020 14:19:11 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id r4so6018428pgg.4 for ; Sat, 02 May 2020 07:19:10 -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=TSdt2n3K4dAbF7MkA+qbx1+/QeSwVEF7lyTGxcQ2LpY=; b=W0j+pEP1kMMREY4Rs8JmOOgdNWDeW4Oltnlp1KjXaclt92T2r4ezYfZxZPBxh1CQ4Z R/sU2KLmFJEcfmHPqpcYEvk6a9W0ZpMat0Z/f80vICI5EnG35dHYkD/Eyuu6ZhE19Twq JSrn0J2WCWI0s1CENSiQ2uCcBrPplF4VV/wqq8dAy3xz0pcpK5ypx5WcpM0KQPm8uBMw GsxJJSUu0mUjRlu0m3fT4NU//dmUJ6PCvINDf1/ewDXDyMkGY0a233T+Dx91tItTs2/i 5ToZ4iEiw389keiuZIW7+R0vqgYmUbRRUogm+O6T3rXBgFd1S1GwJTGTtLm8g9CI08ts zXyA== 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=TSdt2n3K4dAbF7MkA+qbx1+/QeSwVEF7lyTGxcQ2LpY=; b=CqKQoOBxLt3DheqRxwI1aZmRPn0R1xbMdF2zzN7nZTKj5znaHsV6Y3qvbDKpXvA217 RtzwL/h5IBILJgaoS7Jj2p9+w2SjjkTKTGdeE/MQslASyh/AFi860l/HKCI39BVIPoQH Jm97uX09VaBxuCF9JFLc7W815U2ytC430nxAWTJzm8Gq/GZxmYBoSizGwQPXh8E6chre z0bSW/H87Eqv9SVGVXjmcohFoCZSrt15qvc33RcO82sg/fhR23KReBgLLzlmvFikSEWp HkWmvd77MtAyvmsYX4B1H/iBy1FwX2BmL5EMTHkVPSjx/iS50jPHo4+GrDoELleIpmEg MKzw== X-Gm-Message-State: AGi0PubedF6O+MhsIZUQvZPVLyS0YT8LMo7DFWYBjYWeNNmbFgFojX/e H9+KedQr1iiaGWMlPb+fSFA= X-Google-Smtp-Source: APiQypJ+hCk+ZzUwoU2Z79AnRQZcvUwK2AlS5RVRCDMlUzYZDJtlsH7Vosmh9HY4cfaCr4Iv9NlryQ== X-Received: by 2002:a63:f809:: with SMTP id n9mr9219337pgh.355.1588429150084; Sat, 02 May 2020 07:19:10 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id w2sm4540798pfc.194.2020.05.02.07.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2020 07:19:09 -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] mm, memcg: add workingset_restore in memory.stat Date: Sat, 2 May 2020 10:18:49 -0400 Message-Id: <20200502141849.7465-1-laoar.shao@gmail.com> X-Mailer: git-send-email 2.18.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, 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 --- mm/memcontrol.c | 2 ++ 1 file changed, 2 insertions(+) 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));