Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp89857ybj; Fri, 8 May 2020 07:11:23 -0700 (PDT) X-Google-Smtp-Source: APiQypL86nMdj4cTSDecdPGVHws1dTPVV6ArgVTSv3zVRL+oflDANUtDVCf3IRlrZdAsFywPbiWz X-Received: by 2002:adf:fec9:: with SMTP id q9mr3096010wrs.181.1588947083078; Fri, 08 May 2020 07:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588947083; cv=none; d=google.com; s=arc-20160816; b=CTV0wGtIJikl1FcBsilDg007ht+QbmNZcxjLB71buELCNJw7NUDY6jZW5XQTLhf1SP 3SozaKAKRdX1ePIN7jvLpVSPvImZ/DH8ubHTc4iyAA6aTRz3kQACWE6O2aT5IIPZzAUk 5LpYdWV+UJ1Y6WDRgarv+/ivWOOftmXZLKvXOkmImxWdv6QOcw1HNIzjJKIdzPRUL1l8 JOxyrYCswORa4jKJ+V3JeuiQ9OycAHBdgmfamgvDgJ65rJQkO68goJoSC7e3yyWWU4xf EjycFIttg6QDausBnYsP0wFncwnfuMMHapeH1Y0k1TStfAT/UrJfQcTmLSFciOVoVMM+ dgYQ== 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=haWmS+1+Op4dfd1PUhzKPboaEpLi6w7LL8kma7vTFIQ=; b=v9WYudhV2IHp2j4v9pJ8Scx9ta2Y60bFl6kW9vNM0rVhiEnG+omnyj0n70FVasEhTI g8HHJvRK+kw3A9V8pLEJq90VrKT4FRrY6u76koWxyzKTD9mYPB490y/AKvmcymgs57kT jN5ckl8equSWfH9E0RPrnhML79APuuH8pNhKO0ao7oQZaPsCwcdLgMvJUJIeWfF0NN0c tUFeenP8y6AIyGk3YnfiJSteFCfXtX6sM+qvOhwTU+ADQunHYsRq4fYfo4JqWKiX6Kxq 8hbz8c/AjQkhnrGgf8MJf4sTORUlQU/EEOQ/qx6yt3mGQdMwKARfBvjgZzBovHKLMfsd HbSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ceRHV0SN; 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 w8si985548eju.477.2020.05.08.07.10.59; Fri, 08 May 2020 07:11:23 -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=ceRHV0SN; 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 S1727116AbgEHOGA (ORCPT + 99 others); Fri, 8 May 2020 10:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726636AbgEHOF7 (ORCPT ); Fri, 8 May 2020 10:05:59 -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 79A2EC05BD43 for ; Fri, 8 May 2020 07:05:59 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id h26so1512443lfg.6 for ; Fri, 08 May 2020 07:05:59 -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=haWmS+1+Op4dfd1PUhzKPboaEpLi6w7LL8kma7vTFIQ=; b=ceRHV0SNg4h4ryrKrtL+3goG0C5w1BGZ6KqlDlRV87kNxeqK3n/RrJb77F/LD7K2kA ajA4v6WXyozZqr4ooDAaotW6Gmp4FSRZRsz+KBrUVuwipH9+gQAH66kcLQltW6kzCgAX k56pf083vAds2fUez4gXK949rfm5yqXY7RJ9ZhCN852Nn1+lrsqAfTmNSxQxGKLJsu1p xPNV21RUEmi+zihVeAo/MEyl18ZwkrvqtQ4oXiJ8L4EuE5auYTVNqBH9v8xXv+OBWUV9 +qXN+nn3ZxbaTQqQxc4yYAZK/ULG64bAfRo4PAypAXFuoM8Cn8KuLEWp7sW/DjSu70kd egLw== 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=haWmS+1+Op4dfd1PUhzKPboaEpLi6w7LL8kma7vTFIQ=; b=tOIdt5uXadPU5Y658VpHtgd1qAxbuJBMl5UIaDm0obk0gSB91OO0X3NsMKvwmfyYQ4 ht+O0oPiQJ/o6lsv8go32Op+fUTz3QaxOtguu0VwBgCyZQfMWDoSVu0zMW9mOKAXZQ1K YKhT/VRTEprIPrzlJJaU4jbaYaM+sXeE5IfAmN9PZiBnKYlqv41R4jwqWPDbP0grGJPo wAEIvA95f9mKI8GQHRh1b1nP6cOFAIHy98stNHT3pkHJ6/SmebDxcGY/BQys0yQca+Wa ykexEGuI+PWJ0Z7y/u8BjWufoWpG2q2hUxVUTCcrmgKkSXOzWPYvGBYMno0vqiyYOpCu xR9A== X-Gm-Message-State: AOAM532K5Vsk2oFauf/L1tJFMpnfL195n55h7L8pr5uGMHAv8JTfNbz/ 2hVsEAQ9+QgDqI8ZlYD7MoKwxXJW2vJrauxQdAs4/g== X-Received: by 2002:a19:f512:: with SMTP id j18mr2007829lfb.33.1588946757557; Fri, 08 May 2020 07:05:57 -0700 (PDT) MIME-Version: 1.0 References: <20200507204913.18661-1-shakeelb@google.com> <20200508133833.GA181181@cmpxchg.org> In-Reply-To: <20200508133833.GA181181@cmpxchg.org> From: Shakeel Butt Date: Fri, 8 May 2020 07:05:46 -0700 Message-ID: Subject: Re: [PATCH] mm: vmscan: consistent update to pgsteal and pgscan To: Johannes Weiner Cc: Yafang Shao , Mel Gorman , 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 6:38 AM Johannes Weiner wrote: > > On Fri, May 08, 2020 at 06:25:14AM -0700, Shakeel Butt wrote: > > 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. > > I'm in the same boat. It's useful to have activity that happens purely > due to machine capacity rather than localized activity that happens > due to the limits throughout the cgroup tree. > > > Don't you need pgrefill in addition to pgscan and pgsteal to get the > > full picture of the reclaim activity? > > I actually almost never look at pgrefill. > Nowadays we are looking at reclaim cost on high utilization machines/devices and noticed that rmap walk takes more than 60/70% of the CPU cost of the reclaim. Kernel does rmap walks in shrink_active_list and shrink_page_list and pgscan and pgrefill are good approximations of the number of rmap walks during a reclaim. > > > 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. > > How would you feel about adding memory.stat at the root cgroup level? > Actually I would prefer adding memory.stat at the root cgroup level as you noted below that more use-cases would benefit from it. > There are subtle differences between /proc/vmstat and memory.stat, and > cgroup-aware code that wants to watch the full hierarchy currently has > to know about these intricacies and translate semantics back and forth. > > Generally having the fully recursive memory.stat at the root level > could help a broader range of usecases. Thanks for the feedback. I will send the patch with the additional motivation.