From: Jan Kara <jack@suse.cz>
To: Mike Galbraith <efault@gmx.de>
Cc: Jan Kara <jack@suse.cz>, LKML <linux-kernel@vger.kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-ext4@vger.kernel.org
Subject: Re: 307af6c879377 "mbcache: automatically delete entries from cache on freeing" ==> PREEMPT_RT grumble
Date: Wed, 7 Sep 2022 15:14:32 +0200 [thread overview]
Message-ID: <20220907131432.4i3bh3xt6egesv7g@quack3> (raw)
In-Reply-To: <9f593b8ac1b731cbbf92dc1c7b497b668752b325.camel@gmx.de>
Hi Mike!
[added ext4 list to CC]
On Tue 06-09-22 18:21:37, Mike Galbraith wrote:
> 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.
Well, it was an easy solution but there's relatively simple workaround that
should remove the need of nesting. I'll send a patch.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
parent reply other threads:[~2022-09-07 13:15 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <9f593b8ac1b731cbbf92dc1c7b497b668752b325.camel@gmx.de>]
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=20220907131432.4i3bh3xt6egesv7g@quack3 \
--to=jack@suse.cz \
--cc=bigeasy@linutronix.de \
--cc=efault@gmx.de \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.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