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=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 B8682C47247 for ; Fri, 8 May 2020 10:34:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6058720708 for ; Fri, 8 May 2020 10:34:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IB+Tw4YA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6058720708 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 BE3DA8E0005; Fri, 8 May 2020 06:34:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6CC28E0003; Fri, 8 May 2020 06:34:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A38378E0005; Fri, 8 May 2020 06:34:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 88A8D8E0003 for ; Fri, 8 May 2020 06:34:41 -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 4256845B3 for ; Fri, 8 May 2020 10:34:41 +0000 (UTC) X-FDA: 76793193162.16.bread45_bc7f9651f94a X-HE-Tag: bread45_bc7f9651f94a X-Filterd-Recvd-Size: 5539 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 May 2020 10:34:40 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id k18so1342361ion.0 for ; Fri, 08 May 2020 03:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z4Bt4bjxehMk3gJfl5cWg7LmoeINB3VH5yh3MCR/E2Q=; b=IB+Tw4YAIP5htJFb4/RhOt9cQtCj/gsj2H9De6ZNAWkRyFbjtd6Vs8RePxxykMGA8L JRS0WPL4MGlNK0Gb8kgVF6VgTkbUOC+71977cB3oeolZfa65/5G/9lUerxqT96nYElHo OmET902itAyloMrhsJCpPFDXFZIx2/4zHmpRfMEcFVBt8Z0gKaxbBoQOtKIAWvG8To7a FB6SOgxUIQhYEoheTiXlKQPHWZHtx3cIYqtvd2JWxpu82TF0Gh+/sq/sxkYiPc+Rne4z ScKlCcw7xInfTJJCeotQF1HuaSoerJrRewLKrBYIJNSf1C7fnGIl0DrtxWbbI9Zkffvx Py1A== 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=z4Bt4bjxehMk3gJfl5cWg7LmoeINB3VH5yh3MCR/E2Q=; b=PEaKou+kkex/3+gBVyAXG4+65dpIih/SZjllurlXZtLO/WAn2F08vFgrC65bdVxyg4 CAJVB4x6jfpMSD0dBUrQOkW3rf0tItS3TFg0TUKmoR13/KWKwI7jhiMEJ8C2N4rQNx7I S7yikM3Ye5YWu5VEnFyYpZQ/WcWgrnMtEy0GDxzsrxvwk2koCRcPnMrT/xrB8MIhEXj2 ocPFduTWDa7UYRD1iw9OFUnFQaCFoSzaZp2PkC2U2V+R34w/8fYYqb0MJWJVvxomMIIR CrK4Y5dk6EGNRN52ns/WVQvZJskicQ53OxLBagQuSqa0+V5oQkI0Q3O7vCR+/eXMLhxt wK5g== X-Gm-Message-State: AGi0Pua27L4pjqPjzUlbjGWR+qXh1K7LW6diSoB9gqL4+c1KhTE/fU2K 8MvedW4Nc0IhXGLtAFszZ62ZK1WJtKQQvCyPqog= X-Google-Smtp-Source: APiQypKzpPamnAO06g21CAM18FQuJ4zAyl/GSvUXDhfKWGcUema4h82c62k8ni/2vZN2j8k1/CR6Kw6QcXZRuPodTaA= X-Received: by 2002:a02:a90e:: with SMTP id n14mr1835735jam.97.1588934080300; Fri, 08 May 2020 03:34:40 -0700 (PDT) MIME-Version: 1.0 References: <20200507204913.18661-1-shakeelb@google.com> In-Reply-To: <20200507204913.18661-1-shakeelb@google.com> From: Yafang Shao Date: Fri, 8 May 2020 18:34:04 +0800 Message-ID: Subject: Re: [PATCH] mm: vmscan: consistent update to pgsteal and pgscan To: Shakeel Butt Cc: Mel Gorman , Johannes Weiner , Roman Gushchin , Michal Hocko , Andrew Morton , Linux MM , LKML 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: 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. 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 ? > 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