From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
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)" <willy@infradead.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 09/17] mbcache: Add mb_cache_lock
Date: Fri, 9 Apr 2021 03:51:23 +0100 [thread overview]
Message-ID: <20210409025131.4114078-10-willy@infradead.org> (raw)
In-Reply-To: <20210409025131.4114078-1-willy@infradead.org>
Allow lockdep to track the mbcache hash bit spin locks.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/mbcache.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/fs/mbcache.c b/fs/mbcache.c
index 97c54d3a2227..4ce03ea348dd 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -47,6 +47,7 @@ static struct kmem_cache *mb_entry_cache;
static unsigned long mb_cache_shrink(struct mb_cache *cache,
unsigned long nr_to_scan);
+static DEFINE_SPLIT_LOCK(mb_cache_lock);
static inline struct hlist_bl_head *mb_cache_entry_head(struct mb_cache *cache,
u32 key)
{
@@ -97,16 +98,16 @@ int mb_cache_entry_create(struct mb_cache *cache, gfp_t mask, u32 key,
entry->e_reusable = reusable;
entry->e_referenced = 0;
head = mb_cache_entry_head(cache, key);
- hlist_bl_lock(head);
+ hlist_bl_lock(head, &mb_cache_lock);
hlist_bl_for_each_entry(dup, dup_node, head, e_hash_list) {
if (dup->e_key == key && dup->e_value == value) {
- hlist_bl_unlock(head);
+ hlist_bl_unlock(head, &mb_cache_lock);
kmem_cache_free(mb_entry_cache, entry);
return -EBUSY;
}
}
hlist_bl_add_head(&entry->e_hash_list, head);
- hlist_bl_unlock(head);
+ hlist_bl_unlock(head, &mb_cache_lock);
spin_lock(&cache->c_list_lock);
list_add_tail(&entry->e_list, &cache->c_list);
@@ -134,7 +135,7 @@ static struct mb_cache_entry *__entry_find(struct mb_cache *cache,
struct hlist_bl_head *head;
head = mb_cache_entry_head(cache, key);
- hlist_bl_lock(head);
+ hlist_bl_lock(head, &mb_cache_lock);
if (entry && !hlist_bl_unhashed(&entry->e_hash_list))
node = entry->e_hash_list.next;
else
@@ -150,7 +151,7 @@ static struct mb_cache_entry *__entry_find(struct mb_cache *cache,
}
entry = NULL;
out:
- hlist_bl_unlock(head);
+ hlist_bl_unlock(head, &mb_cache_lock);
if (old_entry)
mb_cache_entry_put(cache, old_entry);
@@ -203,7 +204,7 @@ struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *cache, u32 key,
struct mb_cache_entry *entry;
head = mb_cache_entry_head(cache, key);
- hlist_bl_lock(head);
+ hlist_bl_lock(head, &mb_cache_lock);
hlist_bl_for_each_entry(entry, node, head, e_hash_list) {
if (entry->e_key == key && entry->e_value == value) {
atomic_inc(&entry->e_refcnt);
@@ -212,7 +213,7 @@ struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *cache, u32 key,
}
entry = NULL;
out:
- hlist_bl_unlock(head);
+ hlist_bl_unlock(head, &mb_cache_lock);
return entry;
}
EXPORT_SYMBOL(mb_cache_entry_get);
@@ -231,12 +232,12 @@ void mb_cache_entry_delete(struct mb_cache *cache, u32 key, u64 value)
struct mb_cache_entry *entry;
head = mb_cache_entry_head(cache, key);
- hlist_bl_lock(head);
+ hlist_bl_lock(head, &mb_cache_lock);
hlist_bl_for_each_entry(entry, node, head, e_hash_list) {
if (entry->e_key == key && entry->e_value == value) {
/* We keep hash list reference to keep entry alive */
hlist_bl_del_init(&entry->e_hash_list);
- hlist_bl_unlock(head);
+ hlist_bl_unlock(head, &mb_cache_lock);
spin_lock(&cache->c_list_lock);
if (!list_empty(&entry->e_list)) {
list_del_init(&entry->e_list);
@@ -250,7 +251,7 @@ void mb_cache_entry_delete(struct mb_cache *cache, u32 key, u64 value)
return;
}
}
- hlist_bl_unlock(head);
+ hlist_bl_unlock(head, &mb_cache_lock);
}
EXPORT_SYMBOL(mb_cache_entry_delete);
@@ -301,12 +302,12 @@ static unsigned long mb_cache_shrink(struct mb_cache *cache,
*/
spin_unlock(&cache->c_list_lock);
head = mb_cache_entry_head(cache, entry->e_key);
- hlist_bl_lock(head);
+ hlist_bl_lock(head, &mb_cache_lock);
if (!hlist_bl_unhashed(&entry->e_hash_list)) {
hlist_bl_del_init(&entry->e_hash_list);
atomic_dec(&entry->e_refcnt);
}
- hlist_bl_unlock(head);
+ hlist_bl_unlock(head, &mb_cache_lock);
if (mb_cache_entry_put(cache, entry))
shrunk++;
cond_resched();
--
2.30.2
next prev parent reply other threads:[~2021-04-09 2:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-09 2:51 [PATCH 00/17] Provide lockdep tracking for bit spin locks Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 01/17] x86: Rename split_lock_init to sld_init Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 02/17] locking: Add split_lock Matthew Wilcox (Oracle)
2021-04-12 14:29 ` Thomas Gleixner
2021-04-12 14:45 ` Matthew Wilcox
2021-04-12 15:01 ` Thomas Gleixner
2021-05-11 7:46 ` Peter Zijlstra
2021-04-09 2:51 ` [PATCH 03/17] bit_spinlock: Prepare for split_locks Matthew Wilcox (Oracle)
2021-04-09 14:32 ` Theodore Ts'o
2021-04-09 14:35 ` Matthew Wilcox
2021-04-09 14:55 ` Theodore Ts'o
2021-04-09 2:51 ` [PATCH 04/17] hlist_bl: " Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 05/17] dm-snap: Add dm_exceptional_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 06/17] dcache: Add d_hash_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 07/17] fscache: Add cookie_hash_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 08/17] gfs2: Add qd_hash_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` Matthew Wilcox (Oracle) [this message]
2021-04-09 2:51 ` [PATCH 10/17] hlist_bl: Make the split_lock parameter mandatory Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 11/17] s390: Add airq_iv_lock Matthew Wilcox (Oracle)
2021-04-09 6:18 ` kernel test robot
2021-04-09 13:20 ` Matthew Wilcox
2021-04-09 2:51 ` [PATCH 12/17] zram: Add zram_table_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 13/17] jbd2: Add jbd2_jh_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 14/17] slub: Add slab_page_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 15/17] zsmalloc: Add zs_pin_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 16/17] rhashtable: Convert to split_lock Matthew Wilcox (Oracle)
2021-04-09 2:51 ` [PATCH 17/17] bit_spinlock: Track bit spin locks with lockdep Matthew Wilcox (Oracle)
2021-04-09 6:37 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210409025131.4114078-10-willy@infradead.org \
--to=willy@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=neilb@suse.de \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).