Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1250322ybk; Thu, 14 May 2020 04:29:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCy0+cwD0noXsIPU6NSzVIv570ykjpOkDWa5lIpmJyZmOjSVxWXPdso77lWgwcc5oOOvtT X-Received: by 2002:a17:906:a3ca:: with SMTP id ca10mr3498693ejb.298.1589455752448; Thu, 14 May 2020 04:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589455752; cv=none; d=google.com; s=arc-20160816; b=R8OGkkOswLT/eTj+kpH7dJEuEPMv+701pc/JZlYOHManIxc/tmWm5LP5/ALF1juABY kXuJvo3SNQAL7nwVS593NfvjJM7uxQsVJ3tgjYuT6k/NHtLaLenNrVdlZcPlAfH0fcYS nK2rrq1gL7SVbeyPjzV6N8+hYcxGtBXEZmbCM4mnAkfH4FMVxBcD3sXYiy1VIwAJ6ksU umzaqAHz3C/5Wr6bb5QqWB3d9qzYX8TVdXhbo1UcNvsrnqfWEmP0hOwxLzpoiN5VnqTw iclVQtlXZm0gmuV+dehOLmFvec2HEe2h4I83+iTQ2C7gD1nmSPHkmp8P84aqbPB9tB09 0COA== 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=z4Eb6Z/rPVAAEqdRxIyzUYlyq/XLZSCN7N827gkP7SE=; b=Wd3cchjg2qsYHLGZhQAKdo2SF9zm74UX/me7p+xly7HOiRtKH7ooT3CN9bGcOO6mST EKU4iHF1cwt1b9bTblxhEXscDjzt5sP3+OsEeibSuhS5llkge4Joq8o+CHQ2pyiFhA0I c52zJzj2r4v1JMSdd/Vg6efdMN0FQdCkCDaZJlMyVCAdQcMANgoDQ4Wq7KgWrnvCqY4g Gp6q0G9++Ya+EnK9kA0AJU7Aun1BOOn1FdqkxfYuhd28jO9QicgNqgjuSxXjEDGk+Wm0 uPTJEqZFIvunfISLbbyFFyGNr0z1NgWcSN9+lOYvYg1GnOE9nj4DTSPRt11UR8n4AEFC Yq6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Xuama2Pe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si1603575edl.531.2020.05.14.04.28.48; Thu, 14 May 2020 04:29:12 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Xuama2Pe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726156AbgENL1Y (ORCPT + 99 others); Thu, 14 May 2020 07:27:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726051AbgENL1X (ORCPT ); Thu, 14 May 2020 07:27:23 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B5FC061A0E for ; Thu, 14 May 2020 04:27:23 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id p4so581161qvr.10 for ; Thu, 14 May 2020 04:27:23 -0700 (PDT) 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=z4Eb6Z/rPVAAEqdRxIyzUYlyq/XLZSCN7N827gkP7SE=; b=Xuama2Pehfv31Tu5u95cS0aR3Up3PL2ZaP4TPeOq3w7oyLjzaiWSS8A+dcj3dLkHDM u6Z4vxQLsxqmxviLKbp4s2L7OIdHN02+gyGbQN4vWBpgtR4BWnTweHWfZt9bNcAnBjPJ /njdCkO3Yi/Klv3pse7p6MCFPDZJ4abAcNodv4ss9DPMsIYk7c2746M9XrKH9Sqz0o5e bWw+TLs5y1/MYoTwQqEBWKcVgHR8dHdiquyaK1wY3/QyVXZ5OFzfiZDAz7Iu5GMZ78WF qyC1UXJwW5mCpSnSJOE7D2oC89RmZmiluwGWrTagIRExbGtr7csUHL0Z9W7DDBg6Ts3Q EFXQ== 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=z4Eb6Z/rPVAAEqdRxIyzUYlyq/XLZSCN7N827gkP7SE=; b=ITQFhgWcVPXfQqlInQjjiLX7A0b763jhEdINymw0+42CKib54TzkQ5a8RebGPESaRf TXnvz49Vdm//MKfCNDdUgd0Hegp8yozq953oY5Twy2HoFmHFS85okGm7Mmzv6UUlKccX DW8XR0TaBYxWSHPVseJlaiFsME+5VX1kr7d3lhfgpTFjfdzMOYK5zh6m+T34cG6FnytH jaIfZRYZbUODYCC+q+Z/+lu6Jm36fmRWBZdX407nRtMUp49JpxB6EACJL0GIrEFCp2F5 EvFthGTDAWbVxKdnd27vfrkYgZe51oeyObrVX8sXOEP572frQe4xgbzrb/XTKeb1y9hq 8uTQ== X-Gm-Message-State: AOAM530KiPobeGIt4utcU8tuJCP2L5ORE2X6KrSEKS/Q+NGdm7rxtFIq khQhJbMhpJOt3j0t6hfmIWIFhw== X-Received: by 2002:a05:6214:18f1:: with SMTP id ep17mr4337171qvb.64.1589455642535; Thu, 14 May 2020 04:27:22 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id w22sm2436494qth.87.2020.05.14.04.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 04:27:21 -0700 (PDT) Date: Thu, 14 May 2020 07:27:02 -0400 From: Johannes Weiner To: Andrew Morton Cc: 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: <20200514112702.GB544269@cmpxchg.org> References: <20200211175507.178100-1-hannes@cmpxchg.org> <20200512212936.GA450429@cmpxchg.org> <20200513141519.061f8fca4788cd02b4d7068f@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200513141519.061f8fca4788cd02b4d7068f@linux-foundation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 13, 2020 at 02:15:19PM -0700, Andrew Morton wrote: > On Tue, 12 May 2020 17:29:36 -0400 Johannes Weiner wrote: > > > > > ... > > > > Solution > > > > This patch fixes the aging inversion described above on > > !CONFIG_HIGHMEM systems, without reintroducing the problems associated > > with excessive shrinker LRU rotations, by keeping populated inodes off > > the shrinker LRUs entirely. > > > > Currently, inodes are kept off the shrinker LRU as long as they have > > an elevated i_count, indicating an active user. Unfortunately, the > > page cache cannot simply hold an i_count reference, because unlink() > > *should* result in the inode being dropped and its cache invalidated. > > > > Instead, this patch makes iput_final() consult the state of the page > > cache and punt the LRU linking to the VM if the inode is still > > populated; the VM in turn checks the inode state when it depopulates > > the page cache, and adds the inode to the LRU if necessary. > > > > This is not unlike what we do for dirty inodes, which are moved off > > the LRU permanently until writeback completion puts them back on (iff > > still unused). We can reuse the same code -- inode_add_lru() - here. > > > > This is also not unlike page reclaim, where the lower VM layer has to > > negotiate state with the higher VFS layer. Follow existing precedence > > and handle the inversion as much as possible on the VM side: > > > > - introduce an I_PAGES flag that the VM maintains under the i_lock, so > > that any inode code holding that lock can check the page cache state > > without having to lock and inspect the struct address_space > > Maintaining the same info in two places is a hassle. Is this > optimization worthwhile? Hm, maybe not. I'll try to get rid of it and test cache / LRU state directly. > > - introduce inode_pages_set() and inode_pages_clear() to maintain the > > inode LRU state from the VM side, then update all cache mutators to > > use them when populating the first cache entry or clearing the last > > > > With this, the concept of "inodesteal" - where the inode shrinker > > drops page cache - is relegated to CONFIG_HIGHMEM systems only. The VM > > is in charge of the cache, the shrinker in charge of struct inode. > > How tested is this on highmem machines? I don't have a highmem machine, but my code is ifdeffed out on CONFIG_HIGHMEM so the behavior shouldn't have changed there.