summaryrefslogtreecommitdiff
path: root/kernel/irq/handle.c
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-08-19 20:50:09 -0700
committerIngo Molnar <mingo@elte.hu>2008-10-16 16:52:32 +0200
commit7f95ec9e4c12fd067febfd57532da1166d75d858 (patch)
treeb395b6776485f60e3f5d9d820ad665161ef76771 /kernel/irq/handle.c
parent3060d6fe28570640c2d7d66d38b9eaa848c3b9e3 (diff)
x86: move kstat_irqs from kstat to irq_desc
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>
Diffstat (limited to 'kernel/irq/handle.c')
-rw-r--r--kernel/irq/handle.c97
1 files changed, 70 insertions, 27 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 9fc33b3378e6..1f346990f3f8 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -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);
+