]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
x86: move kstat_irqs from kstat to irq_desc
authorYinghai Lu <yhlu.kernel@gmail.com>
Wed, 20 Aug 2008 03:50:09 +0000 (20:50 -0700)
committerIngo Molnar <mingo@elte.hu>
Thu, 16 Oct 2008 14:52:32 +0000 (16:52 +0200)
based on Eric's patch ...

together mold it with dyn_array for irq_desc, will allcate kstat_irqs for
nr_irq_desc alltogether if needed. -- at that point nr_cpus is known already.

v2: make sure system without generic_hardirqs works they don't have irq_desc
v3: fix merging
v4: [mingo@elte.hu] fix typo

[ mingo@elte.hu ] irq: build fix

fix:

 arch/x86/xen/spinlock.c: In function 'xen_spin_lock_slow':
 arch/x86/xen/spinlock.c:90: error: 'struct kernel_stat' has no member named 'irqs'

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/io_apic_32.c
arch/x86/kernel/irq_32.c
arch/x86/kernel/irq_64.c
arch/x86/kernel/visws_quirks.c
arch/x86/xen/spinlock.c
fs/proc/proc_misc.c
include/linux/irq.h
include/linux/kernel_stat.h
kernel/irq/chip.c
kernel/irq/handle.c
kernel/sched.c

index c2160cfdec9b236337118ec8eaaa5f7e24ffcae9..204884b1415a5f33927f5d6c2a438cdd4d018c17 100644 (file)
@@ -526,7 +526,7 @@ static void do_irq_balance(void)
                        if (package_index == i)
                                IRQ_DELTA(package_index, j) = 0;
                        /* Determine the total count per processor per IRQ */
-                       value_now = (unsigned long) kstat_cpu(i).irqs[j];
+                       value_now = (unsigned long) kstat_irqs_cpu(j, i);
 
                        /* Determine the activity per processor per IRQ */
                        delta = value_now - LAST_CPU_IRQ(i, j);
index ede513be517dfb606cb32bb6a225254d4b0837f2..576c5df6cad807af1d14468aa4020179ae6f2f31 100644 (file)
@@ -280,7 +280,7 @@ int show_interrupts(struct seq_file *p, void *v)
                any_count = kstat_irqs(i);
 #else
                for_each_online_cpu(j)
-                       any_count |= kstat_cpu(j).irqs[i];
+                       any_count |= kstat_irqs_cpu(i, j);
 #endif
                action = desc->action;
                if (!action && !any_count)
@@ -290,7 +290,7 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_printf(p, "%10u ", kstat_irqs(i));
 #else
                for_each_online_cpu(j)
-                       seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
+                       seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
 #endif
                seq_printf(p, " %8s", desc->chip->name);
                seq_printf(p, "-%-8s", desc->name);
index 738eb65a924e4e441b5d3503b2604cf80d8013ef..4a0a4eb44dcb3d37c306b771cc015e422484e16e 100644 (file)
@@ -90,7 +90,7 @@ int show_interrupts(struct seq_file *p, void *v)
                any_count = kstat_irqs(i);
 #else
                for_each_online_cpu(j)
-                       any_count |= kstat_cpu(j).irqs[i];
+                       any_count |= kstat_irqs_cpu(i, j);
 #endif
                action = desc->action;
                if (!action && !any_count)
@@ -100,7 +100,7 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_printf(p, "%10u ", kstat_irqs(i));
 #else
                for_each_online_cpu(j)
-                       seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
+                       seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
 #endif
                seq_printf(p, " %8s", desc->chip->name);
                seq_printf(p, "-%-8s", desc->name);
index 9d85ab38443528f8a04f82d6269b6dfe43636918..817aa55a120959f14632dd457e85b3d9fcc7e620 100644 (file)
@@ -633,7 +633,7 @@ static irqreturn_t piix4_master_intr(int irq, void *dev_id)
        /*
         * handle this 'virtual interrupt' as a Cobalt one now.
         */
-       kstat_cpu(smp_processor_id()).irqs[realirq]++;
+       kstat_irqs_this_cpu(desc)++;
 
        if (likely(desc->action != NULL))
                handle_IRQ_event(realirq, desc->action);
index dd71e3a021cd9ba5b5e5433f2031bad45d0ce7a5..bb6bc721b13db70d5a216fffe855d75858ea5a05 100644 (file)
@@ -241,7 +241,7 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl
                ADD_STATS(taken_slow_spurious, !xen_test_irq_pending(irq));
        } while (!xen_test_irq_pending(irq)); /* check for spurious wakeups */
 
