Re: [PATCH] genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask

From: Aaron Tomlin

Date: Thu Apr 02 2026 - 20:27:14 EST


On Wed, Apr 01, 2026 at 02:13:34PM +0200, Sebastian Andrzej Siewior wrote:
> cpu_possible_mask is set early during boot based on information from the
> firmware. After that it remains read only and is never changed.
> Therefore there is no need to acquire CPU-hotplug locks while reading
> it.
>
> Remove cpus_read_*() while accessing cpu_possible_mask.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
> kernel/irq/affinity.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
> index 85c45cfe72238..78f2418a89252 100644
> --- a/kernel/irq/affinity.c
> +++ b/kernel/irq/affinity.c
> @@ -115,13 +115,10 @@ unsigned int irq_calc_affinity_vectors(unsigned int minvec, unsigned int maxvec,
> if (resv > minvec)
> return 0;
>
> - if (affd->calc_sets) {
> + if (affd->calc_sets)
> set_vecs = maxvec - resv;
> - } else {
> - cpus_read_lock();
> + else
> set_vecs = cpumask_weight(cpu_possible_mask);
> - cpus_read_unlock();
> - }
>
> return resv + min(set_vecs, maxvec - resv);
> }
> --

Hi Sebastian,

The cpu_possible_mask is indeed static. It is populated very early during
the system boot process and remains constant for the entire lifetime of the
system. Because the "possible" mask can never change, there is no risk of
concurrent modification during a CPU-hotplug event.
Albeit, I will defer to Thomas Gleixner.

LGTM.

Reviewed-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>
--
Aaron Tomlin

Attachment: signature.asc
Description: PGP signature