Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp474997pxj; Thu, 3 Jun 2021 11:11:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDjyqteUGdf4I00aC0YHDu/aAalIsyk9YFxOa6hr+ENz8hcgVEaQt7ByFJUsCJAUc4od/b X-Received: by 2002:a17:906:b794:: with SMTP id dt20mr547687ejb.521.1622743888943; Thu, 03 Jun 2021 11:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622743888; cv=none; d=google.com; s=arc-20160816; b=TinQMbLUZEIBSJwsB7wim59WMLOUURHPGCZ2moxS1s6qRc8vo4soSTZL/c9buR2xjL Y/cvDbNOcouGEWvT/xD7I9sTup/ys8SsXhZAiiqT8LeTZ+4JrzwwcsHwB4HnoxzWhFSP +06Wi34bwR+eCWJAi52U/dIPaBLGbP6eFQvbkqA9UjieRW9s8Ni1rYOrNoNhx3xQYKpl 6Oc2gronRJQCSI4BW9U6MWmoy3Mncb4uKnImkzt2SrMjEihpbhcsS6T5gpWZ/2GCutup 86h3gkb5zjWYzacOCtLMysSlxpN9FbrixRKn6ds8K199k4pllvVfOiIAXTtP285scBhS l6hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=llczrUowQbUDxoyW8Fe3w+wZDCFWjdjoD/4x2j+vVJg=; b=sAXig/2lj0J/lrdLmVuVwuKyn30dzFtTe/ZAJwCoZ9XFl/9LUXbJJWdNh8Pa6I6jnJ O2E22fgy4bZCzJ/wJCUioPfd7GdOv5m2+6zdidO3O6XpvEeMVm6HDTqey9wThJnsrZiP YlOnPfbapi7PMVlVst9tWHefZRGfNt1D9VISwsnoQ4jGo+e6vwq9fN84b1mO35c0sF03 leL2s0V+my6gl4J7Xr/P/WXFy1LDNudiBCn3UpsvVBcXg+X2PeNkq79kN+5Dq3Bl2VIc gupJgYN+7nCOYnlZh5oiVgP31fl5SgNyFHi7myNys1RciYz/RSRwV32r8VAsYj7XnePa FW2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b="Xrk/o1Wl"; 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 md14si3029311ejb.89.2021.06.03.11.11.05; Thu, 03 Jun 2021 11:11:28 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b="Xrk/o1Wl"; 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 S229994AbhFCSJe (ORCPT + 99 others); Thu, 3 Jun 2021 14:09:34 -0400 Received: from mail-ua1-f49.google.com ([209.85.222.49]:45897 "EHLO mail-ua1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbhFCSJe (ORCPT ); Thu, 3 Jun 2021 14:09:34 -0400 Received: by mail-ua1-f49.google.com with SMTP id m23so3783278uao.12 for ; Thu, 03 Jun 2021 11:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=llczrUowQbUDxoyW8Fe3w+wZDCFWjdjoD/4x2j+vVJg=; b=Xrk/o1WlRoaP8m7dFFhXj1nHF3JRF2UNcgDTxbO5PUjM5F3VtmIuL+9y81MbbHRKs6 H8MEqgjIcYzrCEujCfLC0p3mJLbkDpBXgGbiPIPAFCjy3WwgO3PEdYvJf31nniA0Gei2 kOooV/K6xbQuBRB86za14gz/kpVbu4MU2jKjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=llczrUowQbUDxoyW8Fe3w+wZDCFWjdjoD/4x2j+vVJg=; b=EKYpnVioImHuFNwkxSXCvRW+W1UOceax1M5mqW3f8JEzqPGsNUyNF4+9O5qoustb7l 4c4grf+U65bJpq2SB5ilAOrz1inYiejHCwC2OF1sqv6RUGM05JW9ECd0eHjb3m94s9NY in36eWGQ01vuHUpFYS2/oHrrvNEf/FhEUG4MML9TEGEMfO+Z7cFAz4vFwyOS0ca3kqsC JIdOP/2l7zZ9ADOFn2OV5KAk4nvEF4f5nr/6Y9ozXR0oi+1aTqrjk3glc2E2tAeh3FFc MKf+hcrOVX+HTb5eE1Pf3q3R1Lj+jUBy/0z/GOfv035JKICZJWMQg0e0od49okdU1UZR 0oWQ== X-Gm-Message-State: AOAM531oHH5cKFzCaUeu1Cs9g2CxQYrL1HsgP0oQcrSIuc4YlBNEOr0u p23XEEt9BP3QQHihtDatHj6Y6pPvqS+VWYoRUHmAYg== X-Received: by 2002:a1f:32cf:: with SMTP id y198mr603626vky.23.1622743608931; Thu, 03 Jun 2021 11:06:48 -0700 (PDT) MIME-Version: 1.0 References: <162218354775.34379.5629941272050849549.stgit@web.messagingengine.com> <162218364554.34379.636306635794792903.stgit@web.messagingengine.com> <87czt2q2pl.fsf@disp2133> In-Reply-To: <87czt2q2pl.fsf@disp2133> From: Miklos Szeredi Date: Thu, 3 Jun 2021 20:06:38 +0200 Message-ID: Subject: Re: [REPOST PATCH v4 2/5] kernfs: use VFS negative dentry caching To: "Eric W. Biederman" Cc: Ian Kent , Greg Kroah-Hartman , Tejun Heo , Eric Sandeen , Fox Chen , Brice Goglin , Al Viro , Rick Lindsley , David Howells , Marcelo Tosatti , linux-fsdevel , Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 Jun 2021 at 19:26, Eric W. Biederman wrote: > > Ian Kent writes: > > > 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. > > > > Signed-off-by: Ian Kent > > --- > > fs/kernfs/dir.c | 55 +++++++++++++++++++++++++++++++++---------------------- > > 1 file changed, 33 insertions(+), 22 deletions(-) > > > > diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c > > index 4c69e2af82dac..5151c712f06f5 100644 > > --- a/fs/kernfs/dir.c > > +++ b/fs/kernfs/dir.c > > @@ -1037,12 +1037,33 @@ 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; > > + mutex_lock(&kernfs_mutex); > > > > kn = kernfs_dentry_node(dentry); > > - mutex_lock(&kernfs_mutex); > > Why bring kernfs_dentry_node inside the mutex? > > The inode lock of the parent should protect negative to positive > transitions not the kernfs_mutex. So moving the code inside > the mutex looks unnecessary and confusing. Except that d_revalidate() may or may not be called with parent lock held. Thanks, Miklos