Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6369368ybv; Wed, 12 Feb 2020 10:53:10 -0800 (PST) X-Google-Smtp-Source: APXvYqxn455zYzvpKVWveE2hWFBpY9T9TId96TK5bMSTaHxuieio9aPZTy38R5Kn4L6KeWlRrs8w X-Received: by 2002:aca:2416:: with SMTP id n22mr279622oic.169.1581533590375; Wed, 12 Feb 2020 10:53:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581533590; cv=none; d=google.com; s=arc-20160816; b=xZy/ZQ7gzc3AlzHjnRQYjC8PPeORZ/3n3sqAyc8WQZAXn6ZXBKdFVhaqp4HIWpZlPD bhWGJjjhIJx3RtDzZ9QjqXfcVL8gCQb8EYbopf3xZ4om8XfP2J4qzlM+FsrgdXje/tQi lcZewtw+dZYmMLH9iZRVBhksq5qXAsCyLUJq3lb/OEsrNlraFZ64VOzQKz4tOgJZ7l/Y p3IvJy/2rn2L1Tb0nXwykAePv9mXEbvP0LqZV8MFfSw1cJW8Z0gQdYfsOR5P9Lx6PgyX EoF2OvaHLvadpEBboYb260LbPN9DIPO99XomNl4lL7zplh2tkefLeYxHgr5J4kp6P/95 rIcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ATjtj9uhoqbutpORm3twmVpl6WMWrzgSu/Pef3LSt8M=; b=Xn4xoTQkOWsmGPf4hygcOp281e9ep2e0lkMdUeuC6BWz+UO3YaM/zg8me7U+4+miEh tYRWeEJDdZtI6aOeTFDRL4hs8nD9q3bwrxqt+boFiaO+SnZCjdD2oL+5Vg/99buc6bOb WWl4oOUNXKlmZOTyjiQoXUFLMqyIMD0Pa/wiQ/MoqyYhvf5WhyAoXSOXOVzMNWaRKIdp 6OHJgYfanFKXGRfEoqZYFmYYEgXSe6PvnXdsl1Agv4GtphdjoHAp4z6d68s8YgdgdYfE WP/BICqS9d680joCoIyWtUvoMmmZgH1ju219KS0rmHj+0Sevr9SW9uOmXRa+mJZmuSkP MHFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=CeOgukl0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si3520156oie.151.2020.02.12.10.52.45; Wed, 12 Feb 2020 10:53:10 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=CeOgukl0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728840AbgBLSwN (ORCPT + 99 others); Wed, 12 Feb 2020 13:52:13 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:33897 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727054AbgBLSwN (ORCPT ); Wed, 12 Feb 2020 13:52:13 -0500 Received: by mail-qt1-f196.google.com with SMTP id h12so2431015qtu.1 for ; Wed, 12 Feb 2020 10:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ATjtj9uhoqbutpORm3twmVpl6WMWrzgSu/Pef3LSt8M=; b=CeOgukl06W8Hf4S1CRY2NUWa4z3u+gGuwykBw8jvgPAOCOEqPHzjcGo8O/kZffzk05 v6pDOrnWKwO2Uc0Pv9YX1Gf3iRrqs1SZe9rz76aKfncwXlCGXaX4/VL3H8LkvrFOhDl6 Q/W3RYEYvohBIFAMpqLUXnH67k2XGZf76gyo0SvoWnVwRbyTqyYt37GB5wSC2VoiiPF/ +vb+eYKGZOVcrxuDvI2ZJ5+appiYzcQnj8hBF1TDF+Bef5PGXixPhNinsokmZ0m4fFXU tK8oQWE7EEyOZ+8guuS0/DagdIi9RENopyLQ8RF+FKBFkgaLAf+f6D+ZfNhPgp1YAEdo Xkyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ATjtj9uhoqbutpORm3twmVpl6WMWrzgSu/Pef3LSt8M=; b=TW1EwHnX38s1nuHbbLI+Fl126Sg5LFv3fSFT+Eg3cVP9aQt5u0VrlmJXI661FJg9YQ pX9+2sr4P9Et7IoFn414U/oNMau2oD7epi99hKohC+e8Upn/RvThwUV6MyNixCmK7T3G D9Gb0DJPSQDiGb7w7FSqiYWv6QbqTuIcA6Nan3zcbYtfBVYOFdEi9+4Iir9J4fVjwb6M gDlnB/EoXBAQTEAsyt//kQuqH+sCBvGhliaGkD0lBIb3M4g4IRQ/7nYccunfmfIq0dBI z4+46io3Zlur+/biVpcF/e3ysGQ1gHofgCggaT1kG2z5A6WwimfDv7HpsSQ7AiX2HNck faQQ== X-Gm-Message-State: APjAAAV9V5foJa8QxFsJI290+9Vl073jElTAcxTwHMHZaMXlqUZ2R35i 70997P09vHcF8Z/nHvJts89wlg== X-Received: by 2002:ac8:365c:: with SMTP id n28mr8285715qtb.260.1581533530780; Wed, 12 Feb 2020 10:52:10 -0800 (PST) Received: from localhost ([2620:10d:c091:500::5a94]) by smtp.gmail.com with ESMTPSA id g53sm682746qtk.76.2020.02.12.10.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 10:52:09 -0800 (PST) Date: Wed, 12 Feb 2020 13:52:09 -0500 From: Johannes Weiner To: Andrew Morton Cc: Rik van Riel , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Chinner , Yafang Shao , Michal Hocko , Roman Gushchin , Linus Torvalds , Al Viro , kernel-team@fb.com Subject: Re: [PATCH] vfs: keep inodes with page cache off the inode shrinker LRU Message-ID: <20200212185209.GA206066@cmpxchg.org> References: <20200211175507.178100-1-hannes@cmpxchg.org> <29b6e848ff4ad69b55201751c9880921266ec7f4.camel@surriel.com> <20200211193101.GA178975@cmpxchg.org> <20200211154438.14ef129db412574c5576facf@linux-foundation.org> <20200212163540.GA180867@cmpxchg.org> <20200212102645.7b2e5b228048b6d22331e47d@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200212102645.7b2e5b228048b6d22331e47d@linux-foundation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 12, 2020 at 10:26:45AM -0800, Andrew Morton wrote: > On Wed, 12 Feb 2020 11:35:40 -0500 Johannes Weiner wrote: > > > Since the cache purging code was written for highmem scenarios, how > > about making it specific to CONFIG_HIGHMEM at least? > > Why do I have memories of suggesting this a couple of weeks ago ;) Sorry, you did. I went back and found your email now. It completely slipped my mind after that thread went off into another direction. > > That way we improve the situation for the more common setups, without > > regressing highmem configurations. And if somebody wanted to improve > > the CONFIG_HIGHMEM behavior as well, they could still do so. > > > > Somethig like the below delta on top of my patch? > > Does it need to be that complicated? What's wrong with > > --- a/fs/inode.c~a > +++ a/fs/inode.c > @@ -761,6 +761,10 @@ static enum lru_status inode_lru_isolate > return LRU_ROTATE; > } > > +#ifdef CONFIG_HIGHMEM > + /* > + * lengthy blah > + */ > if (inode_has_buffers(inode) || inode->i_data.nrpages) { > __iget(inode); > spin_unlock(&inode->i_lock); > @@ -779,6 +783,7 @@ static enum lru_status inode_lru_isolate > spin_lock(lru_lock); > return LRU_RETRY; > } > +#endif Pages can show up here even under !CONFIG_HIGHMEM. Because of the lock order to maintain LRU state (i_lock -> xa_lock), when the page cache inserts new pages it doesn't unlink the inode from the LRU atomically, and the shrinker might get here before inode_pages_set(). In that case we need the shrinker to punt the inode off the LRU (the #else branch). > WARN_ON(inode->i_state & I_NEW); > inode->i_state |= I_FREEING; > _ > > Whatever we do will need plenty of testing. It wouldn't surprise me > if there are people who unknowingly benefit from this code on > 64-bit machines. If we agree this is the way to go, I can put the patch into our tree and gather data from the Facebook fleet before we merge it.