Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1012856pxf; Thu, 8 Apr 2021 19:57:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV0AlMc2BA+OUWzYwAuxxteBHqLceDIbVvMOGb+0OYWjzaroHe1pll1F1Z/G2DbpgEO932 X-Received: by 2002:a62:7917:0:b029:23f:594:e289 with SMTP id u23-20020a6279170000b029023f0594e289mr10390703pfc.1.1617937062340; Thu, 08 Apr 2021 19:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617937062; cv=none; d=google.com; s=arc-20160816; b=yDQEvl/RjNb18eixaT7bOzczzLfPKqiTGhCDl1U9X5VoYZqqV4IQ9P0RacyZWQpsa2 nROjZu8pqy/IDfxFuQAldw681grOPjhZGvt4Nx8dPsoJ4aj+lkgFpV4TRFOpRy6nkulg khTTXlJ8UHrNfSv/QkW0IO4kIFyfs8QmWQ2KNsQ5NcBSOyYfduGp6OHh03AJTv9aBotp Hj2uQcCbnT2EJatrQY0kEJollDmvYT/LeFC3kZlnfbYZNf8YZvq4oBXbg7PKFHK9niUd 1k95DL0QuauzsvZFTaNEydPQ2VP92BeuJuexQyLoBPTQdEZV4+mPBOBwF5FeY/w8VXAq 7Nxg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SIjeIVSYyN8GRA4IUq1K+E1Ly/eurxG9Jq0kyWHn2gc=; b=J+ylIHYR6l4+h+DNjEYGN240OK1B9ANaOFs4qBtJsUidMct5x+n6I8mfY6xy8+IF3R K4Vbdq1vN7V47qqohU2fJXZN+/a4EnaCVTjsWmWl0krXfMnXJ/D8NYrF2301tjx2AuBs U1o/rRMfpZNBnJGcAeuIRmPEReA/LhGaZjd2th/sQz1fr2iQwv1jV9Uo5kSFbgrzakxP tlGAZ5TBKkx7X6LQHqlv7ZqIOhB4ULxGHzuLYP7GJlw7bhJekNbJGr2M7ALK+UAKagNf +nN8TZETKJYqr+ws5K5kMcRW0tWbY5CwfnxM8ZDVQN9uDNWlUbjGNvlDaBi9u1S/oVaR RESg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=IgCWw5FV; 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 mz4si1436426pjb.26.2021.04.08.19.57.30; Thu, 08 Apr 2021 19:57:42 -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=@infradead.org header.s=casper.20170209 header.b=IgCWw5FV; 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 S232933AbhDIC4h (ORCPT + 99 others); Thu, 8 Apr 2021 22:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232662AbhDIC4h (ORCPT ); Thu, 8 Apr 2021 22:56:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 121CBC061760 for ; Thu, 8 Apr 2021 19:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=SIjeIVSYyN8GRA4IUq1K+E1Ly/eurxG9Jq0kyWHn2gc=; b=IgCWw5FVt9jUO9cBKDzE9/DgCf 0hco7AwhqZJftOlO5nyU7W3XJBsAtbmc+LH89gxSC3gykTdL0XG0dtdb4r+u26aSgxA4kk4zC3hpA LZ6bzM5n6Eib55BezWNlLfjZ2mBJwAG+hBitpKyX0njocum94q/Umo71NyVT4JF75Fjasf7tLXFXn EyCMdHktr8C+SBG0KzduRzUx+z287B9irdJzJt9K5R0DGDte8M4Lrg96m2aPnGU3rFJtekEgYzIbl hk5lOC6VXkFJDFJ0AyxETs7RGVcaLotLdDjhMR1rNCNnLiwsIN5+QTYp0elNFZpcr45xsZzQijH3M +UH+CrsQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lUhIK-00HGaf-LY; Fri, 09 Apr 2021 02:55:01 +0000 From: "Matthew Wilcox (Oracle)" To: neilb@suse.de, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, tglx@linutronix.de, bigeasy@linutronix.de Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH 06/17] dcache: Add d_hash_lock Date: Fri, 9 Apr 2021 03:51:20 +0100 Message-Id: <20210409025131.4114078-7-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210409025131.4114078-1-willy@infradead.org> References: <20210409025131.4114078-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow lockdep to track the d_hash bit spin locks. Signed-off-by: Matthew Wilcox (Oracle) --- fs/dcache.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 7d24ff7eb206..a3861d330001 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -96,6 +96,7 @@ EXPORT_SYMBOL(slash_name); static unsigned int d_hash_shift __read_mostly; +static DEFINE_SPLIT_LOCK(d_hash_lock); static struct hlist_bl_head *dentry_hashtable __read_mostly; static inline struct hlist_bl_head *d_hash(unsigned int hash) @@ -469,9 +470,9 @@ static void ___d_drop(struct dentry *dentry) else b = d_hash(dentry->d_name.hash); - hlist_bl_lock(b); + hlist_bl_lock(b, &d_hash_lock); __hlist_bl_del(&dentry->d_hash); - hlist_bl_unlock(b); + hlist_bl_unlock(b, &d_hash_lock); } void __d_drop(struct dentry *dentry) @@ -2074,9 +2075,9 @@ static struct dentry *__d_instantiate_anon(struct dentry *dentry, __d_set_inode_and_type(dentry, inode, add_flags); hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); if (!disconnected) { - hlist_bl_lock(&dentry->d_sb->s_roots); + hlist_bl_lock(&dentry->d_sb->s_roots, &d_hash_lock); hlist_bl_add_head(&dentry->d_hash, &dentry->d_sb->s_roots); - hlist_bl_unlock(&dentry->d_sb->s_roots); + hlist_bl_unlock(&dentry->d_sb->s_roots, &d_hash_lock); } spin_unlock(&dentry->d_lock); spin_unlock(&inode->i_lock); @@ -2513,9 +2514,9 @@ static void __d_rehash(struct dentry *entry) { struct hlist_bl_head *b = d_hash(entry->d_name.hash); - hlist_bl_lock(b); + hlist_bl_lock(b, &d_hash_lock); hlist_bl_add_head_rcu(&entry->d_hash, b); - hlist_bl_unlock(b); + hlist_bl_unlock(b, &d_hash_lock); } /** @@ -2606,9 +2607,9 @@ struct dentry *d_alloc_parallel(struct dentry *parent, goto retry; } - hlist_bl_lock(b); + hlist_bl_lock(b, &d_hash_lock); if (unlikely(READ_ONCE(parent->d_inode->i_dir_seq) != seq)) { - hlist_bl_unlock(b); + hlist_bl_unlock(b, &d_hash_lock); rcu_read_unlock(); goto retry; } @@ -2626,7 +2627,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent, continue; if (!d_same_name(dentry, parent, name)) continue; - hlist_bl_unlock(b); + hlist_bl_unlock(b, &d_hash_lock); /* now we can try to grab a reference */ if (!lockref_get_not_dead(&dentry->d_lockref)) { rcu_read_unlock(); @@ -2664,7 +2665,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent, new->d_flags |= DCACHE_PAR_LOOKUP; new->d_wait = wq; hlist_bl_add_head_rcu(&new->d_u.d_in_lookup_hash, b); - hlist_bl_unlock(b); + hlist_bl_unlock(b, &d_hash_lock); return new; mismatch: spin_unlock(&dentry->d_lock); @@ -2677,12 +2678,12 @@ void __d_lookup_done(struct dentry *dentry) { struct hlist_bl_head *b = in_lookup_hash(dentry->d_parent, dentry->d_name.hash); - hlist_bl_lock(b); + hlist_bl_lock(b, &d_hash_lock); dentry->d_flags &= ~DCACHE_PAR_LOOKUP; __hlist_bl_del(&dentry->d_u.d_in_lookup_hash); wake_up_all(dentry->d_wait); dentry->d_wait = NULL; - hlist_bl_unlock(b); + hlist_bl_unlock(b, &d_hash_lock); INIT_HLIST_NODE(&dentry->d_u.d_alias); INIT_LIST_HEAD(&dentry->d_lru); } -- 2.30.2