]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
genirq: Provide irq_fixup_move_pending()
authorThomas Gleixner <tglx@linutronix.de>
Mon, 19 Jun 2017 23:37:19 +0000 (01:37 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 22 Jun 2017 16:21:13 +0000 (18:21 +0200)
If an CPU goes offline, the interrupts are migrated away, but a eventually
pending interrupt move, which has not yet been made effective is kept
pending even if the outgoing CPU is the sole target of the pending affinity
mask. What's worse is, that the pending affinity mask is discarded even if
it would contain a valid subset of the online CPUs.

Implement a helper function which allows to avoid these issues.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>
Link: http://lkml.kernel.org/r/20170619235444.691345468@linutronix.de
include/linux/irq.h
kernel/irq/migration.c

index 7e62e10e5856899cb1c5d968f232ac5eb588604b..d008065e2f4daa2b3d292653b8b777af2909de73 100644 (file)
@@ -491,9 +491,14 @@ extern void irq_migrate_all_off_this_cpu(void);
 #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ)
 void irq_move_irq(struct irq_data *data);
 void irq_move_masked_irq(struct irq_data *data);
+bool irq_fixup_move_pending(struct irq_desc *desc, bool force_clear);
 #else
 static inline void irq_move_irq(struct irq_data *data) { }
 static inline void irq_move_masked_irq(struct irq_data *data) { }
+static inline bool irq_fixup_move_pending(struct irq_desc *desc, bool fclear)
+{
+       return false;
+}
 #endif
 
 extern int no_irq_affinity;
index 37ddb7bda6517ac7cc8df9d9c63e31513d55f73e..6ca054a3f91dd6a874d023ce583b574c22178686 100644 (file)
@@ -4,6 +4,36 @@
 
 #include "internals.h"
 
+/**
+ * irq_fixup_move_pending - Cleanup irq move pending from a dying CPU
+ * @desc:              Interrupt descpriptor to clean up
+ * @force_clear:       If set clear the move pending bit unconditionally.
+ *                     If not set, clear it only when the dying CPU is the
+ *                     last one in the pending mask.
+ *
+ * Returns true if the pending bit was set and the pending mask contains an
+ * online CPU other than the dying CPU.
+ */
+bool irq_fixup_move_pending(struct irq_desc *desc, bool force_clear)
+{
+       struct irq_data *data = irq_desc_get_irq_data(desc);
+
+       if (!irqd_is_setaffinity_pending(data))
+               return false;
+
+       /*
+        * The outgoing CPU might be the last online target in a pending
+        * interrupt move. If that's the case clear the pending move bit.
+        */
+       if (cpumask_any_and(desc->pending_mask, cpu_online_mask) >= nr_cpu_ids) {
+               irqd_clr_move_pending(data);
+               return false;
+       }
+       if (force_clear)
+               irqd_clr_move_pending(data);
+       return true;
+}
+
 void irq_move_masked_irq(struct irq_data *idata)
 {
        struct irq_desc *desc = irq_data_to_desc(idata);