aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2009-01-11 01:24:07 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-11 13:13:38 -0500
commit9332fccdedf8e09448f3b69b624211ae879f6c45 (patch)
tree81f74838f7c5388dc83a3cfd8009a22e223b4888
parent0fa0ebbf15addc1be8f73325d809c8547a9de304 (diff)
irq: initialize nr_irqs based on nr_cpu_ids
Impact: Reduce memory usage. This is the second half of the changes to make the irq_desc_ptrs be variable sized based on nr_cpu_ids. This is done by adding a new "max_nr_irqs" macro to irq_vectors.h (and a dummy in irqnr.h) to return a max NR_IRQS value based on NR_CPUS or nr_cpu_ids. This necessitated moving the define of MAX_IO_APICS to a separate file (asm/apicnum.h) so it could be included without the baggage of the other asm/apicdef.h declarations. Signed-off-by: Mike Travis <travis@sgi.com>
-rw-r--r--arch/x86/include/asm/apicdef.h8
-rw-r--r--arch/x86/include/asm/apicnum.h12
-rw-r--r--arch/x86/include/asm/irq_vectors.h16
-rw-r--r--include/linux/irqnr.h7
-rw-r--r--kernel/irq/handle.c3
5 files changed, 35 insertions, 11 deletions
diff --git a/arch/x86/include/asm/apicdef.h b/arch/x86/include/asm/apicdef.h
index 63134e31e8b9..1a6454ef7f6c 100644
--- a/arch/x86/include/asm/apicdef.h
+++ b/arch/x86/include/asm/apicdef.h
@@ -132,12 +132,8 @@
132#define APIC_BASE_MSR 0x800 132#define APIC_BASE_MSR 0x800
133#define X2APIC_ENABLE (1UL << 10) 133#define X2APIC_ENABLE (1UL << 10)
134 134
135#ifdef CONFIG_X86_32 135/* get MAX_IO_APICS */
136# define MAX_IO_APICS 64 136#include <asm/apicnum.h>
137#else
138# define MAX_IO_APICS 128
139# define MAX_LOCAL_APIC 32768
140#endif
141 137
142/* 138/*
143 * All x86-64 systems are xAPIC compatible. 139 * All x86-64 systems are xAPIC compatible.
diff --git a/arch/x86/include/asm/apicnum.h b/arch/x86/include/asm/apicnum.h
new file mode 100644
index 000000000000..82f613c607ce
--- /dev/null
+++ b/arch/x86/include/asm/apicnum.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_X86_APICNUM_H
2#define _ASM_X86_APICNUM_H
3
4/* define MAX_IO_APICS */
5#ifdef CONFIG_X86_32
6# define MAX_IO_APICS 64
7#else
8# define MAX_IO_APICS 128
9# define MAX_LOCAL_APIC 32768
10#endif
11
12#endif /* _ASM_X86_APICNUM_H */
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index f7ff65032b9d..602361ad0e74 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -105,6 +105,8 @@
105 105
106#if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_VOYAGER) 106#if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_VOYAGER)
107 107
108#include <asm/apicnum.h> /* need MAX_IO_APICS */
109
108#ifndef CONFIG_SPARSE_IRQ 110#ifndef CONFIG_SPARSE_IRQ
109# if NR_CPUS < MAX_IO_APICS 111# if NR_CPUS < MAX_IO_APICS
110# define NR_IRQS (NR_VECTORS + (32 * NR_CPUS)) 112# define NR_IRQS (NR_VECTORS + (32 * NR_CPUS))
@@ -112,11 +114,15 @@
112# define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS)) 114# define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS))
113# endif 115# endif
114#else 116#else
115# if (8 * NR_CPUS) > (32 * MAX_IO_APICS) 117
116# define NR_IRQS (NR_VECTORS + (8 * NR_CPUS)) 118/* defined as a macro so nr_irqs = max_nr_irqs(nr_cpu_ids) can be used */
117# else 119# define max_nr_irqs(nr_cpus) \
118# define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS)) 120 ((8 * nr_cpus) > (32 * MAX_IO_APICS) ? \
119# endif 121 (NR_VECTORS + (8 * NR_CPUS)) : \
122 (NR_VECTORS + (32 * MAX_IO_APICS))) \
123
124# define NR_IRQS max_nr_irqs(NR_CPUS)
125
120#endif 126#endif
121 127
122#elif defined(CONFIG_X86_VOYAGER) 128#elif defined(CONFIG_X86_VOYAGER)
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 86af92e9e84c..de66e4e10406 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -20,11 +20,18 @@
20 20
21# define for_each_irq_desc_reverse(irq, desc) \ 21# define for_each_irq_desc_reverse(irq, desc) \
22 for (irq = nr_irqs - 1; irq >= 0; irq--) 22 for (irq = nr_irqs - 1; irq >= 0; irq--)
23
23#else /* CONFIG_GENERIC_HARDIRQS */ 24#else /* CONFIG_GENERIC_HARDIRQS */
24 25
26#include <asm/irq_vectors.h> /* need possible max_nr_irqs() */
27
25extern int nr_irqs; 28extern int nr_irqs;
26extern struct irq_desc *irq_to_desc(unsigned int irq); 29extern struct irq_desc *irq_to_desc(unsigned int irq);
27 30
31# ifndef max_nr_irqs
32# define max_nr_irqs(nr_cpus) NR_IRQS
33# endif
34
28# define for_each_irq_desc(irq, desc) \ 35# define for_each_irq_desc(irq, desc) \
29 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \ 36 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
30 irq++, desc = irq_to_desc(irq)) \ 37 irq++, desc = irq_to_desc(irq)) \
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index d0b8f7e72790..ebba7a116f14 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -133,6 +133,9 @@ int __init early_irq_init(void)
133 int legacy_count; 133 int legacy_count;
134 int i; 134 int i;
135 135
136 /* initialize nr_irqs based on nr_cpu_ids */
137 nr_irqs = max_nr_irqs(nr_cpu_ids);
138
136 printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs); 139 printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs);
137 140
138 desc = irq_desc_legacy; 141 desc = irq_desc_legacy;