public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask
@ 2026-04-01 12:13 Sebastian Andrzej Siewior
  2026-04-01 14:15 ` [tip: irq/core] " tip-bot2 for Sebastian Andrzej Siewior
  2026-04-03  0:26 ` [PATCH] " Aaron Tomlin
  0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-04-01 12:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Aaron Tomlin

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@linutronix.de>
---
 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);
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [tip: irq/core] genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask
  2026-04-01 12:13 [PATCH] genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask Sebastian Andrzej Siewior
@ 2026-04-01 14:15 ` tip-bot2 for Sebastian Andrzej Siewior
  2026-04-03  0:26 ` [PATCH] " Aaron Tomlin
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Sebastian Andrzej Siewior @ 2026-04-01 14:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Sebastian Andrzej Siewior, Thomas Gleixner, x86, linux-kernel,
	maz

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 <bigeasy@linutronix.de>
AuthorDate:    Wed, 01 Apr 2026 14:13:34 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
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.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260401121334.xeMOSC1v@linutronix.de
---
 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 85c45cf..78f2418 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);
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask
  2026-04-01 12:13 [PATCH] genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask Sebastian Andrzej Siewior
  2026-04-01 14:15 ` [tip: irq/core] " tip-bot2 for Sebastian Andrzej Siewior
@ 2026-04-03  0:26 ` Aaron Tomlin
  1 sibling, 0 replies; 3+ messages in thread
From: Aaron Tomlin @ 2026-04-03  0:26 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-kernel, Thomas Gleixner, neelx

[-- Attachment #1: Type: text/plain, Size: 1561 bytes --]

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@linutronix.de>
> ---
>  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@atomlin.com>
-- 
Aaron Tomlin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-03  0:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 12:13 [PATCH] genirq/affinity: Remove cpus_read_lock() while reading cpu_possible_mask Sebastian Andrzej Siewior
2026-04-01 14:15 ` [tip: irq/core] " tip-bot2 for Sebastian Andrzej Siewior
2026-04-03  0:26 ` [PATCH] " Aaron Tomlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox