Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp990171pxj; Fri, 11 Jun 2021 17:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ/5JXTcrPa43pn6ULQOJOTrK1Y0lmJaoiAy1EaEXfMS09PCX51ERS1JGbZfBP+hfH40Zu X-Received: by 2002:a17:906:8056:: with SMTP id x22mr5712936ejw.298.1623459086212; Fri, 11 Jun 2021 17:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623459086; cv=none; d=google.com; s=arc-20160816; b=zRsL5lSH+p95wSPplKMXRfv+w/Sf14L1QuupX93NQdct8m0vDXUbJo5KAx0Uu1gpkR lW+Nqf7U139Q3SqbqqVUTMgTbQjpZCvz2yTHVmnQZcpTCEXhTwGLDZqpfJemZjQg52an JnIBD/NLToXzetd/F5FNwvDAJLP+DWviKfaJmhDNYaDkQbGI2z0ZLKvrStwwr0t15JgD PwhWYLM7SkQG7hqAPASbUBl8jQBuvEwHg+rAU+YwGdrXGns52zZBoOojzyHZoAE7lo/y LGsjjyDOQN5zdJsLrGu+xDRDrRZB1aSKZUUNHTkc+KYoOYHGwZcSZNIFzeIGW1TSQviC X2vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=pUHyicE+xVETwF9BHn/R9zG86J8cj32XPjWTRMM+Dxo=; b=HBuA436SD0Lz8Kfk/SAlgB/oQ4H3qCMaPOmCqLKyxkEC+DgUzP/scSc2hrO85IEiDp 9HSoN28x+teYF6wgpO9v8p4a284J+ft9mizPFXLI//S7DDJM/vcIYwKbuYEsCJW5x2yV 29Eq+qs+ptuHqZ1pwUsVgFWPJdVN+e0xJNz/oxgcKydZ6TCrcn9Y2iuobBjQnZADcHZD 35TQRKrMGVoJIawIEKjq/xtBLtWpOVXTji7oSAW2nTIyv6DDnNoGpuYw2YwTmOHndL1L c1JudCin973PX4/rmjBurdr81LkFCyVR+8nbQNP08x6SxykHVmNGp1rPDmf0FtAYp4Wf +KhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm3 header.b=OWnFYSJ0; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BJiSdG3c; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si6349231ejl.598.2021.06.11.17.51.03; Fri, 11 Jun 2021 17:51:26 -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=@themaw.net header.s=fm3 header.b=OWnFYSJ0; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BJiSdG3c; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbhFLAt1 (ORCPT + 99 others); Fri, 11 Jun 2021 20:49:27 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:33153 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229942AbhFLAt0 (ORCPT ); Fri, 11 Jun 2021 20:49:26 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id BAFFE580B33; Fri, 11 Jun 2021 20:47:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 11 Jun 2021 20:47:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h= message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; s=fm3; bh= pUHyicE+xVETwF9BHn/R9zG86J8cj32XPjWTRMM+Dxo=; b=OWnFYSJ0m6zKboQZ FoXrPwTf5vKk2D0uZ7OijBK5DKfyqgA7JAQKsOrRDOZ7dAosHivf0YJ5Q7HRUWDd pZ/+FEB8f5ArUzhSwlJqDvRgzEx1qaGOLC9JOGECTxQktpe1xDzjGd15krYZZXhH pFcx86sYuXoO47hfvfZlA+5aywu1CBJmBTSCAvJQ9KbyR3eL8TCku/QNNi1nmCrm OB30BAQ/Nllg7sPUJc50FQZSLFPkGJ0pB1dlJV7dLkde48Sgmn8vjxJj9g7C7Rcr 3Xw57nNFBmgEDEMvUZJszHitiiKj3oxgpxOeSMNxFl+OYK3tFUOp54DeiLU2QxDC rxkfhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=pUHyicE+xVETwF9BHn/R9zG86J8cj32XPjWTRMM+D xo=; b=BJiSdG3cpKe/+7Xhr43xs77HwYN2RPyhWkeCsPFDKMxWgFeUTIM/diRNl YtkogJaTy8lhjoHdm73cfBVWrCwiZwgOHe6FxAXk2/GV/Z+TVwQMsfvUZ/mvRtPb fDyhslQKtCnewFUAAVoqyIAcXegFtxuy6pdLOhv1kO0/iqGa26jRfE37UG3RnBPt etqV7KE2tHhMe16AP6ACMzQMUeehaOmoBkQl9nbRsnDZdMVUDvrhQgzKI8bulLHh nOTC6yn6jbOuDPLFSxeTHlMcEWY9o+lRIQ04spZk8MCWUHacG9L7ifhIgG5rWD/Z E0EufHck483zWA2Gz1wPbrf22WQDw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeduledgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkffuhffvffgjfhgtfggggfesthekredttderjeenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe fgleelkeetheelgeehueejueduhfeufffgleehgfevtdehhffhhffhtddugfefheenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 11 Jun 2021 20:47:21 -0400 (EDT) Message-ID: Subject: Re: [PATCH v6 3/7] kernfs: use VFS negative dentry caching From: Ian Kent To: Miklos Szeredi Cc: Greg Kroah-Hartman , Tejun Heo , Eric Sandeen , Fox Chen , Brice Goglin , Al Viro , Rick Lindsley , David Howells , Marcelo Tosatti , "Eric W. Biederman" , Carlos Maiolino , linux-fsdevel , Kernel Mailing List Date: Sat, 12 Jun 2021 08:47:17 +0800 In-Reply-To: References: <162322846765.361452.17051755721944717990.stgit@web.messagingengine.com> <162322862726.361452.10114120072438540655.stgit@web.messagingengine.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-06-11 at 15:07 +0200, Miklos Szeredi wrote: > On Wed, 9 Jun 2021 at 10:50, Ian Kent wrote: > > > > If there are many lookups for non-existent paths these negative > > lookups > > can lead to a lot of overhead during path walks. > > > > The VFS allows dentries to be created as negative and hashed, and > > caches > > them so they can be used to reduce the fairly high overhead > > alloc/free > > cycle that occurs during these lookups. > > > > Use the kernfs node parent revision to identify if a change has > > been > > made to the containing directory so that the negative dentry can be > > discarded and the lookup redone. > > > > Signed-off-by: Ian Kent > > --- > >  fs/kernfs/dir.c |   52 ++++++++++++++++++++++++++++++++----------- > > --------- > >  1 file changed, 32 insertions(+), 20 deletions(-) > > > > diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c > > index b3d1bc0f317d0..4f037456a8e17 100644 > > --- a/fs/kernfs/dir.c > > +++ b/fs/kernfs/dir.c > > @@ -1039,9 +1039,28 @@ static int kernfs_dop_revalidate(struct > > dentry *dentry, unsigned int flags) > >         if (flags & LOOKUP_RCU) > >                 return -ECHILD; > > > > -       /* Always perform fresh lookup for negatives */ > > -       if (d_really_is_negative(dentry)) > > -               goto out_bad_unlocked; > > +       /* Negative hashed dentry? */ > > +       if (d_really_is_negative(dentry)) { > > +               struct dentry *d_parent = dget_parent(dentry); > > +               struct kernfs_node *parent; > > + > > +               /* If the kernfs parent node has changed discard > > and > > +                * proceed to ->lookup. > > +                */ > > +               parent = kernfs_dentry_node(d_parent); > > +               if (parent) { > > +                       if (kernfs_dir_changed(parent, dentry)) { > > Perhaps add a note about this being dependent on parent of a negative > dentry never changing. Which of course it it can change, at any time. > > If this was backported to a kernel where this assumption doesn't > hold, > there would be a mathematical chance of a false negative. Isn't this a cunning way of saying "in thinking about the move case you've forgotten about the obvious common case, just put back taking the read lock already, at least for the check"? Ian