mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* 307af6c879377 "mbcache: automatically delete entries from cache on freeing" ==> PREEMPT_RT grumble
@ 2022-09-06 16:21 Mike Galbraith
  2022-09-07 13:14 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Galbraith @ 2022-09-06 16:21 UTC (permalink / raw)
  To: Jan Kara; +Cc: LKML, Sebastian Andrzej Siewior

Hi Jan,

diff --git a/fs/mbcache.c b/fs/mbcache.c
index d1ebb5df2856..96f1d49d30a5 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@ -106,21 +106,28 @@ int mb_cache_entry_create(struct mb_cache *cache, gfp_t mask, u32 key,
 		}
 	}
 	hlist_bl_add_head(&entry->e_hash_list, head);
-	hlist_bl_unlock(head);
-
+	/*
+	 * Add entry to LRU list before it can be found by
+	 * mb_cache_entry_delete() to avoid races
+	 */
 	spin_lock(&cache->c_list_lock);
 	list_add_tail(&entry->e_list, &cache->c_list);
-	/* Grab ref for LRU list */
-	atomic_inc(&entry->e_refcnt);
 	cache->c_entry_count++;
 	spin_unlock(&cache->c_list_lock);
+	hlist_bl_unlock(head);

 	return 0;
 }
 EXPORT_SYMBOL(mb_cache_entry_create);

The above movement of hlist_bl_unlock() is a problem for RT wrt both
taking and releasing of ->c_list_lock, it becoming an rtmutex in RT and
hlist_bl_unlock() taking a preemption blocking bit spinlock.

Is that scope increase necessary?  If so, looks like ->c_list_lock
could probably become a raw_spinlock_t without anyone noticing.

	-Mike

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-07 13:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 16:21 307af6c879377 "mbcache: automatically delete entries from cache on freeing" ==> PREEMPT_RT grumble Mike Galbraith
2022-09-07 13:14 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®