genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask
PATCH 1/1 genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask
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.
--- kernel/irq/affinity.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/irq/affinity.c +2 -5
@@ -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); }
Signature · 1 line
2.53.0
The following commit has been merged into the irq/core branch of tip:
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 34d85ad42604fbb5a8903488c6a7e2862e2d0254 Gitweb: https://git.kernel.org/tip/34d85ad42604fbb5a8903488c6a7e2862e2d0254 Author: Sebastian Andrzej Siewior <[email protected]> AuthorDate: Wed, 01 Apr 2026 14:13:34 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 01 Apr 2026 16:09:05 +02:00
genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask
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 the CPU-hotplug lock while reading it.
Remove cpus_read_*() while accessing cpu_possible_mask.
--- kernel/irq/affinity.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/irq/affinity.c +2 -5
@@ -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); }
Quoted 23 lines · Sebastian Andrzej Siewior
cpu_possible_maskis 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 <[email protected]>--- kernel/irq/affinity.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)kernel/irq/affinity.c +1
-1@@ -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)
kernel/irq/affinity.c unsigned int irq_calc_affinity_vectors(unsigned int minvec, unsigned int maxvec, · line 124
Quoted 10 lines
kernel/irq/affinity.c +1
-4set_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.
Signature · 1 line
Aaron Tomlin