From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54716C433DF for ; Thu, 14 May 2020 11:27:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C7D72074A for ; Thu, 14 May 2020 11:27:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="Xuama2Pe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbgENL1Y (ORCPT ); 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-Google-Smtp-Source: ABdhPJwNzKrTSsz07dyXsXpJd6gX8DQPhRfqzzRHvRXSP01QQc+CGwjKrc9uTxvROL9gZMKBT68QNw== 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.