-       kstat_this_cpu.irqs[irq]++;
+       kstat_irqs_this_cpu(irq_to_desc(irq))++;
 
 out:
        raw_local_irq_restore(flags);
index a2173a2a5625a8fd537ad680282bf3e62b3f99ea..aa069acf61a07505e2fe12abf3c0219e0d8827f0 100644 (file)
@@ -532,7 +532,7 @@ static int show_stat(struct seq_file *p, void *v)
                steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
                guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
                for (j = 0; j < nr_irqs; j++) {
-                       unsigned int temp = kstat_cpu(i).irqs[j];
+                       unsigned int temp = kstat_irqs_cpu(j, i);
                        sum += temp;
                        per_irq_sum[j] += temp;
                }
index 60c856aaac0f8327a18433e32f4523e44a1959f9..cbf471aee1cee8a69680f0ae1d449527749d4b3a 100644 (file)
@@ -157,6 +157,11 @@ struct irq_desc {
 #ifdef CONFIG_HAVE_SPARSE_IRQ
        struct irq_desc         *next;
        struct timer_rand_state *timer_rand_state;
+#endif
+#ifdef CONFIG_HAVE_DYN_ARRAY
+       unsigned int            *kstat_irqs;
+#else
+       unsigned int            kstat_irqs[NR_CPUS];
 #endif
        irq_flow_handler_t      handle_irq;
        struct irq_chip         *chip;
@@ -190,6 +195,8 @@ extern struct irq_desc *irq_to_desc(unsigned int irq);
 /* could be removed if we get rid of all irq_desc reference */
 extern struct irq_desc irq_desc[NR_IRQS];
 #endif
+#define kstat_irqs_this_cpu(DESC) \
+       ((DESC)->kstat_irqs[smp_processor_id()])
 
 /*
  * Migration helpers for obsolete names, they will go away:
index fe1f7fe534b44b4951db80f06217f2095a064253..f10616712de586a0ce3999dc7be30d30e0a94f80 100644 (file)
@@ -28,10 +28,8 @@ struct cpu_usage_stat {
 
 struct kernel_stat {
        struct cpu_usage_stat   cpustat;
-#ifdef CONFIG_HAVE_DYN_ARRAY
-       unsigned int *irqs;
-#else
-       unsigned int irqs[NR_IRQS];
+#ifndef CONFIG_GENERIC_HARDIRQS
+       unsigned int irqs[NR_IRQS];
 #endif
 };
 
@@ -43,15 +41,25 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
 
 extern unsigned long long nr_context_switches(void);
 
+#ifndef CONFIG_GENERIC_HARDIRQS
+static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
+{
+       return kstat_cpu(cpu).irqs[irq];
+}
+#else
+extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu);
+#endif
+
 /*
  * Number of interrupts per specific IRQ source, since bootup
  */
-static inline int kstat_irqs(int irq)
+static inline unsigned int kstat_irqs(unsigned int irq)
 {
-       int cpu, sum = 0;
+       unsigned int sum = 0;
+       int cpu;
 
        for_each_possible_cpu(cpu)
-               sum += kstat_cpu(cpu).irqs[irq];
+               sum += kstat_irqs_cpu(irq, cpu);
 
        return sum;
 }
index 76c225cf4b263ee60bfb88c8dca468312daa7133..2aa3d4b2fce80fb5b0e293fbdae1cbb938320f74 100644 (file)
@@ -312,14 +312,13 @@ handle_simple_irq(unsigned int irq, struct irq_desc *desc)
 {
        struct irqaction *action;
        irqreturn_t action_ret;
-       const unsigned int cpu = smp_processor_id();
 
        spin_lock(&desc->lock);
 
        if (unlikely(desc->status & IRQ_INPROGRESS))
                goto out_unlock;
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
-       kstat_cpu(cpu).irqs[irq]++;
+       kstat_irqs_this_cpu(desc)++;
 
        action = desc->action;
        if (unlikely(!action || (desc->status & IRQ_DISABLED)))
@@ -351,7 +350,6 @@ out_unlock:
 void
 handle_level_irq(unsigned int irq, struct irq_desc *desc)
 {
-       unsigned int cpu = smp_processor_id();
        struct irqaction *action;
        irqreturn_t action_ret;
 
@@ -361,7 +359,7 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc)
        if (unlikely(desc->status & IRQ_INPROGRESS))
                goto out_unlock;
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
-       kstat_cpu(cpu).irqs[irq]++;
+       kstat_irqs_this_cpu(desc)++;
 
        /*
         * If its disabled or no action available
@@ -399,7 +397,6 @@ out_unlock:
 void
 handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 {
-       unsigned int cpu = smp_processor_id();
        struct irqaction *action;
        irqreturn_t action_ret;
 
@@ -409,7 +406,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
                goto out;
 
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
-       kstat_cpu(cpu).irqs[irq]++;
+       kstat_irqs_this_cpu(desc)++;
 
        /*
         * If its disabled or no action available
@@ -458,8 +455,6 @@ out:
 void
 handle_edge_irq(unsigned int irq, struct irq_desc *desc)
 {
-       const unsigned int cpu = smp_processor_id();
-
        spin_lock(&desc->lock);
 
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
@@ -476,7 +471,7 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
                goto out_unlock;
        }
 
-       kstat_cpu(cpu).irqs[irq]++;
+       kstat_irqs_this_cpu(desc)++;
 
        /* Start handling the irq */
        desc->chip->ack(irq);
@@ -531,7 +526,7 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
 {
        irqreturn_t action_ret;
 
-       kstat_this_cpu.irqs[irq]++;
+       kstat_irqs_this_cpu(desc)++;
 
        if (desc->chip->ack)
                desc->chip->ack(irq);
index 9fc33b3378e657ef821efd0afdc1d2fd24858972..1f346990f3f89983588d2836d387f863798e7e3e 100644 (file)
@@ -37,7 +37,7 @@ void
 handle_bad_irq(unsigned int irq, struct irq_desc *desc)
 {
        print_irq_desc(irq, desc);
-       kstat_this_cpu.irqs[irq]++;
+       kstat_irqs_this_cpu(desc)++;
        ack_bad_irq(irq);
 }
 
@@ -80,17 +80,38 @@ static void init_one_irq_desc(struct irq_desc *desc)
 #endif
 }
 
-#ifdef CONFIG_HAVE_SPARSE_IRQ
-static int nr_irq_desc = 32;
+extern int after_bootmem;
+extern void *__alloc_bootmem_nopanic(unsigned long size,
+                            unsigned long align,
+                            unsigned long goal);
 
-static int __init parse_nr_irq_desc(char *arg)
+static void init_kstat_irqs(struct irq_desc *desc, int nr_desc, int nr)
 {
-       if (arg)
-               nr_irq_desc = simple_strtoul(arg, NULL, 0);
-       return 0;
+       unsigned long bytes, total_bytes;
+       char *ptr;
+       int i;
+       unsigned long phys;
+
+       /* Compute how many bytes we need per irq and allocate them */
+       bytes = nr * sizeof(unsigned int);
+       total_bytes = bytes * nr_desc;
+       if (after_bootmem)
+               ptr = kzalloc(total_bytes, GFP_ATOMIC);
+       else
+               ptr = __alloc_bootmem_nopanic(total_bytes, PAGE_SIZE, 0);
+
+       if (!ptr)
+               panic(" can not allocate kstat_irqs\n");
+
+       phys = __pa(ptr);
+       printk(KERN_DEBUG "kstat_irqs ==> [%#lx - %#lx]\n", phys, phys + total_bytes);
+
+       for (i = 0; i < nr_desc; i++) {
+               desc[i].kstat_irqs = (unsigned int *)ptr;
+               ptr += bytes;
+       }
 }
 
-early_param("nr_irq_desc", parse_nr_irq_desc);
 
 static void __init init_work(void *data)
 {
@@ -100,25 +121,44 @@ static void __init init_work(void *data)
 
        desc = *da->name;
 
-       for (i = 0; i < *da->nr; i++)
+       for (i = 0; i < *da->nr; i++) {
                init_one_irq_desc(&desc[i]);
+#ifndef CONFIG_HAVE_SPARSE_IRQ
+               desc[i].irq = i;
+#endif
+       }
 
+#ifdef CONFIG_HAVE_SPARSE_IRQ
        for (i = 1; i < *da->nr; i++)
                desc[i-1].next = &desc[i];
+#endif
+
+       /* init kstat_irqs, nr_cpu_ids is ready already */
+       init_kstat_irqs(desc, *da->nr, nr_cpu_ids);
 }
 
+#ifdef CONFIG_HAVE_SPARSE_IRQ
+static int nr_irq_desc = 32;
+
+static int __init parse_nr_irq_desc(char *arg)
+{
+       if (arg)
+               nr_irq_desc = simple_strtoul(arg, NULL, 0);
+       return 0;
+}
+
+early_param("nr_irq_desc", parse_nr_irq_desc);
+
 static struct irq_desc *sparse_irqs;
 DEFINE_DYN_ARRAY(sparse_irqs, sizeof(struct irq_desc), nr_irq_desc, PAGE_SIZE, init_work);
 
-extern int after_bootmem;
-extern void *__alloc_bootmem_nopanic(unsigned long size,
-                            unsigned long align,
-                            unsigned long goal);
 struct irq_desc *irq_to_desc(unsigned int irq)
 {
        struct irq_desc *desc, *desc_pri;
        int i;
        int count = 0;
+       unsigned long phys;
+       unsigned long total_bytes;
 
        BUG_ON(irq == -1U);
 
@@ -141,38 +181,34 @@ struct irq_desc *irq_to_desc(unsigned int irq)
         */
        printk(KERN_DEBUG "try to get more irq_desc %d\n", nr_irq_desc);
 
+       total_bytes = sizeof(struct irq_desc) * nr_irq_desc;
        if (after_bootmem)
-               desc = kzalloc(sizeof(struct irq_desc)*nr_irq_desc, GFP_ATOMIC);
+               desc = kzalloc(total_bytes, GFP_ATOMIC);
        else
-               desc = __alloc_bootmem_nopanic(sizeof(struct irq_desc)*nr_irq_desc, PAGE_SIZE, 0);
+               desc = __alloc_bootmem_nopanic(total_bytes, PAGE_SIZE, 0);
 
        if (!desc)
                panic("please boot with nr_irq_desc= %d\n", count * 2);
 
+       phys = __pa(desc);
+       printk(KERN_DEBUG "irq_desc ==> [%#lx - %#lx]\n", phys, phys + total_bytes);
+
        for (i = 0; i < nr_irq_desc; i++)
                init_one_irq_desc(&desc[i]);
 
        for (i = 1; i < nr_irq_desc; i++)
                desc[i-1].next = &desc[i];
 
+       /* init kstat_irqs, nr_cpu_ids is ready already */
+       init_kstat_irqs(desc, nr_irq_desc, nr_cpu_ids);
+
        desc->irq = irq;
        desc_pri->next = desc;
 
        return desc;
 }
 #else
-static void __init init_work(void *data)
-{
-       struct dyn_array *da = data;
-       int i;
-       struct  irq_desc *desc;
-
-       desc = *da->name;
 
-       for (i = 0; i < *da->nr; i++)
-               init_one_irq_desc(&desc[i]);
-
-}
 static struct irq_desc *irq_desc;
 DEFINE_DYN_ARRAY(irq_desc, sizeof(struct irq_desc), nr_irqs, PAGE_SIZE, init_work);
 
@@ -315,7 +351,7 @@ unsigned int __do_IRQ(unsigned int irq)
        struct irqaction *action;
        unsigned int status;
 
-       kstat_this_cpu.irqs[irq]++;
+       kstat_irqs_this_cpu(desc)++;
        if (CHECK_IRQ_PER_CPU(desc->status)) {
                irqreturn_t action_ret;
 
@@ -415,3 +451,10 @@ void early_init_irq_lock_class(void)
 }
 #endif
 
+unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
+{
+       struct irq_desc *desc = irq_to_desc(irq);
+       return desc->kstat_irqs[cpu];
+}
+EXPORT_SYMBOL(kstat_irqs_cpu);
+
index b9d713781b5bba46dbe54c3ab62fa137c4a68970..6f230596bd0c1d21a2c68ffbff8207e93dcd65b5 100644 (file)
@@ -4048,11 +4048,8 @@ static inline void idle_balance(int cpu, struct rq *rq)
 #endif
 
 DEFINE_PER_CPU(struct kernel_stat, kstat);
-EXPORT_PER_CPU_SYMBOL(kstat);
 
-#ifdef CONFIG_HAVE_DYN_ARRAY
-DEFINE_PER_CPU_DYN_ARRAY_ADDR(per_cpu__kstat_irqs, per_cpu__kstat.irqs, sizeof(unsigned int), nr_irqs, sizeof(unsigned long), NULL);
-#endif
+EXPORT_PER_CPU_SYMBOL(kstat);
 
 /*
  * Return p->sum_exec_runtime plus any more ns on the sched_clock