Re: [PATCH v3 06/12] smp: Enable preemption early in smp_call_function_many_cond
From: Sebastian Andrzej Siewior
Date: Wed Mar 18 2026 - 13:40:35 EST
On 2026-03-18 12:56:32 [+0800], Chuyi Zhou wrote:
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -907,9 +920,11 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
> }
> }
So now I understand why we have this cpumask on stack.
Could we, on a preemptible kernel, where we have a preemption counter,
in the case of preemptible() allocate a cpumask and use it here? If the
allocation fails or we are not on a preemptbile kernel then we don't do
this optimized wait with enabled preemption.
There is no benefit of doing all this if the caller has already
preemption disabled.
> - rcu_read_unlock();
> - if (preemptible_wait)
> + if (!preemptible_wait)
> + put_cpu();
> + else
> free_cpumask_var(cpumask_stack);
> + rcu_read_unlock();
> }
>
> /**
Sebastian