<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/kernel/irq/cpuhotplug.c, branch linux-6.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-06-13T13:13:35Z</updated>
<entry>
<title>genirq/cpuhotplug: Restore affinity even for suspended IRQ</title>
<updated>2025-06-13T13:13:35Z</updated>
<author>
<name>Brian Norris</name>
</author>
<published>2025-06-12T18:32:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=72218d74c9c57b8ea36c2a58875dff406fc10462'/>
<id>urn:sha1:72218d74c9c57b8ea36c2a58875dff406fc10462</id>
<content type='text'>
Commit 788019eb559f ("genirq: Retain disable depth for managed interrupts
across CPU hotplug") tried to make managed shutdown/startup properly
reference counted, but it missed the fact that the unplug and hotplug code
has an intentional imbalance by skipping IRQS_SUSPENDED interrupts on
the "restore" path.

This means that if a managed-affinity interrupt was both suspended and
managed-shutdown (such as may happen during system suspend / S3), resume
skips calling irq_startup_managed(), and would again have an unbalanced
depth this time, with a positive value (i.e., remaining unexpectedly
masked).

This IRQS_SUSPENDED check was introduced in commit a60dd06af674
("genirq/cpuhotplug: Skip suspended interrupts when restoring affinity")
for essentially the same reason as commit 788019eb559f, to prevent that
irq_startup() would unconditionally re-enable an interrupt too early.

Because irq_startup_managed() now respsects the disable-depth count, the
IRQS_SUSPENDED check is not longer needed, and instead, it causes harm.

Thus, drop the IRQS_SUSPENDED check, and restore balance.

This effectively reverts commit a60dd06af674 ("genirq/cpuhotplug: Skip
suspended interrupts when restoring affinity"), because it is replaced
by commit 788019eb559f ("genirq: Retain disable depth for managed
interrupts across CPU hotplug").

Fixes: 788019eb559f ("genirq: Retain disable depth for managed interrupts across CPU hotplug")
Reported-by: Aleksandrs Vinarskis &lt;alex.vinarskis@gmail.com&gt;
Signed-off-by: Brian Norris &lt;briannorris@chromium.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Aleksandrs Vinarskis &lt;alex.vinarskis@gmail.com&gt;
Link: https://lore.kernel.org/all/20250612183303.3433234-3-briannorris@chromium.org
Closes: https://lore.kernel.org/lkml/24ec4adc-7c80-49e9-93ee-19908a97ab84@gmail.com/
</content>
</entry>
<entry>
<title>genirq: Retain disable depth for managed interrupts across CPU hotplug</title>
<updated>2025-05-15T14:44:25Z</updated>
<author>
<name>Brian Norris</name>
</author>
<published>2025-05-14T20:13:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=788019eb559fd0b365f501467ceafce540e377cc'/>
<id>urn:sha1:788019eb559fd0b365f501467ceafce540e377cc</id>
<content type='text'>
Affinity-managed interrupts can be shut down and restarted during CPU
hotunplug/plug. Thereby the interrupt may be left in an unexpected state.
Specifically:

 1. Interrupt is affine to CPU N
 2. disable_irq() -&gt; depth is 1
 3. CPU N goes offline
 4. irq_shutdown() -&gt; depth is set to 1 (again)
 5. CPU N goes online
 6. irq_startup() -&gt; depth is set to 0 (BUG! driver expects that the interrupt
    		     	      	        still disabled)
 7. enable_irq() -&gt; depth underflow / unbalanced enable_irq() warning

This is only a problem for managed interrupts and CPU hotplug, all other
cases like request()/free()/request() truly needs to reset a possibly stale
disable depth value.

Provide a startup function, which takes the disable depth into account, and
invoked it for the managed interrupts in the CPU hotplug path.

This requires to change irq_shutdown() to do a depth increment instead of
setting it to 1, which allows to retain the disable depth, but is harmless
for the other code paths using irq_startup(), which will still reset the
disable depth unconditionally to keep the original correct behaviour.

A kunit tests will be added separately to cover some of these aspects.

[ tglx: Massaged changelog ]

Suggested-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Brian Norris &lt;briannorris@chromium.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20250514201353.3481400-2-briannorris@chromium.org
</content>
</entry>
<entry>
<title>genirq/cpuhotplug: Fix up lock guards conversion brainf..t</title>
<updated>2025-05-08T10:05:38Z</updated>
<author>
<name>Thomas Gleixner</name>
</author>
<published>2025-05-08T10:05:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c855506257063f444044d0a85a2e9ad9ab1c7ecd'/>
<id>urn:sha1:c855506257063f444044d0a85a2e9ad9ab1c7ecd</id>
<content type='text'>
The lock guard conversion converted raw_spin_lock_irq() to
scoped_guard(raw_spinlock), which is obviously bogus and makes lockdep
mightily unhappy.

Note to self: Copy and pasta without using brain is a patently bad idea.

Fixes: 88a4df117ad6 ("genirq/cpuhotplug: Convert to lock guards")
Reported-by: Borislav Petkov &lt;bp@alien8.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Borislav Petkov &lt;bp@alien8.de&gt;
</content>
</entry>
<entry>
<title>genirq/cpuhotplug: Convert to lock guards</title>
<updated>2025-05-07T07:08:12Z</updated>
<author>
<name>Thomas Gleixner</name>
</author>
<published>2025-04-29T06:55:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=88a4df117ad66100d0f870aa02032dfb9cb29179'/>
<id>urn:sha1:88a4df117ad66100d0f870aa02032dfb9cb29179</id>
<content type='text'>
Convert all lock/unlock pairs to guards and tidy up the code.

No functional change.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/all/20250429065420.560083665@linutronix.de


</content>
</entry>
<entry>
<title>genirq/cpuhotplug: Use cpumask_intersects()</title>
<updated>2024-09-06T14:28:39Z</updated>
<author>
<name>Costa Shulyupin</name>
</author>
<published>2024-09-04T13:48:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=87b5a153b862b7d937fc1dd499368297a1feae87'/>
<id>urn:sha1:87b5a153b862b7d937fc1dd499368297a1feae87</id>
<content type='text'>
Replace `cpumask_any_and(a, b) &gt;= nr_cpu_ids`
with the more readable `!cpumask_intersects(a, b)`.

[ tglx: Massaged change log ]

Signed-off-by: Costa Shulyupin &lt;costa.shul@redhat.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Link: https://lore.kernel.org/all/20240904134823.777623-2-costa.shul@redhat.com
</content>
</entry>
<entry>
<title>genirq/cpuhotplug, x86/vector: Prevent vector leak during CPU offline</title>
<updated>2024-05-23T19:51:50Z</updated>
<author>
<name>Dongli Zhang</name>
</author>
<published>2024-05-22T22:02:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a6c11c0a5235fb144a65e0cb2ffd360ddc1f6c32'/>
<id>urn:sha1:a6c11c0a5235fb144a65e0cb2ffd360ddc1f6c32</id>
<content type='text'>
The absence of IRQD_MOVE_PCNTXT prevents immediate effectiveness of
interrupt affinity reconfiguration via procfs. Instead, the change is
deferred until the next instance of the interrupt being triggered on the
original CPU.

When the interrupt next triggers on the original CPU, the new affinity is
enforced within __irq_move_irq(). A vector is allocated from the new CPU,
but the old vector on the original CPU remains and is not immediately
reclaimed. Instead, apicd-&gt;move_in_progress is flagged, and the reclaiming
process is delayed until the next trigger of the interrupt on the new CPU.

Upon the subsequent triggering of the interrupt on the new CPU,
irq_complete_move() adds a task to the old CPU's vector_cleanup list if it
remains online. Subsequently, the timer on the old CPU iterates over its
vector_cleanup list, reclaiming old vectors.

However, a rare scenario arises if the old CPU is outgoing before the
interrupt triggers again on the new CPU.

In that case irq_force_complete_move() is not invoked on the outgoing CPU
to reclaim the old apicd-&gt;prev_vector because the interrupt isn't currently
affine to the outgoing CPU, and irq_needs_fixup() returns false. Even
though __vector_schedule_cleanup() is later called on the new CPU, it
doesn't reclaim apicd-&gt;prev_vector; instead, it simply resets both
apicd-&gt;move_in_progress and apicd-&gt;prev_vector to 0.

As a result, the vector remains unreclaimed in vector_matrix, leading to a
CPU vector leak.

To address this issue, move the invocation of irq_force_complete_move()
before the irq_needs_fixup() call to reclaim apicd-&gt;prev_vector, if the
interrupt is currently or used to be affine to the outgoing CPU.

Additionally, reclaim the vector in __vector_schedule_cleanup() as well,
following a warning message, although theoretically it should never see
apicd-&gt;move_in_progress with apicd-&gt;prev_cpu pointing to an offline CPU.

Fixes: f0383c24b485 ("genirq/cpuhotplug: Add support for cleaning up move in progress")
Signed-off-by: Dongli Zhang &lt;dongli.zhang@oracle.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240522220218.162423-1-dongli.zhang@oracle.com
</content>
</entry>
<entry>
<title>genirq/cpuhotplug: Retry with cpu_online_mask when migration fails</title>
<updated>2024-04-24T18:42:57Z</updated>
<author>
<name>Dongli Zhang</name>
</author>
<published>2024-04-23T07:34:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=88d724e2301a69c1ab805cd74fc27aa36ae529e0'/>
<id>urn:sha1:88d724e2301a69c1ab805cd74fc27aa36ae529e0</id>
<content type='text'>
When a CPU goes offline, the interrupts affine to that CPU are
re-configured.

Managed interrupts undergo either migration to other CPUs or shutdown if
all CPUs listed in the affinity are offline. The migration of managed
interrupts is guaranteed on x86 because there are interrupt vectors
reserved.

Regular interrupts are migrated to a still online CPU in the affinity mask
or if there is no online CPU to any online CPU.

This works as long as the still online CPUs in the affinity mask have
interrupt vectors available, but in case that none of those CPUs has a
vector available the migration fails and the device interrupt becomes
stale.

This is not any different from the case where the affinity mask does not
contain any online CPU, but there is no fallback operation for this.

Instead of giving up, retry the migration attempt with the online CPU mask
if the interrupt is not managed, as managed interrupts cannot be affected
by this problem.

Signed-off-by: Dongli Zhang &lt;dongli.zhang@oracle.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/r/20240423073413.79625-1-dongli.zhang@oracle.com
</content>
</entry>
<entry>
<title>genirq/cpuhotplug: Skip suspended interrupts when restoring affinity</title>
<updated>2024-04-24T18:42:57Z</updated>
<author>
<name>David Stevens</name>
</author>
<published>2024-04-24T09:03:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a60dd06af674d3bb76b40da5d722e4a0ecefe650'/>
<id>urn:sha1:a60dd06af674d3bb76b40da5d722e4a0ecefe650</id>
<content type='text'>
irq_restore_affinity_of_irq() restarts managed interrupts unconditionally
when the first CPU in the affinity mask comes online. That's correct during
normal hotplug operations, but not when resuming from S3 because the
drivers are not resumed yet and interrupt delivery is not expected by them.

Skip the startup of suspended interrupts and let resume_device_irqs() deal
with restoring them. This ensures that irqs are not delivered to drivers
during the noirq phase of resuming from S3, after non-boot CPUs are brought
back online.

Signed-off-by: David Stevens &lt;stevensd@chromium.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/r/20240424090341.72236-1-stevensd@chromium.org
</content>
</entry>
<entry>
<title>sched/isolation: Use single feature type while referring to housekeeping cpumask</title>
<updated>2022-02-16T14:57:55Z</updated>
<author>
<name>Frederic Weisbecker</name>
</author>
<published>2022-02-07T15:59:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=04d4e665a60902cf36e7ad39af1179cb5df542ad'/>
<id>urn:sha1:04d4e665a60902cf36e7ad39af1179cb5df542ad</id>
<content type='text'>
Refer to housekeeping APIs using single feature types instead of flags.
This prevents from passing multiple isolation features at once to
housekeeping interfaces, which soon won't be possible anymore as each
isolation features will have their own cpumask.

Signed-off-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Juri Lelli &lt;juri.lelli@redhat.com&gt;
Reviewed-by: Phil Auld &lt;pauld@redhat.com&gt;
Link: https://lore.kernel.org/r/20220207155910.527133-5-frederic@kernel.org
</content>
</entry>
<entry>
<title>genirq/cpuhotplug: Demote debug printk to KERN_DEBUG</title>
<updated>2021-08-24T07:16:20Z</updated>
<author>
<name>Lee Jones</name>
</author>
<published>2021-08-16T13:48:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=88ffe2d0a55a165e55cedad1693f239d47e3e17e'/>
<id>urn:sha1:88ffe2d0a55a165e55cedad1693f239d47e3e17e</id>
<content type='text'>
This sort of information is only generally useful when debugging.
No need to have these sprinkled through the kernel log otherwise.

Real world problem:

  During pre-release testing these have an affect on performance on
  real products.  To the point where so much logging builds up, that
  it sets off the watchdog(s) on some high profile consumer devices.

Signed-off-by: Lee Jones &lt;lee.jones@linaro.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/r/20210816134817.1503661-1-lee.jones@linaro.org
</content>
</entry>
</feed>
