Skip to contentSkip to conversation

add apic_irqs bitmap to identify irqs from apic

RFC PATCH In review Jason Chen 2 participants 3 messages Apr 21, 2014 – Apr 24, 2014

Subsystems (2)
lore
Share & tools
lore

Jason Chen

author
#0 lore raw

cover add apic_irqs bitmap to identify irqs from apic

During irq migration, irq_force_complete_move() will consider all irqs coming from apic kind of irq chip, but they may also coming from other irq chip, such kind of irqs should be filtered out.

Jason Chen (1):
x86/apic: add apic_irqs bitmap to identify irqs from apic

 arch/x86/kernel/apic/io_apic.c | 21 ++++++++++++++++++++-
 include/linux/irqdesc.h        |  6 ++++++
 kernel/irq/internals.h         |  6 ------
 3 files changed, 26 insertions(+), 7 deletions(-)
Signature · 1 line
1.8.1.2
author
#1 lore raw

RFC PATCH 1/1 x86/apic: add apic_irqs bitmap to identify irqs from apic

The function irq_force_complete_move() might handle irqs based on the non-apic irq_chip the way apic does, which has the structure irq_cfg as its chip_data.
Wrong operations on non-apic irq_chip might make its chip_data changed and bring unexpected issues.
Add apic_irqs bitmap to identify irqs from apic, and filter out all other irq_chips by checking this bitmap.

---
 arch/x86/kernel/apic/io_apic.c | 21 ++++++++++++++++++++-
 include/linux/irqdesc.h        |  6 ++++++
 kernel/irq/internals.h         |  6 ------
 3 files changed, 26 insertions(+), 7 deletions(-)
arch/x86/kernel/apic/io_apic.c +20 -1
index 6ad4658..1e2bcb5 100644
@@ -37,6 +37,7 @@
 #include <linux/kthread.h>
 #include <linux/jiffies.h>	/* time_after() */
 #include <linux/slab.h>
+#include <linux/irqdesc.h>
 #include <linux/bootmem.h>
 #include <linux/dmar.h>
 #include <linux/hpet.h>
@@ -74,6 +75,8 @@ int sis_apic_bug = -1;
 static DEFINE_RAW_SPINLOCK(ioapic_lock);
 static DEFINE_RAW_SPINLOCK(vector_lock);
 
+static DECLARE_BITMAP(apic_irqs, IRQ_BITMAP_BITS);
+
 static struct ioapic {
 	/*
 	 * # of IRQ routing registers
@@ -1158,6 +1161,10 @@ next:
 		err = 0;
 		break;
 	}
+
+	if (err == 0)
+		set_bit(irq, apic_irqs);
+
 	free_cpumask_var(tmp_mask);
 	return err;
 }
@@ -1185,6 +1192,7 @@ static void __clear_irq_vector(int irq, struct irq_cfg *cfg)
 
 	cfg->vector = 0;
 	cpumask_clear(cfg->domain);
+	clear_bit(irq, apic_irqs);
 
 	if (likely(!cfg->move_in_progress))
 		return;
@@ -1213,6 +1221,9 @@ void __setup_vector_irq(int cpu)
 	raw_spin_lock(&vector_lock);
 	/* Mark the inuse vectors */
 	for_each_active_irq(irq) {
+		if (!test_bit(irq, apic_irqs))
+			continue;
+
 		cfg = irq_get_chip_data(irq);
 		if (!cfg)
 			continue;
@@ -2268,7 +2279,12 @@ static void irq_complete_move(struct irq_cfg *cfg)
 
 void irq_force_complete_move(int irq)
 {
-	struct irq_cfg *cfg = irq_get_chip_data(irq);
+	struct irq_cfg *cfg;
+
+	if (!test_bit(irq, apic_irqs))
+		return;
+
+	cfg = irq_get_chip_data(irq);
 
 	if (!cfg)
 		return;
@@ -2541,6 +2557,9 @@ static inline void init_IO_APIC_traps(void)
 	 * 0x80, because int 0x80 is hm, kind of importantish. ;)
 	 */
 	for_each_active_irq(irq) {
+		if (!test_bit(irq, apic_irqs))
+			continue;
+
 		cfg = irq_get_chip_data(irq);
 		if (IO_APIC_IRQ(irq) && cfg && !cfg->vector) {
 			/*
include/linux/irqdesc.h +6 -0
index 26e2661..1b20979 100644
@@ -1,6 +1,12 @@
 #ifndef _LINUX_IRQDESC_H
 #define _LINUX_IRQDESC_H
 
+#ifdef CONFIG_SPARSE_IRQ
+# define IRQ_BITMAP_BITS	(NR_IRQS + 8196)
+#else
+# define IRQ_BITMAP_BITS	NR_IRQS
+#endif
+
 /*
  * Core internal functions to deal with irq descriptors
  *
kernel/irq/internals.h +0 -6
index ddf1ffe..b2fb994 100644
@@ -8,12 +8,6 @@
 #include <linux/irqdesc.h>
 #include <linux/kernel_stat.h>
 
-#ifdef CONFIG_SPARSE_IRQ
-# define IRQ_BITMAP_BITS	(NR_IRQS + 8196)
-#else
-# define IRQ_BITMAP_BITS	NR_IRQS
-#endif
-
 #define istate core_internal_state__do_not_mess_with_it
 
 extern bool noirqdebug;
Signature · 1 line
1.8.1.2
#2 lore raw

Re: [RFC PATCH 1/1] x86/apic: add apic_irqs bitmap to identify irqs from apic

Quoted 7 lines · Jason Chen

The function irq_force_complete_move() might handle irqs based on the non-apic irq_chip the way apic does, which has the structure irq_cfg as its chip_data.
Wrong operations on non-apic irq_chip might make its chip_data changed and bring unexpected issues.
Add apic_irqs bitmap to identify irqs from apic, and filter out all other irq_chips by checking this bitmap.

Please update the changelog to describe the current behavior, and how it affects your platform. (I.e. how do users notice, if at all?)

Then describe why you think that behavior should be changed. ie:
what's the reason for this patch.

Only then describe the details of the change itself.

Thanks,

Ingo