Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1059170ybj; Thu, 7 May 2020 13:53:39 -0700 (PDT) X-Google-Smtp-Source: APiQypL6On7zbYc4YlLDHkKZQ8woEDz6bW9QLQPVKsHZnlp8Xq3hGeDTJLFZzYLuuNg2g5TQDS9l X-Received: by 2002:a17:906:7e5a:: with SMTP id z26mr14519419ejr.168.1588884818814; Thu, 07 May 2020 13:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588884818; cv=none; d=google.com; s=arc-20160816; b=mQQWcq6cNRavEsbuJy2dbJ2OCVTpZX51rjVj2AM1Ptb1Ud5tgMSzb5n+Yp0n6pA8zt VhD9/8YGLlYt6eILkGn85O+Ms8xNKK2hgwv/ufHN/3ZsoIwf6mR7Rusci4GcMBHiO+2N 5HnYrYyVR32gKq4hdk2KYQbmTWCp3qG9NXCM/qk/lDsKfYUsEyAO1UtI+1SMeuv8nT+U cn2/y8FI6rLw4cdry3YwhnmQMV9tE3oIU6U1v+F0NI2QnS7P7sY/Kxmkc/Luqp963yFB oSKZoW4mo8mA/ihBZ4UFF+nKFUQMXREuwxpaSD8b98m5nWIOZtDtUsbWdZLodU+HxENx g7lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=N2ff8TXAhQSelwb8Fo/2whe057WE75uOPyG09EBawpk=; b=Vn3TlVs6q5Aj+GUI7yDfIZ1O4o/ci8Ffw54+6Hr/Bqmjz7xKIWLCVv4KndH5r1bRnF F/dOIqpgOJYUG4v3oih1gPQP0P/+1x2xEczyGhLoZCQdB/y208GuWzu9m6vBoCl0zZo2 CSXIfL34ZqEfUzM+NNqz6sAhaaWlYowTKLLqnRziueiV58D1RaTpwSirwG8+3Q0o1625 ukko1bXj0xzdp0RSLEv85u6gbvKnDYs6/SOzNvkVUGBdad9Kr/p8PV6k0m+O8e8bgJXO gFfTLB+O+I8Id1OLVK1HLlUMQHSaGWLYU6TYZn+9oQBdcGP+c1Yj5c8FmRcJ7+goeYmd 2nrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ug0Afhxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si4025803edf.513.2020.05.07.13.53.15; Thu, 07 May 2020 13:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ug0Afhxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726476AbgEGUtX (ORCPT + 99 others); Thu, 7 May 2020 16:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726268AbgEGUtW (ORCPT ); Thu, 7 May 2020 16:49:22 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9AAEC05BD43 for ; Thu, 7 May 2020 13:49:23 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id z14so7116552qvv.6 for ; Thu, 07 May 2020 13:49:23 -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=sMX5D00O//tuIz6Lc9ISPVoAnki/LBIztNkg20c4u3R0UNI4dZ28MdVxlSS9OcHPab PJd3uEw4OJGOY+OsPvCCCS4efuTpsSJMSOgc2xRBpg8iDEjoKEXVPuGRuRKIGvgtaKy5 9xSfjfWB4u5xT0uXg3FKgHLnlN6y7lILWlADd5xzEhaNYvtImA+RX9aGN01gC15fbAoR MjZNdtEbOAobkaW8rk3T1id4D6iO5uq9ZP/vV8w+gNVDYZctENjBhVn1je4A4JhDF2Km miOMP/zT7Dblg97CWD11oVe5ANGjNS34L09R34Nf4NzYWKmgoNhfMxwHlYIYDU/BPJ6w L7Dw== X-Gm-Message-State: AGi0PuZbzOmet5ug9GUjNy3Ig9C/lm8tKfxDSvUrFLknlrWEYTzvHMkL lpDA5hYhYWSxYjL9eRip0Ar5dakhe9QsHA== 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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