Re: [PATCH 3/3] kvfree_rcu: use migrate_disable/enable()

From: Sebastian Andrzej Siewior
Date: Wed Jan 20 2021 - 14:49:32 EST


On 2021-01-20 17:21:48 [+0100], Uladzislau Rezki (Sony) wrote:
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -3489,10 +3489,12 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp,
> (*krcp)->bkvhead[idx]->nr_records == KVFREE_BULK_MAX_ENTR) {
> bnode = get_cached_bnode(*krcp);
> if (!bnode && can_alloc) {
> + migrate_disable();
> krc_this_cpu_unlock(*krcp, *flags);

Why is krc_this_cpu_unlock() defined as
| static inline void
| krc_this_cpu_unlock(struct kfree_rcu_cpu *krcp, unsigned long flags)
| {
| raw_spin_unlock(&krcp->lock);
| local_irq_restore(flags);
| }

instead of raw_spin_unlock_irqrestore()?
Should something with the locked section trigger a scheduling event by
setting TIF_NEED_RESCHED then there will be no scheduling event on
unlock. It will be delayed until a later "random" preempt_enable().

raw_spin_unlock_irqrestore() will reschedule if the flag is set,
local_irq_restore() will not.

Sebastian