All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2] genirq/cpuhotpug: notify of irq affinity change for offlined cpu.
@ 2026-01-02 16:53 Imran Khan
  2026-01-13  9:24 ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Imran Khan @ 2026-01-02 16:53 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel

During cpu offlining the irqs with broken_affinity are affined
to other CPU but this affinity change is not accounted for by
desc::affinity_notify (if available).
This can leave users of irq_set_affinity_notifier, with old
affinity information.

Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
---
v1 -> v2:
 - Fix compilation error due to missed parenthesis around scoped_guard

 kernel/irq/cpuhotplug.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c
index 755346ea98196..30153be1a4cca 100644
--- a/kernel/irq/cpuhotplug.c
+++ b/kernel/irq/cpuhotplug.c
@@ -177,9 +177,17 @@ void irq_migrate_all_off_this_cpu(void)
 		bool affinity_broken;
 
 		desc = irq_to_desc(irq);
-		scoped_guard(raw_spinlock, &desc->lock)
+		scoped_guard(raw_spinlock_irqsave, &desc->lock) {
 			affinity_broken = migrate_one_irq(desc);
-
+			if (affinity_broken && desc->affinity_notify) {
+				kref_get(&desc->affinity_notify->kref);
+				if (!schedule_work(&desc->affinity_notify->work)) {
+					/* Work was already scheduled, drop our extra ref */
+					kref_put(&desc->affinity_notify->kref,
+					desc->affinity_notify->release);
+				}
+			}
+		}
 		if (affinity_broken) {
 			pr_debug_ratelimited("IRQ %u: no longer affine to CPU%u\n",
 					    irq, smp_processor_id());

base-commit: f8f9c1f4d0c7a64600e2ca312dec824a0bc2f1da
-- 
2.34.1


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

* Re: [RFC PATCH v2] genirq/cpuhotpug: notify of irq affinity change for offlined cpu.
  2026-01-02 16:53 [RFC PATCH v2] genirq/cpuhotpug: notify of irq affinity change for offlined cpu Imran Khan
@ 2026-01-13  9:24 ` Thomas Gleixner
  2026-01-13  9:24   ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2026-01-13  9:24 UTC (permalink / raw)
  To: Imran Khan; +Cc: linux-kernel

On Sat, Jan 03 2026 at 00:53, Imran Khan wrote:
> During cpu offlining the irqs with broken_affinity are affined
> to other CPU but this affinity change is not accounted for by
> desc::affinity_notify (if available).
> This can leave users of irq_set_affinity_notifier, with old
> affinity information.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> ---
> v1 -> v2:
>  - Fix compilation error due to missed parenthesis around scoped_guard
>
>  kernel/irq/cpuhotplug.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c
> index 755346ea98196..30153be1a4cca 100644
> --- a/kernel/irq/cpuhotplug.c
> +++ b/kernel/irq/cpuhotplug.c
> @@ -177,9 +177,17 @@ void irq_migrate_all_off_this_cpu(void)
>  		bool affinity_broken;
>  
>  		desc = irq_to_desc(irq);
> -		scoped_guard(raw_spinlock, &desc->lock)
> +		scoped_guard(raw_spinlock_irqsave, &desc->lock) {
>  			affinity_broken = migrate_one_irq(desc);
> -
> +			if (affinity_broken && desc->affinity_notify) {
> +				kref_get(&desc->affinity_notify->kref);
> +				if (!schedule_work(&desc->affinity_notify->work)) {
> +					/* Work was already scheduled, drop our extra ref */
> +					kref_put(&desc->affinity_notify->kref,
> +					desc->affinity_notify->release);
> +				}
> +			}

No, we are not doing random copy&pasta.

Split out the functionality into a function and use it both here and in
irq_set_affinity_locked().

Thanks,

        tglx

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

* Re: [RFC PATCH v2] genirq/cpuhotpug: notify of irq affinity change for offlined cpu.
  2026-01-13  9:24 ` Thomas Gleixner
@ 2026-01-13  9:24   ` Thomas Gleixner
  2026-01-13 14:41     ` imran.f.khan
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2026-01-13  9:24 UTC (permalink / raw)
  To: Imran Khan; +Cc: linux-kernel

On Tue, Jan 13 2026 at 10:24, Thomas Gleixner wrote:
> On Sat, Jan 03 2026 at 00:53, Imran Khan wrote:
>> +			if (affinity_broken && desc->affinity_notify) {
>> +				kref_get(&desc->affinity_notify->kref);
>> +				if (!schedule_work(&desc->affinity_notify->work)) {
>> +					/* Work was already scheduled, drop our extra ref */
>> +					kref_put(&desc->affinity_notify->kref,
>> +					desc->affinity_notify->release);
>> +				}
>> +			}
>
> No, we are not doing random copy&pasta.
>
> Split out the functionality into a function and use it both here and in
> irq_set_affinity_locked().

And while at it you might fix the typos in subject and change log.

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

* Re: [RFC PATCH v2] genirq/cpuhotpug: notify of irq affinity change for offlined cpu.
  2026-01-13  9:24   ` Thomas Gleixner
@ 2026-01-13 14:41     ` imran.f.khan
  0 siblings, 0 replies; 4+ messages in thread
From: imran.f.khan @ 2026-01-13 14:41 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel

Hello Thomas,
Thanks a lot for reviewing this patch.

On 13/1/2026 5:24 pm, Thomas Gleixner wrote:
> On Tue, Jan 13 2026 at 10:24, Thomas Gleixner wrote:
>> On Sat, Jan 03 2026 at 00:53, Imran Khan wrote:
>>> +			if (affinity_broken && desc->affinity_notify) {
>>> +				kref_get(&desc->affinity_notify->kref);
>>> +				if (!schedule_work(&desc->affinity_notify->work)) {
>>> +					/* Work was already scheduled, drop our extra ref */
>>> +					kref_put(&desc->affinity_notify->kref,
>>> +					desc->affinity_notify->release);
>>> +				}
>>> +			}
>>
>> No, we are not doing random copy&pasta.
>>
>> Split out the functionality into a function and use it both here and in
>> irq_set_affinity_locked().
> 
> And while at it you might fix the typos in subject and change log.

I have addressed your review comments and have sent a new (v3) version
of this patch at [1].
Could you please have a look and let me know if it looks okay now.

Thanks,
Imran

[1]: https://lore.kernel.org/all/20260113143727.1041265-1-imran.f.khan@oracle.com/

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

end of thread, other threads:[~2026-01-13 14:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-02 16:53 [RFC PATCH v2] genirq/cpuhotpug: notify of irq affinity change for offlined cpu Imran Khan
2026-01-13  9:24 ` Thomas Gleixner
2026-01-13  9:24   ` Thomas Gleixner
2026-01-13 14:41     ` imran.f.khan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.