Skip to contentSkip to conversation

allow efficient allocation of multiple CPU masks at once

PATCH In review Jan Beulich 1 participant 1 message Oct 20, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 6/12 allow efficient allocation of multiple CPU masks at once

This is to better amortize the cost of storing an extra pointer when dynamically allocating CPU masks: If a certain entity (struct irq_desc being the first user) wants multiple, it can get away with holding just a single pointer, which is especially beneficial when a hypervisor with large NR_CPUS gets run on systems with a relatively small number of actual CPUs.

If rationale, concept, and implementation are deemed reasonable, this could/should also be used for the three CPU masks that get allocated per vCPU.

xen/arch/ia64/linux-xen/irq_ia64.c +3 -0
@@ -303,6 +303,9 @@ int __init request_irq_vector(unsigned i
 void __init
 init_IRQ (void)
 {
+#ifdef XEN
+	BUG_ON(init_irq_data());
+#endif
 	register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
 #ifdef CONFIG_SMP
 	register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction);
xen/arch/ia64/xen/irq.c +20 -10
@@ -74,17 +74,27 @@ unsigned int __ia64_local_vector_to_irq 
 /*
  * Controller mappings for all interrupt sources:
  */
-irq_desc_t irq_desc[NR_IRQS] = {
-	[0 ... NR_IRQS-1] = {
-		.status = IRQ_DISABLED,
-		.handler = &no_irq_type,
-		.lock = SPIN_LOCK_UNLOCKED
-		.arch = {
-		        .vector = -1,
-		        .cpu_mask = CPU_MASK_ALL,
-		}
+irq_desc_t irq_desc[NR_IRQS];
+
+int __init arch_init_one_irq_desc(struct irq_desc *desc)
+{
+	desc->arch.vector = -1;
+	cpumask_setall(irq_desc_cpu_mask(desc));
+
+	return 0;
+}
+
+int __init init_irq_data(void)
+{
+	unsigned int irq;
+
+	for (irq = 0; irq < NR_IRQS; irq++) {
+		struct irq_desc *desc = irq_to_desc(irq);
+
+		desc->irq = irq;
+		init_one_irq_desc(desc);
 	}
-};
+}
 
 void __do_IRQ_guest(int irq);
 
xen/arch/x86/i8259.c +1 -1
@@ -398,7 +398,7 @@ void __init init_IRQ(void)
         
         desc->handler = &i8259A_irq_type;
         per_cpu(vector_irq, cpu)[FIRST_LEGACY_VECTOR + irq] = irq;
-        cpumask_copy(&desc->arch.cpu_mask, cpumask_of(cpu));
+        cpumask_copy(irq_desc_cpu_mask(desc), cpumask_of(cpu));
         desc->arch.vector = FIRST_LEGACY_VECTOR + irq;
     }
     
xen/arch/x86/io_apic.c +9 -8
@@ -648,20 +648,21 @@ static int pin_2_irq(int idx, int apic, 
 void /*__init*/ setup_ioapic_dest(void)
 {
     int pin, ioapic, irq, irq_entry;
-    struct irq_cfg *cfg;
 
     if (skip_ioapic_setup)
         return;
 
     for (ioapic = 0; ioapic < nr_ioapics; ioapic++) {
         for (pin = 0; pin < nr_ioapic_entries[ioapic]; pin++) {
+            struct irq_desc *desc;
+
             irq_entry = find_irq_entry(ioapic, pin, mp_INT);
             if (irq_entry == -1)
                 continue;
             irq = pin_2_irq(irq_entry, ioapic, pin);
-            cfg = irq_cfg(irq);
-            BUG_ON(cpus_empty(cfg->cpu_mask));
-            set_ioapic_affinity_irq(irq_to_desc(irq), &cfg->cpu_mask);
+            desc = irq_to_desc(irq);
+            BUG_ON(cpumask_empty(irq_desc_cpu_mask(desc)));
+            set_ioapic_affinity_irq(desc, irq_desc_cpu_mask(desc));
         }
 
     }
@@ -956,12 +957,12 @@ static void __init setup_IO_APIC_irqs(vo
     struct IO_APIC_route_entry entry;
     int apic, pin, idx, irq, first_notcon = 1, vector;
     unsigned long flags;
-    struct irq_cfg *cfg;
 
     apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
 
     for (apic = 0; apic < nr_ioapics; apic++) {
         for (pin = 0; pin < nr_ioapic_entries[apic]; pin++) {
+            struct irq_desc *desc;
 
             /*
              * add it to the IO-APIC irq-routing table:
@@ -1016,9 +1017,9 @@ static void __init setup_IO_APIC_irqs(vo
                 if (!apic && platform_legacy_irq(irq))
                     disable_8259A_irq(irq_to_desc(irq));
             }
-            cfg = irq_cfg(irq);
+            desc = irq_to_desc(irq);
             SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-                     cpu_mask_to_apicid(&cfg->cpu_mask));
+                     cpu_mask_to_apicid(irq_desc_cpu_mask(desc)));
             spin_lock_irqsave(&ioapic_lock, flags);
             __ioapic_write_entry(apic, pin, 0, entry);
             set_native_irq_info(irq, TARGET_CPUS);
@@ -2372,7 +2373,7 @@ int ioapic_guest_write(unsigned long phy
     rte.vector = cfg->vector;
 
     SET_DEST(rte.dest.dest32, rte.dest.logical.logical_dest,
-             cpu_mask_to_apicid(&cfg->cpu_mask));
+             cpu_mask_to_apicid(irq_desc_cpu_mask(desc)));
 
     io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&rte) + 0));
     io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&rte) + 1));
xen/arch/x86/irq.c +94 -92

424 lines not on this page · raw message

xen/arch/x86/msi.c +2 -2
@@ -125,13 +125,13 @@ void msi_compose_msg(struct irq_desc *de
     unsigned dest;
     int vector = desc->arch.vector;
 
-    if ( cpumask_empty(&desc->arch.cpu_mask) ) {
+    if ( cpumask_empty(irq_desc_cpu_mask(desc)) ) {
         dprintk(XENLOG_ERR,"%s, compose msi message error!!\n", __func__);
         return;
     }
 
     if ( vector ) {
-        dest = cpu_mask_to_apicid(&desc->arch.cpu_mask);
+        dest = cpu_mask_to_apicid(irq_desc_cpu_mask(desc));
 
         msg->address_hi = MSI_ADDR_BASE_HI;
         msg->address_lo =
xen/arch/x86/smpboot.c +1 -1
@@ -1011,7 +1011,7 @@ void __init smp_intr_init(void)
         irq_vector[irq] = FIRST_HIPRIORITY_VECTOR + seridx + 1;
         per_cpu(vector_irq, cpu)[FIRST_HIPRIORITY_VECTOR + seridx + 1] = irq;
         irq_to_desc(irq)->arch.vector = FIRST_HIPRIORITY_VECTOR + seridx + 1;
-        cpumask_copy(&irq_to_desc(irq)->arch.cpu_mask, &cpu_online_map);
+        cpumask_copy(irq_desc_cpu_mask(irq_to_desc(irq)), &cpu_online_map);
     }
 
     /* IPI for cleanuping vectors after irq move */
xen/common/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-y += domctl.o
 obj-y += domain.o
 obj-y += event_channel.o
 obj-y += grant_table.o
+obj-y += irq.o
 obj-y += kernel.o
 obj-y += keyhandler.o
 obj-y += kexec.o
xen/common/irq.c new file +18 -0
@@ -0,0 +1,18 @@
+#include <xen/config.h>
+#include <xen/irq.h>
+
+int init_one_irq_desc(struct irq_desc *desc)
+{
+    if (irq_desc_initialized(desc))
+        return 0;
+
+    desc->status = IRQ_DISABLED;
+    desc->handler = &no_irq_type;
+    spin_lock_init(&desc->lock);
+    if ( !alloc_cpumask_array(desc->cpumasks) )
+        return -ENOMEM;
+    cpumask_setall(irq_desc_affinity(desc));
+    INIT_LIST_HEAD(&desc->rl_link);
+
+    return arch_init_one_irq_desc(desc);
+}
xen/drivers/passthrough/vtd/iommu.c +4 -3
@@ -1965,17 +1965,18 @@ static int init_vtd_hw(void)
     struct iommu_flush *flush = NULL;
     int ret;
     unsigned long flags;
-    struct irq_cfg *cfg;
 
     /*
      * Basic VT-d HW init: set VT-d interrupt, clear VT-d faults.  
      */
     for_each_drhd_unit ( drhd )
     {
+        struct irq_desc *desc;
+
         iommu = drhd->iommu;
 
-        cfg = irq_cfg(iommu->irq);
-        dma_msi_set_affinity(irq_to_desc(iommu->irq), &cfg->cpu_mask);
+        desc = irq_to_desc(iommu->irq);
+        dma_msi_set_affinity(desc, irq_desc_cpu_mask(desc));
 
         clear_fault_bits(iommu);
 
xen/include/asm-ia64/linux-xen/asm/irq.h +5 -1
@@ -18,8 +18,12 @@
 struct irq_cfg {
 #define arch_irq_desc irq_cfg
         int  vector;
-        cpumask_t cpu_mask;
 };
+
+#define ARCH_IRQ_DESC_NR_CPUMASKS 1
+#define irq_desc_cpu_mask(desc) arch_irq_desc_cpumask(desc, 0)
+
+int init_irq_data(void);
 #endif
 
 static __inline__ int
xen/include/asm-x86/irq.h +5 -4
@@ -33,14 +33,17 @@ struct irq_cfg {
 #define arch_irq_desc irq_cfg
         s16 vector;                  /* vector itself is only 8 bits, */
         s16 old_vector;              /* but we use -1 for unassigned  */
-        cpumask_t cpu_mask;
-        cpumask_t old_cpu_mask;
         unsigned move_cleanup_count;
         vmask_t *used_vectors;
         u8 move_in_progress : 1;
         u8 used: 1;
 };
 
+#define ARCH_IRQ_DESC_NR_CPUMASKS 3
+#define irq_desc_cpu_mask(desc)     arch_irq_desc_cpumask(desc, 0)
+#define irq_desc_old_cpu_mask(desc) arch_irq_desc_cpumask(desc, 1)
+#define irq_desc_pending_mask(desc) arch_irq_desc_cpumask(desc, 2)
+
 /* For use with irq_cfg.used */
 #define IRQ_UNUSED      (0)
 #define IRQ_USED        (1)
@@ -174,8 +177,6 @@ void __setup_vector_irq(int cpu);
 void move_native_irq(struct irq_desc *);
 void move_masked_irq(struct irq_desc *);
 
-int __assign_irq_vector(int irq, struct irq_cfg *, const cpumask_t *);
-
 int bind_irq_vector(int irq, int vector, const cpumask_t *);
 
 void irq_set_affinity(struct irq_desc *, const cpumask_t *mask);
xen/include/xen/cpumask.h +56 -0

68 lines not on this page · raw message

xen/include/xen/irq.h +19 -3
@@ -63,6 +63,17 @@ extern unsigned int nr_irqs;
 #endif
 
 struct msi_desc;
+
+#define ARCH_IRQ_DESC_FIRST_CPUMASK 1
+#ifndef ARCH_IRQ_DESC_NR_CPUMASKS
+#define ARCH_IRQ_DESC_NR_CPUMASKS 0
+#endif
+
+#define irq_desc_cpumask(desc, idx) cpumask_array_index((desc)->cpumasks, idx)
+#define irq_desc_affinity(desc) irq_desc_cpumask(desc, 0)
+#define arch_irq_desc_cpumask(desc, idx) \
+    irq_desc_cpumask(desc, ARCH_IRQ_DESC_FIRST_CPUMASK + (idx))
+
 /*
  * This is the "IRQ descriptor", which contains various information
  * about the irq, including what kind of hardware handling it has,
@@ -76,8 +87,8 @@ typedef struct irq_desc {
     int irq;
     spinlock_t lock;
     struct arch_irq_desc arch;
-    cpumask_t affinity;
-    cpumask_t pending_mask;  /* IRQ migration pending mask */
+    DECLARE_CPUMASK_ARRAY(cpumasks,
+        ARCH_IRQ_DESC_FIRST_CPUMASK + ARCH_IRQ_DESC_NR_CPUMASKS);
 
     /* irq ratelimit */
     s_time_t rl_quantum_start;
@@ -85,6 +96,11 @@ typedef struct irq_desc {
     struct list_head rl_link;
 } __cacheline_aligned irq_desc_t;
 
+int init_one_irq_desc(struct irq_desc *);
+int arch_init_one_irq_desc(struct irq_desc *);
+
+#define irq_desc_initialized(desc) ((desc)->handler != NULL)
+
 #if defined(__ia64__)
 extern irq_desc_t irq_desc[NR_VECTORS];
 
@@ -153,7 +169,7 @@ extern irq_desc_t *pirq_spin_lock_irq_de
 
 static inline void set_native_irq_info(unsigned int irq, const cpumask_t *mask)
 {
-    cpumask_copy(&irq_desc[irq].affinity, mask);
+    cpumask_copy(irq_desc_affinity(irq_to_desc(irq)), mask);
 }
 
 unsigned int set_desc_affinity(struct irq_desc *, const cpumask_t *);

allow efficient allocation of multiple CPU masks at once

This is to better amortize the cost of storing an extra pointer when dynamically allocating CPU masks: If a certain entity (struct irq_desc being the first user) wants multiple, it can get away with holding just a single pointer, which is especially beneficial when a hypervisor with large NR_CPUS gets run on systems with a relatively small number of actual CPUs.

If rationale, concept, and implementation are deemed reasonable, this could/should also be used for the three CPU masks that get allocated per vCPU.

xen/arch/ia64/linux-xen/irq_ia64.c +3 -0
@@ -303,6 +303,9 @@ int __init request_irq_vector(unsigned i
 void __init
 init_IRQ (void)
 {
+#ifdef XEN
+	BUG_ON(init_irq_data());
+#endif
 	register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
 #ifdef CONFIG_SMP
 	register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction);
xen/arch/ia64/xen/irq.c +20 -10
@@ -74,17 +74,27 @@ unsigned int __ia64_local_vector_to_irq 
 /*
  * Controller mappings for all interrupt sources:
  */
-irq_desc_t irq_desc[NR_IRQS] = {
-	[0 ... NR_IRQS-1] = {
-		.status = IRQ_DISABLED,
-		.handler = &no_irq_type,
-		.lock = SPIN_LOCK_UNLOCKED
-		.arch = {
-		        .vector = -1,
-		        .cpu_mask = CPU_MASK_ALL,
-		}
+irq_desc_t irq_desc[NR_IRQS];
+
+int __init arch_init_one_irq_desc(struct irq_desc *desc)
+{
+	desc->arch.vector = -1;
+	cpumask_setall(irq_desc_cpu_mask(desc));
+
+	return 0;
+}
+
+int __init init_irq_data(void)
+{
+	unsigned int irq;
+
+	for (irq = 0; irq < NR_IRQS; irq++) {
+		struct irq_desc *desc = irq_to_desc(irq);
+
+		desc->irq = irq;
+		init_one_irq_desc(desc);
 	}
-};
+}
 
 void __do_IRQ_guest(int irq);
 
xen/arch/x86/i8259.c +1 -1
@@ -398,7 +398,7 @@ void __init init_IRQ(void)
         
         desc->handler = &i8259A_irq_type;
         per_cpu(vector_irq, cpu)[FIRST_LEGACY_VECTOR + irq] = irq;
-        cpumask_copy(&desc->arch.cpu_mask, cpumask_of(cpu));
+        cpumask_copy(irq_desc_cpu_mask(desc), cpumask_of(cpu));
         desc->arch.vector = FIRST_LEGACY_VECTOR + irq;
     }
     
xen/arch/x86/io_apic.c +9 -8
@@ -648,20 +648,21 @@ static int pin_2_irq(int idx, int apic, 
 void /*__init*/ setup_ioapic_dest(void)
 {
     int pin, ioapic, irq, irq_entry;
-    struct irq_cfg *cfg;
 
     if (skip_ioapic_setup)
         return;
 
     for (ioapic = 0; ioapic < nr_ioapics; ioapic++) {
         for (pin = 0; pin < nr_ioapic_entries[ioapic]; pin++) {
+            struct irq_desc *desc;
+
             irq_entry = find_irq_entry(ioapic, pin, mp_INT);
             if (irq_entry == -1)
                 continue;
             irq = pin_2_irq(irq_entry, ioapic, pin);
-            cfg = irq_cfg(irq);
-            BUG_ON(cpus_empty(cfg->cpu_mask));
-            set_ioapic_affinity_irq(irq_to_desc(irq), &cfg->cpu_mask);
+            desc = irq_to_desc(irq);
+            BUG_ON(cpumask_empty(irq_desc_cpu_mask(desc)));
+            set_ioapic_affinity_irq(desc, irq_desc_cpu_mask(desc));
         }
 
     }
@@ -956,12 +957,12 @@ static void __init setup_IO_APIC_irqs(vo
     struct IO_APIC_route_entry entry;
     int apic, pin, idx, irq, first_notcon = 1, vector;
     unsigned long flags;
-    struct irq_cfg *cfg;
 
     apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
 
     for (apic = 0; apic < nr_ioapics; apic++) {
         for (pin = 0; pin < nr_ioapic_entries[apic]; pin++) {
+            struct irq_desc *desc;
 
             /*
              * add it to the IO-APIC irq-routing table:
@@ -1016,9 +1017,9 @@ static void __init setup_IO_APIC_irqs(vo
                 if (!apic && platform_legacy_irq(irq))
                     disable_8259A_irq(irq_to_desc(irq));
             }
-            cfg = irq_cfg(irq);
+            desc = irq_to_desc(irq);
             SET_DEST(entry.dest.dest32, entry.dest.logical.logical_dest,
-                     cpu_mask_to_apicid(&cfg->cpu_mask));
+                     cpu_mask_to_apicid(irq_desc_cpu_mask(desc)));
             spin_lock_irqsave(&ioapic_lock, flags);
             __ioapic_write_entry(apic, pin, 0, entry);
             set_native_irq_info(irq, TARGET_CPUS);
@@ -2372,7 +2373,7 @@ int ioapic_guest_write(unsigned long phy
     rte.vector = cfg->vector;
 
     SET_DEST(rte.dest.dest32, rte.dest.logical.logical_dest,
-             cpu_mask_to_apicid(&cfg->cpu_mask));
+             cpu_mask_to_apicid(irq_desc_cpu_mask(desc)));
 
     io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&rte) + 0));
     io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&rte) + 1));
xen/arch/x86/irq.c +94 -92

424 lines not on this page · raw message

xen/arch/x86/msi.c +2 -2
@@ -125,13 +125,13 @@ void msi_compose_msg(struct irq_desc *de
     unsigned dest;
     int vector = desc->arch.vector;
 
-    if ( cpumask_empty(&desc->arch.cpu_mask) ) {
+    if ( cpumask_empty(irq_desc_cpu_mask(desc)) ) {
         dprintk(XENLOG_ERR,"%s, compose msi message error!!\n", __func__);
         return;
     }
 
     if ( vector ) {
-        dest = cpu_mask_to_apicid(&desc->arch.cpu_mask);
+        dest = cpu_mask_to_apicid(irq_desc_cpu_mask(desc));
 
         msg->address_hi = MSI_ADDR_BASE_HI;
         msg->address_lo =
xen/arch/x86/smpboot.c +1 -1
@@ -1011,7 +1011,7 @@ void __init smp_intr_init(void)
         irq_vector[irq] = FIRST_HIPRIORITY_VECTOR + seridx + 1;
         per_cpu(vector_irq, cpu)[FIRST_HIPRIORITY_VECTOR + seridx + 1] = irq;
         irq_to_desc(irq)->arch.vector = FIRST_HIPRIORITY_VECTOR + seridx + 1;
-        cpumask_copy(&irq_to_desc(irq)->arch.cpu_mask, &cpu_online_map);
+        cpumask_copy(irq_desc_cpu_mask(irq_to_desc(irq)), &cpu_online_map);
     }
 
     /* IPI for cleanuping vectors after irq move */
xen/common/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-y += domctl.o
 obj-y += domain.o
 obj-y += event_channel.o
 obj-y += grant_table.o
+obj-y += irq.o
 obj-y += kernel.o
 obj-y += keyhandler.o
 obj-y += kexec.o
xen/common/irq.c new file +18 -0
@@ -0,0 +1,18 @@
+#include <xen/config.h>
+#include <xen/irq.h>
+
+int init_one_irq_desc(struct irq_desc *desc)
+{
+    if (irq_desc_initialized(desc))
+        return 0;
+
+    desc->status = IRQ_DISABLED;
+    desc->handler = &no_irq_type;
+    spin_lock_init(&desc->lock);
+    if ( !alloc_cpumask_array(desc->cpumasks) )
+        return -ENOMEM;
+    cpumask_setall(irq_desc_affinity(desc));
+    INIT_LIST_HEAD(&desc->rl_link);
+
+    return arch_init_one_irq_desc(desc);
+}
xen/drivers/passthrough/vtd/iommu.c +4 -3
@@ -1965,17 +1965,18 @@ static int init_vtd_hw(void)
     struct iommu_flush *flush = NULL;
     int ret;
     unsigned long flags;
-    struct irq_cfg *cfg;
 
     /*
      * Basic VT-d HW init: set VT-d interrupt, clear VT-d faults.  
      */
     for_each_drhd_unit ( drhd )
     {
+        struct irq_desc *desc;
+
         iommu = drhd->iommu;
 
-        cfg = irq_cfg(iommu->irq);
-        dma_msi_set_affinity(irq_to_desc(iommu->irq), &cfg->cpu_mask);
+        desc = irq_to_desc(iommu->irq);
+        dma_msi_set_affinity(desc, irq_desc_cpu_mask(desc));
 
         clear_fault_bits(iommu);
 
xen/include/asm-ia64/linux-xen/asm/irq.h +5 -1
@@ -18,8 +18,12 @@
 struct irq_cfg {
 #define arch_irq_desc irq_cfg
         int  vector;
-        cpumask_t cpu_mask;
 };
+
+#define ARCH_IRQ_DESC_NR_CPUMASKS 1
+#define irq_desc_cpu_mask(desc) arch_irq_desc_cpumask(desc, 0)
+
+int init_irq_data(void);
 #endif
 
 static __inline__ int
xen/include/asm-x86/irq.h +5 -4
@@ -33,14 +33,17 @@ struct irq_cfg {
 #define arch_irq_desc irq_cfg
         s16 vector;                  /* vector itself is only 8 bits, */
         s16 old_vector;              /* but we use -1 for unassigned  */
-        cpumask_t cpu_mask;
-        cpumask_t old_cpu_mask;
         unsigned move_cleanup_count;
         vmask_t *used_vectors;
         u8 move_in_progress : 1;
         u8 used: 1;
 };
 
+#define ARCH_IRQ_DESC_NR_CPUMASKS 3
+#define irq_desc_cpu_mask(desc)     arch_irq_desc_cpumask(desc, 0)
+#define irq_desc_old_cpu_mask(desc) arch_irq_desc_cpumask(desc, 1)
+#define irq_desc_pending_mask(desc) arch_irq_desc_cpumask(desc, 2)
+
 /* For use with irq_cfg.used */
 #define IRQ_UNUSED      (0)
 #define IRQ_USED        (1)
@@ -174,8 +177,6 @@ void __setup_vector_irq(int cpu);
 void move_native_irq(struct irq_desc *);
 void move_masked_irq(struct irq_desc *);
 
-int __assign_irq_vector(int irq, struct irq_cfg *, const cpumask_t *);
-
 int bind_irq_vector(int irq, int vector, const cpumask_t *);
 
 void irq_set_affinity(struct irq_desc *, const cpumask_t *mask);
xen/include/xen/cpumask.h +56 -0

68 lines not on this page · raw message

xen/include/xen/irq.h +19 -3
@@ -63,6 +63,17 @@ extern unsigned int nr_irqs;
 #endif
 
 struct msi_desc;
+
+#define ARCH_IRQ_DESC_FIRST_CPUMASK 1
+#ifndef ARCH_IRQ_DESC_NR_CPUMASKS
+#define ARCH_IRQ_DESC_NR_CPUMASKS 0
+#endif
+
+#define irq_desc_cpumask(desc, idx) cpumask_array_index((desc)->cpumasks, idx)
+#define irq_desc_affinity(desc) irq_desc_cpumask(desc, 0)
+#define arch_irq_desc_cpumask(desc, idx) \
+    irq_desc_cpumask(desc, ARCH_IRQ_DESC_FIRST_CPUMASK + (idx))
+
 /*
  * This is the "IRQ descriptor", which contains various information
  * about the irq, including what kind of hardware handling it has,
@@ -76,8 +87,8 @@ typedef struct irq_desc {
     int irq;
     spinlock_t lock;
     struct arch_irq_desc arch;
-    cpumask_t affinity;
-    cpumask_t pending_mask;  /* IRQ migration pending mask */
+    DECLARE_CPUMASK_ARRAY(cpumasks,
+        ARCH_IRQ_DESC_FIRST_CPUMASK + ARCH_IRQ_DESC_NR_CPUMASKS);
 
     /* irq ratelimit */
     s_time_t rl_quantum_start;
@@ -85,6 +96,11 @@ typedef struct irq_desc {
     struct list_head rl_link;
 } __cacheline_aligned irq_desc_t;
 
+int init_one_irq_desc(struct irq_desc *);
+int arch_init_one_irq_desc(struct irq_desc *);
+
+#define irq_desc_initialized(desc) ((desc)->handler != NULL)
+
 #if defined(__ia64__)
 extern irq_desc_t irq_desc[NR_VECTORS];
 
@@ -153,7 +169,7 @@ extern irq_desc_t *pirq_spin_lock_irq_de
 
 static inline void set_native_irq_info(unsigned int irq, const cpumask_t *mask)
 {
-    cpumask_copy(&irq_desc[irq].affinity, mask);
+    cpumask_copy(irq_desc_affinity(irq_to_desc(irq)), mask);
 }
 
 unsigned int set_desc_affinity(struct irq_desc *, const cpumask_t *);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel