Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp458158yba; Wed, 3 Apr 2019 12:06:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxJiW2TrLyIO0hLHnIHK0FuyhQ5tcAPyEDuNAgjJadD2gPUdI5g/fgBDIbls58kIkQJAHl X-Received: by 2002:a63:b64:: with SMTP id a36mr1373400pgl.58.1554318392117; Wed, 03 Apr 2019 12:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554318392; cv=none; d=google.com; s=arc-20160816; b=I/qQNNsSb1WTSOez8O1mYi2t8evMDScMvGkds4HPIEsHCYYSLjIbYf5tCzZmmLltVs Uf3des4t0U2sGuc3aDPhC4LtybhwRETW+z+eAqhlZhJ0jHkKIrMme/EawaFyVt7qMd2K 46n11Mmmof/ki/ZtYcc78T3mglU3E5p7uXAwNrl7sRgttY6dMJA5NZaxsRZA0S6YfU82 L+mYCr52C/GgqCaF5sRwQkxg3KIXqW0f+G0mftaBuv10ozo0vcxcquEauvgXeJM60td/ dVireh//U9H0h25Elyt1x9K2RCz2S/cm7cY1x+nIMFN/RX9/72XUuv542wm6GWR2l/7r 4Hpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=OEYJTk4ERbxR3Ks/Z8SoPrEsQATOWMET3H09eKVbTkg=; b=oVNIBK6SZ3IZajpvlfvIxJdoOS6RAebCzXsv5QhJ0tS42dPRSDOUXsj3hZOZXqG/Rb WNDo6yzq4yi4ZrMYTiriC1er5TdKUrgJ1p73jhEkI8RHfQ+AHG7O37IgAMcwQEwdYQEv wSat5YxQ2JjNUnmy4I2sF8o6tzbqmNhggcGCsaoy9WNzfx3A5vqd6zpKJZ8CPegpUPt8 722XGIgGguLGAe4Evqb36JGw7M+UnJeIN1/s9EYu6Vl1PSPZhEM/f+ituNizO5kx9Oxg 0n4ziWH4sbWho2yAT+9gWafpVOlFbUhoaJmr8/5KFp0ixinaQwuF7/rLsVSNGspeK1am AtuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7si14121913plo.163.2019.04.03.12.06.16; Wed, 03 Apr 2019 12:06:32 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726263AbfDCTFl (ORCPT + 99 others); Wed, 3 Apr 2019 15:05:41 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:35422 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbfDCTFl (ORCPT ); Wed, 3 Apr 2019 15:05:41 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hBlCK-0006a6-NT; Wed, 03 Apr 2019 19:05:20 +0000 Date: Wed, 3 Apr 2019 20:05:20 +0100 From: Al Viro To: Christopher Lameter Cc: "Tobin C. Harding" , Andrew Morton , Roman Gushchin , Alexander Viro , Christoph Hellwig , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , Miklos Szeredi , Andreas Dilger , Waiman Long , Tycho Andersen , Theodore Ts'o , Andi Kleen , David Chinner , Nick Piggin , Rik van Riel , Hugh Dickins , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds Subject: Re: [RFC PATCH v2 14/14] dcache: Implement object migration Message-ID: <20190403190520.GW2217@ZenIV.linux.org.uk> References: <20190403042127.18755-1-tobin@kernel.org> <20190403042127.18755-15-tobin@kernel.org> <20190403170811.GR2217@ZenIV.linux.org.uk> <01000169e458534a-3c6a5d6f-3054-4c64-b5f9-7f46c811eeac-000000@email.amazonses.com> <20190403182454.GU2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190403182454.GU2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 03, 2019 at 07:24:54PM +0100, Al Viro wrote: > If by "how to do it right" you mean "expedit kicking out something with > non-zero refcount" - there's no way to do that. Nothing even remotely > sane. > > If you mean "kick out everything in this page with zero refcount" - that > can be done (see further in the thread). > > Look, dentries and inodes are really, really not relocatable. If they > can be evicted by memory pressure - sure, we can do that for a given > set (e.g. "everything in that page"). But that's it - if memory > pressure would _not_ get rid of that one, there's nothing to be done. > Again, all VM can do is to simulate shrinker hitting hard on given > bunch (rather than buggering the entire cache). If filesystem (or > something in VFS) says "it's busy", it bloody well _is_ busy and > won't be going away until it ceases to be such. FWIW, some theory: the only kind of long-term reference that can be killed off by memory pressure is that from child to parent. Anything else (e.g. an opened file, current directory, mountpoint, etc.) is out of limits - it either won't be going away until the thing is not pinned anymore (close, chdir, etc.) *or* it really shouldn't be ("VM wants this mountpoint dentry freed, so just dissolve the mount" is a bloody bad idea for obvious reasons). Stuff in somebody's shrink list is none of our business - somebody else is going to try and evict it anyway; if it can be evicted, it will be. Anything with zero refcount that isn't in somebody else's shrink list is fair game. Directories with children could, in principle, be helped along - we could try shrink_dcache_parent() on them, which might end up leaving them with zero refcount. However, it's not cheap and if you pick the root dentry of a filesystem, it'll try to evict everything on it that can be evicted, be it in this page or not. And there's no promise that it will end up evictable after that. So from the correctness POV * you can kick out everything with zero refcount not on shrink lists. * you _might_ try shrink_dcache_parent() on directory dentries, in hope to drive their refcount to zero. However, that's almost certainly going to hit too hard and be too costly. * d_invalidate() is no-go; if anything, you want something weaker than shrink_dcache_parent(), not stronger. For anything beyond "just kick out everything in that page that happens to have zero refcount" I would really like to see the stats - how much does it help, how costly it is _and_ how much of the cache does it throw away (see above re running into a root dentry of some filesystem and essentially trimming dcache for that fs down to the unevictable stuff).