From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0646C38A2A for ; Thu, 7 May 2020 20:49:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6BDD420725 for ; Thu, 7 May 2020 20:49:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ug0Afhxk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BDD420725 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CCE7B900004; Thu, 7 May 2020 16:49:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7EFB900002; Thu, 7 May 2020 16:49:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6DDA900004; Thu, 7 May 2020 16:49:23 -0400 (EDT) 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 9D705900002 for ; Thu, 7 May 2020 16:49:23 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5E786EFE7 for ; Thu, 7 May 2020 20:49:23 +0000 (UTC) X-FDA: 76791113406.16.north89_51ed19351f31c X-HE-Tag: north89_51ed19351f31c X-Filterd-Recvd-Size: 4615 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 20:49:22 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id p126so7131005qke.8 for ; Thu, 07 May 2020 13:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=N2ff8TXAhQSelwb8Fo/2whe057WE75uOPyG09EBawpk=; b=ug0AfhxkFYxV7gPwZQUiO1TH3mLYMXaH6iQJmRt4l4dAOkKMo1p8glAwchEJSmd48c KO6FfYEFXmZWE81BIC9AelKPV7tepn0+Ftyaib5noC4g13aPBsyAyMdxgvKHwAfQGO1v /vVJqS1ZifkmreEOPNH/fBb0pIBBQzOBDGmV5r3SYopfhtu8NQep9Zx6wo2i+p6uof5f arI5Xy212yrTpsSdUjgBM+SB60lQWQE4Ih4L+qjVG+DoXOQw5TjVQIFXe0UYJMfm83Ej Hmmdem0OFwI/EwortJyPaS8KM+VjNt2vbRqfIIYMkolXyGcVgDuhhkk0U2bBr7SJPL4D G7QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=N2ff8TXAhQSelwb8Fo/2whe057WE75uOPyG09EBawpk=; b=BUBJQt/7qX6DIXFG71gZJPnvQi9iKmdIemIzOUoH1lAxlqLB2ZgLCa13vl+otZqx2i hcwYK4U+Wc+EN4sfFJni+8hoXKwwlDIzTBwg5wJoc6D/oWK/FmSMIkVEzTCXIoA9z/je FY9eQ0T2p4R1TtDpMrTNXrwoWhxDuQOitv+Yi70UZjmtU6UaWpMyDorKy3F0ZgiLWuqe MRbZwXYkGvsimt3KVb1TvCZVytyGQ9/XnzsZjfzAmByBS75aK/9b02Oq9ljUCKnMumtJ hymLc507zAaMqGLLXjl7Pb22uvM1nNfZ65MHStYN+4ue+sDbDVKcWIMH1uNxopXp7AJB R20A== X-Gm-Message-State: AGi0PuZtMzjUjQOCVwoQkw145Rpjes1Orst270GB0cejcaZxSVnkJ09M UtqJkjjRkqocbkxtaLp6LJwVEtgkIo9WOg== X-Google-Smtp-Source: APiQypLIwmOebFUIMyZG3XpyW3XxAzQzjw/dvg2VWxnQ01/+jF/bRCFmduwTX9Bdk6dvzmjtIRNXl65ogssE3Q== X-Received: by 2002:a37:aac5:: with SMTP id t188mr16318525qke.393.1588884562180; Thu, 07 May 2020 13:49:22 -0700 (PDT) Date: Thu, 7 May 2020 13:49:13 -0700 Message-Id: <20200507204913.18661-1-shakeelb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog Subject: [PATCH] mm: vmscan: consistent update to pgsteal and pgscan From: Shakeel Butt To: Mel Gorman , Johannes Weiner , Roman Gushchin , Michal Hocko Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt Content-Type: text/plain; charset="UTF-8" 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: One way to measure the efficiency of memory reclaim is to look at the ratio (pgscan+pfrefill)/pgsteal. However at the moment these stats are not updated consistently at the system level and the ratio of these are not very meaningful. The pgsteal and pgscan are updated for only global reclaim while pgrefill gets updated for global as well as cgroup reclaim. Please note that this difference is only for system level vmstats. The cgroup stats returned by memory.stat are actually consistent. The cgroup's pgsteal contains number of reclaimed pages for global as well as cgroup reclaim. So, one way to get the system level stats is to get these stats from root's memory.stat but root does not expose that interface. Also for !CONFIG_MEMCG machines /proc/vmstat is the only way to get these stats. So, make these stats consistent. Signed-off-by: Shakeel Butt --- mm/vmscan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index cc555903a332..51f7d1efc912 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1943,8 +1943,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, reclaim_stat->recent_scanned[file] += nr_taken; item = current_is_kswapd() ? PGSCAN_KSWAPD : PGSCAN_DIRECT; - if (!cgroup_reclaim(sc)) - __count_vm_events(item, nr_scanned); + __count_vm_events(item, nr_scanned); __count_memcg_events(lruvec_memcg(lruvec), item, nr_scanned); spin_unlock_irq(&pgdat->lru_lock); @@ -1957,8 +1956,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, spin_lock_irq(&pgdat->lru_lock); item = current_is_kswapd() ? PGSTEAL_KSWAPD : PGSTEAL_DIRECT; - if (!cgroup_reclaim(sc)) - __count_vm_events(item, nr_reclaimed); + __count_vm_events(item, nr_reclaimed); __count_memcg_events(lruvec_memcg(lruvec), item, nr_reclaimed); reclaim_stat->recent_rotated[0] += stat.nr_activate[0]; reclaim_stat->recent_rotated[1] += stat.nr_activate[1]; -- 2.26.2.526.g744177e7f7-goog