On 6/15/26 13:05, Harry Yoo (Oracle) wrote:
> call_rcu() disables IRQs with local_irq_save() to protect its per-cpu
> data structures. Therefore, if IRQs are not disabled, they cannot be
> corrupted by reentrance into call_rcu(). So fall back to the deferred
> path only when !allow_spin && irqs_disabled().
>
> The RCU subsystem does not guarantee this contractually, and this
> optimization relies on RCU's implementation details. Ideally, it should
> be removed once call_rcu_nolock() is supported by the RCU subsystem.
>
> Link:
> https://lore.kernel.org/linux-mm/caadnvqkrvd5zsnekbzzu7w86ghbghuug2pvzpgztngns+fg...@mail.gmail.com
> Suggested-by: Alexei Starovoitov <[email protected]>
> Signed-off-by: Harry Yoo (Oracle) <[email protected]>
Hope RCU people can approve this.
> ---
> mm/slub.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index b0d38d515386..6a3552b70683 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -6158,8 +6158,8 @@ bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj,
> bool allow_spin)
> if (likely(rcu_sheaf->size < s->sheaf_capacity)) {
> rcu_sheaf = NULL;
> } else {
> - if (unlikely(!allow_spin)) {
> - /* call_rcu() cannot be called in an unknown context */
> + /* call_rcu() disables IRQs to protect percpu data structures */
Maybe elaborate that with !allow_spin we might have preempted call_rcu()'s
protected section, which disables IRQs, so we can't call_rcu(). But if IRQs
are not disabled, we know it's not the case?
> + if (unlikely(!allow_spin && irqs_disabled())) {
> rcu_sheaf->size--;
> local_unlock(&s->cpu_sheaves->lock);
> goto fail;
>