Received: by 2002:a25:ab0e:0:0:0:0:0 with SMTP id u14csp6627055ybi; Wed, 12 Feb 2020 17:49:51 -0800 (PST) X-Google-Smtp-Source: APXvYqybvvBrl7fQxdDm2VPMiiK0MfFaGDXkG5v0ZEnv0WgbYTM3n/44eV8sbdN5RgsJV8LVC+C1 X-Received: by 2002:a9d:65c1:: with SMTP id z1mr12119716oth.180.1581558591086; Wed, 12 Feb 2020 17:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581558591; cv=none; d=google.com; s=arc-20160816; b=rypAFLHLLvtvKywCYRQIKBTUlB9hBcLHQ8SSRSa8m/imaWJkCMgYCsgFG5YLo35oJh QNMJ2jfXMcCcLTEf0LS5xPOq/upy6RrY3qG+vIK7kKBA5SANd6CqctPzW8gbhnMKDzXe kV+z2wPoWn9wI/FvWoCOvLdQWqZrbx1eyxqAVzHUU8LvwDScG9v64rTq/mfUizRiwM5z 8wrI93/3QDST7nje39XqWh0YMsewH/gUPb3XirLdQuV8FD8qTNu2qdJ28DnxOLMmBiCx O/H0iWuuwHFUX2zEIS5UoxRTup1eJDyqMOcC5jez9Ds2bgbNQO85Jfb43/Kk/JpErRwN Zrgg== 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=NcupujMoNZ+lhM7+9GoPlR+Ij7mhzM+rhSEsy6lC7Ik=; b=a1Ya/cQYtbmhnJlxBfhh1jBZeywP0r76f/wtB+RVadDq60Q91j0uSV7YMwKS3ZGxPl 9y+p1+SF4avPHbWIQGPHziUPbFG2BjF1zXjQLlylO55KvY8zwk6TsY0k5577QlUurQe7 rUKx+QQ+g4q3DhVz9LTL5Qk2gbXIjsXLprQ1QvxiM2wUsRl6FYBjfMgXE0KX4gGOxrtr I2pTPN5xNdJYI2SqAMMURwH/gNk/pEd5ag6ArPM83JJAL8gP1SyAX0kK4/opUy3+nVJJ HIMJ3k4+EDU40Pqjn5yr725+C5Kori4YGww4eaoyLvZm5hB4PwzQiG9zxfInoCyWk22E IJvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ss6Lnwur; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k205si458315oib.64.2020.02.12.17.49.21; Wed, 12 Feb 2020 17:49:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ss6Lnwur; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729389AbgBMBsG (ORCPT + 99 others); Wed, 12 Feb 2020 20:48:06 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:45755 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729289AbgBMBsG (ORCPT ); Wed, 12 Feb 2020 20:48:06 -0500 Received: by mail-io1-f67.google.com with SMTP id i11so4576630ioi.12; Wed, 12 Feb 2020 17:48:05 -0800 (PST) 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=NcupujMoNZ+lhM7+9GoPlR+Ij7mhzM+rhSEsy6lC7Ik=; b=Ss6Lnwurj/uXI0dVZEJyGvlmTQz36Vl5AU9orRG34T+RQ/yrm8Sa/Pyjqc03UKVRiZ NwZsF052DjppBJaKpAY2JiyDZWKz1nKX0olUFwP2ddsxBW+iK0U4vTunmy1rxO7c6v1B qRzLV/Rlct/AbvpVx4BhaSqsOmcy9UhqRwQqtID7p5gaKk9qHQfASNQYzuLCn8RZrvW9 lBUkoPPdBwahHCL3uIYZW4EeIxT62fsE4iFR5R8gbjhT028SJFzGLdoXuHFdRMfJofuD tdS/o6Y37PwBdAOXm1ZfnXxwL0inuKGDQoIpET6WWcooE0xDu9SaHh3BSzP9B/PN/+Ab 0zIw== 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=NcupujMoNZ+lhM7+9GoPlR+Ij7mhzM+rhSEsy6lC7Ik=; b=FOPMwRGNJ/ISWzBGdM/Atnl3xLaMLWdpuwsQ/FEkveBvg5JrnWosDEFKyE1RtQG/mG rwPciRyXj8NsQs7oBx2jYlTWhJI5lETT2uY9bSMnY778FSjHj0POqIbjcNA8KwSFq64L M1wJoW0DiKJwS/IDZSevWEtGBumzfT83+vYpnjgwUCJCVaSkm+CXVbeCssYmtrXul3mT ZfhwvrvOBUU9F3YOaJ50DfMijXrNPPBY+u4usuCHhLLhFZtfhek6sILmluAr6V3N8ved 9AxMNggbBhDmPt+w4zKhQUhEhkGQ2JIb5+Gwv4p3ixPjofxuCz5A4/4FoQ6DIeFTTx90 hckQ== X-Gm-Message-State: APjAAAWh6TvJo+oi1TuAIQi2KEBBGrAd8Bb44JzuQS4Aaj86K7X3XReH jz6AFwj3RZPcv5brWwqolTjZlJ01eXr4ktslMbU= X-Received: by 2002:a5d:8146:: with SMTP id f6mr19522873ioo.93.1581558485520; Wed, 12 Feb 2020 17:48:05 -0800 (PST) MIME-Version: 1.0 References: <20200211175507.178100-1-hannes@cmpxchg.org> <20200212164235.GB180867@cmpxchg.org> In-Reply-To: <20200212164235.GB180867@cmpxchg.org> From: Yafang Shao Date: Thu, 13 Feb 2020 09:47:29 +0800 Message-ID: Subject: Re: [PATCH] vfs: keep inodes with page cache off the inode shrinker LRU To: Johannes Weiner Cc: linux-fsdevel@vger.kernel.org, Linux MM , LKML , Dave Chinner , Michal Hocko , Roman Gushchin , Andrew Morton , Linus Torvalds , Al Viro , Kernel Team 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 Thu, Feb 13, 2020 at 12:42 AM Johannes Weiner wrote: > > On Wed, Feb 12, 2020 at 08:25:45PM +0800, Yafang Shao wrote: > > On Wed, Feb 12, 2020 at 1:55 AM Johannes Weiner wrote: > > > Another variant of this problem was recently observed, where the > > > kernel violates cgroups' memory.low protection settings and reclaims > > > page cache way beyond the configured thresholds. It was followed by a > > > proposal of a modified form of the reverted commit above, that > > > implements memory.low-sensitive shrinker skipping over populated > > > inodes on the LRU [1]. However, this proposal continues to run the > > > risk of attracting disproportionate reclaim pressure to a pool of > > > still-used inodes, > > > > Hi Johannes, > > > > If you really think that is a risk, what about bellow additional patch > > to fix this risk ? > > > > diff --git a/fs/inode.c b/fs/inode.c > > index 80dddbc..61862d9 100644 > > --- a/fs/inode.c > > +++ b/fs/inode.c > > @@ -760,7 +760,7 @@ static bool memcg_can_reclaim_inode(struct inode *inode, > > goto out; > > > > cgroup_size = mem_cgroup_size(memcg); > > - if (inode->i_data.nrpages + protection >= cgroup_size) > > + if (inode->i_data.nrpages) > > reclaimable = false; > > > > out: > > > > With this additional patch, we skip all inodes in this memcg until all > > its page cache pages are reclaimed. > > Well that's something we've tried and had to revert because it caused > issues in slab reclaim. See the History part of my changelog. > You misuderstood it. The reverted patch skips all inodes in the system, while this patch only works when you turn on memcg.{min, low} protection. IOW, that is not a default behavior, while it only works when you want it and only effect your targeted memcg rather than the whole system. > > > while not addressing the more generic reclaim > > > inversion problem outside of a very specific cgroup application. > > > > > > > But I have a different understanding. This method works like a > > knob. If you really care about your workingset (data), you should > > turn it on (i.e. by using memcg protection to protect them), while > > if you don't care about your workingset (data) then you'd better > > turn it off. That would be more flexible. Regaring your case in the > > commit log, why not protect your linux git tree with memcg > > protection ? > > I can't imagine a scenario where I *wouldn't* care about my > workingset, though. Why should it be opt-in, not the default? Because the default behavior has caused the XFS performace hit. (I haven't checked your patch carefully, so I don't know whehter your patch fix it yet.) Thanks Yafang