From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH] powerpc/irq: Improve/fix migrate_irqs()
Date: Tue, 07 Feb 2017 11:36:44 +1100 [thread overview]
Message-ID: <1486427804.4850.104.camel@kernel.crashing.org> (raw)
migrate_irqs() is used by some platforms to migrate interrupts
away from a CPU about to be offlined.
The current implementation had various issues such as not taking
the descriptor lock before manipulating it. This refactors it
a bit, fixing that problem at the same time.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/kernel/irq.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index a018f5c..52308b4 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -456,22 +456,31 @@ void migrate_irqs(void)
for_each_irq_desc(irq, desc) {
struct irq_data *data;
struct irq_chip *chip;
+ const struct cpumask *affinity;
- data = irq_desc_get_irq_data(desc);
- if (irqd_is_per_cpu(data))
- continue;
+ /* Interrupts are already disabled */
+ raw_spin_lock(&desc->lock);
+ data = irq_desc_get_irq_data(desc);
+ affinity = irq_data_get_affinity_mask(data);
chip = irq_data_get_irq_chip(data);
+ if (!irq_has_action(irq) || irqd_is_per_cpu(data) ||
+ cpumask_subset(affinity, cpu_online_mask) ||
+ !chip) {
+ raw_spin_unlock(&desc->lock);
+ continue;
+ }
- cpumask_and(mask, irq_data_get_affinity_mask(data), map);
- if (cpumask_any(mask) >= nr_cpu_ids) {
+ cpumask_and(mask, affinity, map);
+ if (cpumask_empty(mask)) {
pr_warn("Breaking affinity for irq %i\n", irq);
cpumask_copy(mask, map);
}
if (chip->irq_set_affinity)
chip->irq_set_affinity(data, mask, true);
else if (desc->action && !(warned++))
- pr_err("Cannot set affinity for irq %i\n", irq);
+ pr_debug("Cannot set affinity for irq %i\n", irq);
+ raw_spin_unlock(&desc->lock);
}
free_cpumask_var(mask);
next reply other threads:[~2017-02-07 0:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 0:36 Benjamin Herrenschmidt [this message]
2017-02-08 10:02 ` [PATCH] powerpc/irq: Improve/fix migrate_irqs() Michael Ellerman
2017-02-09 0:40 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486427804.4850.104.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).