Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp742720pxf; Wed, 10 Mar 2021 17:02:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMTR09EAGuz6T9OKANI4zfKC+Fd9VIXz8lVol5ts8VRZuVnQPDUYvw2+t0GyKhKoIGt7Qf X-Received: by 2002:a17:907:7664:: with SMTP id kk4mr613600ejc.352.1615424529347; Wed, 10 Mar 2021 17:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615424529; cv=none; d=google.com; s=arc-20160816; b=T+v+sguNiGxzUEWB4X5VVG9vQhxIV/+m90lREL8DlE6hx6uS5rjMgzTH5MeThTWKou SXkAJvLcgAxVQ2UkDeCtbNe3LF1D/EMaK3NxDx9vZTA2lRXcyH/Dv9+jWOx67TIRSxtK y5avuhNkycp2H2A8DGMWQPzklzAtEVGhZpUXesI+4iT+17+E987/zFMF8k5hjq07cVQT VwBD9/xk8yNcG8O3u12qDE3YmVNxerRVF7l919NSn1wro9c+AX2DuzHAOjJwN+kS9rRe 2TNmZLmbynrn9aErxKgRQnvbuVcXjHeELcEsg+/gMMbKPShBCjVv7MLECmurG13ANLS/ pqNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CrfiISBeWcM0aghiGCmSAIV9dxcofoH89E4I2n3l8ko=; b=WIgFJDfGJzvZc09TA7xSA+0w+5Y9aizeMINDBLBkfXSBSSQGODCgmFTr7DE75M5W1T wagY/66s3xR0Qz5bB9ZC4ub1t2/MFIcHYWfVPCuCYRrHSVo7+sCHuPa4UTB6VISQqOfW GPIABXc1wAk/gsg2dt7Pw6Gw7kB7/gWHGWY06s03p3igyJeJ3aFCSzx8AZU+e3zDw0OD v+Xqk8bgKdJMDx47wS+pBc100PqPC9w+cgFZIeX63iLnseYBDUYeDg5SuTGoTC3RQiOS RhbwC6H2gcFuFaNyDmfNelni5jtqGjwDEhvTjsdJV9FUu6bJiXCuYC05VuH0p+SXDbLQ VMRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="fOC/xkbo"; 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 j2si568737ejx.646.2021.03.10.17.01.47; Wed, 10 Mar 2021 17:02:09 -0800 (PST) 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="fOC/xkbo"; 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 S229570AbhCKA6U (ORCPT + 99 others); Wed, 10 Mar 2021 19:58:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbhCKA6D (ORCPT ); Wed, 10 Mar 2021 19:58:03 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893E2C061574 for ; Wed, 10 Mar 2021 16:58:02 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id d3so36788926lfg.10 for ; Wed, 10 Mar 2021 16:58:02 -0800 (PST) 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=CrfiISBeWcM0aghiGCmSAIV9dxcofoH89E4I2n3l8ko=; b=fOC/xkbof84GSdDqGTqMuAYyiGl9AT6rEWRfjjF30HZBilUqm25UMz9Zh8pezHE+lY VrwLXmP2U2XJl0HYbYqDhCd5fZ1oImvNq3Uz259jpqJqG0sNu6Yr/EMbuhSJTMM9nRKo euin/u8aCf9vResvfQ5bxbg5AVU4TpRd1zmSok1+VFvnE1LeQKELyQ1cJtxjR4KKwKgm bSuSsrm1kh9KROHeh4624u58UIG8aXB27Z4Fp/xDPfcCAvlb4c9XPNnRlz3zbk0gXZi1 mpCjKqw//YoPe2Khl+6Qx7ux47X7Eg47OQuDQss9gnQc55vAUhKdytduEXUN2s8bdYkp U2nQ== 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=CrfiISBeWcM0aghiGCmSAIV9dxcofoH89E4I2n3l8ko=; b=pAl8VZlYCVAhoKYm/yCOHNHb1tW0ZmvtYfWoVg59iHL0FzHxybe19vyfkGKBaVp9ZJ nwK8S6buLAfMyJ3lelTuTjKTkwHIFUMwPx1jtwPARZvdgvvFc4bFfBcrP13luSBiytn7 OF0E93n6pViv78YyPx2Rh8+pqcNwAzqN9VC9qJcFztuygZqMcMkMcRQqQZyuFFbGTWRT zzjLQPy3qV7wAEwDurK4sr0b+J5Js1m1Tae+WhwuSXlbU2CIhbglR1+1OK9ovEss+Q0V oM9Hhn/6cfkC1tzKLuzpQIU68Pxc93lgCBte9IUuDmfkZN35bWTJLWgc5SwHm8OuJhix aa5Q== X-Gm-Message-State: AOAM532nzUrm+eZk6sbSiezS0g9sRBN4XcDBhAI6hpOEY6Jykxn1Z0a8 g82I3yOAG9gMEwq5QlYs3J207ZigjsSxk97qRTGsNw== X-Received: by 2002:a19:3804:: with SMTP id f4mr721936lfa.117.1615424280844; Wed, 10 Mar 2021 16:58:00 -0800 (PST) MIME-Version: 1.0 References: <20210311004449.1170308-1-ying.huang@intel.com> In-Reply-To: <20210311004449.1170308-1-ying.huang@intel.com> From: Shakeel Butt Date: Wed, 10 Mar 2021 16:57:49 -0800 Message-ID: Subject: Re: [PATCH] vmscan: retry without cache trim mode if nothing scanned To: "Huang, Ying" , Tejun Heo Cc: Andrew Morton , Linux MM , LKML , Mel Gorman , Johannes Weiner , Vladimir Davydov , Michal Hocko , Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 4:47 PM Huang, Ying wrote: > > From: Huang Ying > > In shrink_node(), to determine whether to enable cache trim mode, the > LRU size is gotten via lruvec_page_state(). That gets the value from > a per-CPU counter (mem_cgroup_per_node->lruvec_stat[]). The error of > the per-CPU counter from CPU local counting and the descendant memory > cgroups may cause some issues. We run into this in 0-Day performance > test. > > 0-Day uses the RAM file system as root file system, so the number of > the reclaimable file pages is very small. In the swap testing, the > inactive file LRU list will become almost empty soon. But the size of > the inactive file LRU list gotten from the per-CPU counter may keep a > much larger value (say, 33, 50, etc.). This will enable cache trim > mode, but nothing can be scanned in fact. The following pattern > repeats for long time in the test, > > priority inactive_file_size cache_trim_mode > 12 33 0 > 11 33 0 > ... > 6 33 0 > 5 33 1 > ... > 1 33 1 > > That is, the cache_trim_mode will be enabled wrongly when the scan > priority decreases to 5. And the problem will not be recovered for > long time. > > It's hard to get the more accurate size of the inactive file list > without much more overhead. And it's hard to estimate the error of > the per-CPU counter too, because there may be many descendant memory > cgroups. But after the actual scanning, if nothing can be scanned > with the cache trim mode, it should be wrong to enable the cache trim > mode. So we can retry with the cache trim mode disabled. This patch > implement this policy. Instead of playing with the already complicated heuristics, we should improve the accuracy of the lruvec stats. Johannes already fixed the memcg stats using rstat infrastructure and Tejun has suggestions on how to use rstat infrastructure efficiently for lruvec stats at https://lore.kernel.org/linux-mm/YCFgr300eRiEZwpL@slm.duckdns.org/.