From 27d0a53142b88a471af323c237cadb7e9edb4e8b Mon Sep 17 00:00:00 2001 From: zyf1116 Date: Fri, 11 Apr 2025 17:55:59 +0800 Subject: [PATCH 1/2] Revert "genirq/cpuhotplug: Retry with cpu_online_mask when migration fails" This reverts commit 6e1801d8158d1c9a6588f9f898dbc827cfa2be3e. Signed-off-by: zyf1116 --- kernel/irq/cpuhotplug.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c index 4db263debb39..34ffcd8eb0d2 100644 --- a/kernel/irq/cpuhotplug.c +++ b/kernel/irq/cpuhotplug.c @@ -168,31 +168,17 @@ static bool migrate_one_irq(struct irq_desc *desc) #endif brokeaff = true; } - /* - * If there are online CPUs in the affinity mask, but they have no - * vectors left to make the migration work, try to break the - * affinity by migrating to any online CPU. + * Do not set the force argument of irq_do_set_affinity() as this + * disables the masking of offline CPUs from the supplied affinity + * mask and therefore might keep/reassign the irq to the outgoing + * CPU. */ - if (err == -ENOSPC && !irqd_affinity_is_managed(d) && affinity != cpu_online_mask) { - pr_debug("IRQ%u: set affinity failed for %*pbl, re-try with online CPUs\n", - d->irq, cpumask_pr_args(affinity)); - - affinity = cpu_online_mask; - brokeaff = true; - /* - * Do not set the force argument of irq_do_set_affinity() as this - * disables the masking of offline CPUs from the supplied affinity - * mask and therefore might keep/reassign the irq to the outgoing - * CPU. - */ #ifdef CONFIG_CPU_ISOLATION_OPT - err = irq_set_affinity_locked(d, affinity, false); + err = irq_set_affinity_locked(d, affinity, false); #else - err = irq_do_set_affinity(d, affinity, false); + err = irq_do_set_affinity(d, affinity, false); #endif - } - if (err) { pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n", d->irq, err); -- Gitee From b3ae047b91f648eefa93ca16d31115702943959b Mon Sep 17 00:00:00 2001 From: Dongli Zhang Date: Tue, 23 Apr 2024 00:34:13 -0700 Subject: [PATCH 2/2] genirq/cpuhotplug: Retry with cpu_online_mask when migration fails stable inclusion from stable-v6.6.47 commit bcd51480439499d5f8605ba2f3edb5bd0dd81fd8 category: bugfix issue: #IBO43T CVE: NA Signed-off-by: zyf1116 --------------------------------------- commit 88d724e2301a69c1ab805cd74fc27aa36ae529e0 upstream. 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 Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20240423073413.79625-1-dongli.zhang@oracle.com Cc: Bart Van Assche Signed-off-by: Greg Kroah-Hartman Signed-off-by: zyf1116 --- kernel/irq/cpuhotplug.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c index 34ffcd8eb0d2..f8440eab6347 100644 --- a/kernel/irq/cpuhotplug.c +++ b/kernel/irq/cpuhotplug.c @@ -179,6 +179,22 @@ static bool migrate_one_irq(struct irq_desc *desc) #else err = irq_do_set_affinity(d, affinity, false); #endif + + /* + * If there are online CPUs in the affinity mask, but they have no + * vectors left to make the migration work, try to break the + * affinity by migrating to any online CPU. + */ + if (err == -ENOSPC && !irqd_affinity_is_managed(d) && affinity != cpu_online_mask) { + pr_debug("IRQ%u: set affinity failed for %*pbl, re-try with online CPUs\n", + d->irq, cpumask_pr_args(affinity)); + + affinity = cpu_online_mask; + brokeaff = true; + + err = irq_do_set_affinity(d, affinity, false); + } + if (err) { pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n", d->irq, err); -- Gitee