Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp56239ybj; Fri, 8 May 2020 06:27:07 -0700 (PDT) X-Google-Smtp-Source: APiQypKEEQVBf2Y944eNDyNXa0OOGvvkKs/MjKEo1Tz/BgT4Nqkpl7a8tKny89NyWL/VfeUb9+Gd X-Received: by 2002:aa7:d7d8:: with SMTP id e24mr2246376eds.215.1588944427695; Fri, 08 May 2020 06:27:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588944427; cv=none; d=google.com; s=arc-20160816; b=D5tXVFJ2w4edjXLhcglmbte2SS05GXaDV47X21tNCGMmBZimDsANAsHRYprSqmPwjr BwOxLBs+nrVkZBcGzXfC/wzOPcEdrRw7L+8cQk13yK0WM8wSknEuDTpZb+AGMr+TLfGX ReISMVaf9V8zKi+dEZc8pKgASPt6SB4Xo0VybFM1Psm9Gc6+8jg2ojbXge1MSZjkJhzh T/+b+pPqYWI0WrWmjq1ZlCFB8F1GoLWd28OrefU8kIbjqks1KmqhXiwiebdpYxfYCZO9 CcUcxypewr9N7fNV4VCFEvZv1EKgrbPzHXCZTBqJ0lmFBQMYrTMY4g8J99iICt78YDOw 2lcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sYFngmQuiKj7kYwyJTK5tfHqOHjbxR0GHIB5m/n0A4s=; b=YZKLD0Ra6PesC9Y23CU8wkl2qosGmTSHwreQ2goF2oo+R7uf5vH+XtmRgS53L9DSDQ kXFfHrTCe+8NsRyQFn1BCL0B6ZziQnjg9UCjYjnOcRxgHWkD5v3M1xOg5c8HAt9S36WT a90HxhFGaRryKtY5Pc01G6Qb7Dxa5pfpxpuYfT33IZAbGbcFFjdf+RhQLrZ1O/A5XtWI uIjM0qj/fKinDK3GAfbiCCE0Sida9u+GdaQycUVRxYJwOEmbeb52q3GOQzJnrYHjRmPK NxjzBt9f8XlOcrcY+sx9/FvBlnpBPBsUCEo5t10kb+OWFmZG2ndDo0l0546uSmB4mYzO d9Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Cf51VBGp; 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 kt5si984239ejb.455.2020.05.08.06.26.44; Fri, 08 May 2020 06:27:07 -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=Cf51VBGp; 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 S1727794AbgEHNZ3 (ORCPT + 99 others); Fri, 8 May 2020 09:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726736AbgEHNZ2 (ORCPT ); Fri, 8 May 2020 09:25:28 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2944EC05BD43 for ; Fri, 8 May 2020 06:25:28 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id z22so1415944lfd.0 for ; Fri, 08 May 2020 06:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sYFngmQuiKj7kYwyJTK5tfHqOHjbxR0GHIB5m/n0A4s=; b=Cf51VBGpTVncNyypzafaMswErlBVVkKsuBZHqtPhOLPKowx6U319ToIwP6m5e6mpRh reAGFanDQBRdo0yq41C6od6xAcZ3/qy1z3Bn4i8/fn9QosxBRl1AWBOQsEvxs/PXTKSK WYEEG4rCEnNKBoipBN5aEhix/DSOgIhR0Bq3b9LfzMFlV/0L5H+QXWEVBsbUzqXrvVIu UJHUplKW+tyy4K5X1A9O2cOqWFbdEjE1XlleUvVb9Lg1AImgfisqVJB002wj0XqGmRdi tZKlPOwCqdV29jhgvG6M3tYzkVD3sYNM5uPHzsEL0GGBYsGYGKwvTh0a3K0cjHgZxayu 4tAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sYFngmQuiKj7kYwyJTK5tfHqOHjbxR0GHIB5m/n0A4s=; b=UMhac4+wJ2wt5rjh7p1f5QJ8OvGlJ0tyecOi/n6j1jLLAy+QEW+zkfTVJo41A0fHbI 4QV/nc4wQ6fVeU1JtD4YGC14WXynIkNOCPf74SkSsmODA+Awm1jOe1S+XSOrrYlGO2Qi 7yN9qeASZu3iFoxUv389n37+KaKPd7q6dr/vvIgiib1bLBbU4QyQ3VPNVfAyxo5/fK5m zGwRhQZq+6Vm0Ln875FYmpInLnX24Wq6UIIc3ioVeeWQKFaAdfQSUo6EqeLqKtQsg+f3 mH19y5VtEoPRfbUZ472VihYviQJiDB4Ed7aCEQrF9XaeCvL5EZ4xa6QECgi7sTL8q+n2 1foQ== X-Gm-Message-State: AOAM5332xNMe2w243Dm4SdiaTqDwWq+PfscDcePtYMYh7bnXMWTNFbfD ppW4Vhh1WbgaBKuqBZxqRP/LKEWgJwPtL57adrOiVw== X-Received: by 2002:a19:ee19:: with SMTP id g25mr1933226lfb.124.1588944325982; Fri, 08 May 2020 06:25:25 -0700 (PDT) MIME-Version: 1.0 References: <20200507204913.18661-1-shakeelb@google.com> In-Reply-To: From: Shakeel Butt Date: Fri, 8 May 2020 06:25:14 -0700 Message-ID: Subject: Re: [PATCH] mm: vmscan: consistent update to pgsteal and pgscan To: Yafang Shao Cc: Mel Gorman , Johannes Weiner , Roman Gushchin , Michal Hocko , Andrew Morton , Linux MM , LKML 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 On Fri, May 8, 2020 at 3:34 AM Yafang Shao wrote: > > On Fri, May 8, 2020 at 4:49 AM Shakeel Butt wrote: > > > > 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. > > > > Hi Shakeel, > > We always use pgscan and pgsteal for monitoring the system level > memory pressure, for example, by using sysstat(sar) or some other > monitor tools. Don't you need pgrefill in addition to pgscan and pgsteal to get the full picture of the reclaim activity? > But with this change, these two counters include the memcg pressure as > well. It is not easy to know whether the pgscan and pgsteal are caused > by system level pressure or only some specific memcgs reaching their > memory limit. > > How about adding cgroup_reclaim() to pgrefill as well ? > I am looking for all the reclaim activity on the system. Adding !cgroup_reclaim to pgrefill will skip the cgroup reclaim activity. Maybe adding pgsteal_cgroup and pgscan_cgroup would be better. > > 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 > > > > > > > -- > Thanks > Yafang