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 3DE6FC433E0 for ; Thu, 14 May 2020 11:27:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA65C206DA for ; Thu, 14 May 2020 11:27:24 +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" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA65C206DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 66F22900004; Thu, 14 May 2020 07:27:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 620718E0005; Thu, 14 May 2020 07:27:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E82A900004; Thu, 14 May 2020 07:27:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 3041B8E0005 for ; Thu, 14 May 2020 07:27:24 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D0C413A9E for ; Thu, 14 May 2020 11:27:23 +0000 (UTC) X-FDA: 76815098766.07.mint52_5d9eb2546b952 X-HE-Tag: mint52_5d9eb2546b952 X-Filterd-Recvd-Size: 5828 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 May 2020 11:27:23 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id ee19so1438634qvb.11 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=eoAVRCN1f208p254N49Sg6xSEvsQEq0fOJLfqC4qnUP8xLcWayfS4mK3HhDlp2VSD4 eTuOJA9XzFzfGZayonJsbN6ln3qDaX0nueMeaaviJrdM1jIT/Mzf/aRz8XEpP/ByuF5I xJIA3FkHqUQ99Ym8b3X6+VCCMe4vnbUv3xAK96cDYY/f/gWOMZ81d2zkumY/kyNXus2V Pt/7gTbgRXdSTa6EDer6qEqbGraBz4xP7CxjZb6rWUk0Jv13+nm7SNFo/BDpuxlwTU9H FBuE1ri9+lbJarYDB5JWhuaFMdsS6LMnCY+9j3Irhl+DxoP3s9Aqwb+pt1a0gEWKge75 KJaw== X-Gm-Message-State: AOAM533dBH/RuqzUdzcfsfuvwRzB14nc48ZkwPlVpPIjhYj91o8E+vX6 G5cM9MYCaEB9edSExicJAYNiVA== 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.