diff options
| author | Yinghai Lu <yinghai@kernel.org> | 2008-12-05 21:58:31 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-12-08 08:31:51 -0500 |
| commit | 0b8f1efad30bd58f89961b82dfe68b9edf8fd2ac (patch) | |
| tree | 239251bad791fd60af8c0f2ba365b7188395c83f /include/linux | |
| parent | 218d11a8b071b23b76c484fd5f72a4fe3306801e (diff) | |
sparse irq_desc[] array: core kernel and x86 changes
Impact: new feature
Problem on distro kernels: irq_desc[NR_IRQS] takes megabytes of RAM with
NR_CPUS set to large values. The goal is to be able to scale up to much
larger NR_IRQS value without impacting the (important) common case.
To solve this, we generalize irq_desc[NR_IRQS] to an (optional) array of
irq_desc pointers.
When CONFIG_SPARSE_IRQ=y is used, we use kzalloc_node to get irq_desc,
this also makes the IRQ descriptors NUMA-local (to the site that calls
request_irq()).
This gets rid of the irq_cfg[] static array on x86 as well: irq_cfg now
uses desc->chip_data for x86 to store irq_cfg.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/interrupt.h | 2 | ||||
| -rw-r--r-- | include/linux/irq.h | 54 | ||||
| -rw-r--r-- | include/linux/irqnr.h | 14 | ||||
| -rw-r--r-- | include/linux/kernel_stat.h | 14 | ||||
| -rw-r--r-- | include/linux/random.h | 51 |
5 files changed, 122 insertions, 13 deletions
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index f58a0cf8929a..79e915e7e8a5 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h | |||
| @@ -18,6 +18,8 @@ | |||
| 18 | #include <asm/ptrace.h> | 18 | #include <asm/ptrace.h> |
| 19 | #include <asm/system.h> | 19 | #include <asm/system.h> |
| 20 | 20 | ||
| 21 | extern int nr_irqs; | ||
| 22 | |||
| 21 | /* | 23 | /* |
| 22 | * These correspond to the IORESOURCE_IRQ_* defines in | 24 | * These correspond to the IORESOURCE_IRQ_* defines in |
| 23 | * linux/ioport.h to select the interrupt line behaviour. When | 25 | * linux/ioport.h to select the interrupt line behaviour. When |
diff --git a/include/linux/irq.h b/include/linux/irq.h index 3dddfa703ebd..63b00439d4d2 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
| @@ -129,6 +129,8 @@ struct irq_chip { | |||
| 129 | const char *typename; | 129 | const char *typename; |
| 130 | }; | 130 | }; |
| 131 | 131 | ||
| 132 | struct timer_rand_state; | ||
| 133 | struct irq_2_iommu; | ||
| 132 | /** | 134 | /** |
| 133 | * struct irq_desc - interrupt descriptor | 135 | * struct irq_desc - interrupt descriptor |
| 134 | * @irq: interrupt number for this descriptor | 136 | * @irq: interrupt number for this descriptor |
| @@ -154,6 +156,13 @@ struct irq_chip { | |||
| 154 | */ | 156 | */ |
| 155 | struct irq_desc { | 157 | struct irq_desc { |
| 156 | unsigned int irq; | 158 | unsigned int irq; |
| 159 | #ifdef CONFIG_SPARSE_IRQ | ||
| 160 | struct timer_rand_state *timer_rand_state; | ||
| 161 | unsigned int *kstat_irqs; | ||
| 162 | # ifdef CONFIG_INTR_REMAP | ||
| 163 | struct irq_2_iommu *irq_2_iommu; | ||
| 164 | # endif | ||
| 165 | #endif | ||
| 157 | irq_flow_handler_t handle_irq; | 166 | irq_flow_handler_t handle_irq; |
| 158 | struct irq_chip *chip; | 167 | struct irq_chip *chip; |
| 159 | struct msi_desc *msi_desc; | 168 | struct msi_desc *msi_desc; |
| @@ -181,14 +190,52 @@ struct irq_desc { | |||
| 181 | const char *name; | 190 | const char *name; |
| 182 | } ____cacheline_internodealigned_in_smp; | 191 | } ____cacheline_internodealigned_in_smp; |
| 183 | 192 | ||
| 193 | extern void early_irq_init(void); | ||
| 194 | extern void arch_early_irq_init(void); | ||
| 195 | extern void arch_init_chip_data(struct irq_desc *desc, int cpu); | ||
| 196 | extern void arch_init_copy_chip_data(struct irq_desc *old_desc, | ||
| 197 | struct irq_desc *desc, int cpu); | ||
| 198 | extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc); | ||
| 199 | |||
| 200 | #ifndef CONFIG_SPARSE_IRQ | ||
| 184 | 201 | ||
| 185 | extern struct irq_desc irq_desc[NR_IRQS]; | 202 | extern struct irq_desc irq_desc[NR_IRQS]; |
| 186 | 203 | ||
| 187 | static inline struct irq_desc *irq_to_desc(unsigned int irq) | 204 | static inline struct irq_desc *irq_to_desc(unsigned int irq) |
| 188 | { | 205 | { |
| 189 | return (irq < nr_irqs) ? irq_desc + irq : NULL; | 206 | return (irq < NR_IRQS) ? irq_desc + irq : NULL; |
| 207 | } | ||
| 208 | static inline struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) | ||
| 209 | { | ||
| 210 | return irq_to_desc(irq); | ||
| 190 | } | 211 | } |
| 191 | 212 | ||
| 213 | #ifdef CONFIG_GENERIC_HARDIRQS | ||
| 214 | # define for_each_irq_desc(irq, desc) \ | ||
| 215 | for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc++) | ||
| 216 | # define for_each_irq_desc_reverse(irq, desc) \ | ||
| 217 | for (irq = nr_irqs - 1, desc = irq_desc + (nr_irqs - 1); \ | ||
| 218 | irq >= 0; irq--, desc--) | ||
| 219 | #endif | ||
| 220 | |||
| 221 | #else | ||
| 222 | |||
| 223 | extern struct irq_desc *irq_to_desc(unsigned int irq); | ||
| 224 | extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu); | ||
| 225 | extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu); | ||
| 226 | |||
| 227 | # define for_each_irq_desc(irq, desc) \ | ||
| 228 | for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; irq++, desc = irq_to_desc(irq)) | ||
| 229 | # define for_each_irq_desc_reverse(irq, desc) \ | ||
| 230 | for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; irq--, desc = irq_to_desc(irq)) | ||
| 231 | |||
| 232 | #define kstat_irqs_this_cpu(DESC) \ | ||
| 233 | ((DESC)->kstat_irqs[smp_processor_id()]) | ||
| 234 | #define kstat_incr_irqs_this_cpu(irqno, DESC) \ | ||
| 235 | ((DESC)->kstat_irqs[smp_processor_id()]++) | ||
| 236 | |||
| 237 | #endif | ||
| 238 | |||
| 192 | /* | 239 | /* |
| 193 | * Migration helpers for obsolete names, they will go away: | 240 | * Migration helpers for obsolete names, they will go away: |
| 194 | */ | 241 | */ |
| @@ -380,6 +427,11 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry); | |||
| 380 | #define get_irq_data(irq) (irq_to_desc(irq)->handler_data) | 427 | #define get_irq_data(irq) (irq_to_desc(irq)->handler_data) |
| 381 | #define get_irq_msi(irq) (irq_to_desc(irq)->msi_desc) | 428 | #define get_irq_msi(irq) (irq_to_desc(irq)->msi_desc) |
| 382 | 429 | ||
| 430 | #define get_irq_desc_chip(desc) ((desc)->chip) | ||
| 431 | #define get_irq_desc_chip_data(desc) ((desc)->chip_data) | ||
| 432 | #define get_irq_desc_data(desc) ((desc)->handler_data) | ||
| 433 | #define get_irq_desc_msi(desc) ((desc)->msi_desc) | ||
| 434 | |||
| 383 | #endif /* CONFIG_GENERIC_HARDIRQS */ | 435 | #endif /* CONFIG_GENERIC_HARDIRQS */ |
| 384 | 436 | ||
| 385 | #endif /* !CONFIG_S390 */ | 437 | #endif /* !CONFIG_S390 */ |
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h index 452c280c8115..7a299e989f8b 100644 --- a/include/linux/irqnr.h +++ b/include/linux/irqnr.h | |||
| @@ -7,18 +7,10 @@ | |||
| 7 | 7 | ||
| 8 | # define for_each_irq_desc(irq, desc) \ | 8 | # define for_each_irq_desc(irq, desc) \ |
| 9 | for (irq = 0; irq < nr_irqs; irq++) | 9 | for (irq = 0; irq < nr_irqs; irq++) |
| 10 | #else | ||
| 11 | extern int nr_irqs; | ||
| 12 | 10 | ||
| 13 | # define for_each_irq_desc(irq, desc) \ | 11 | static inline early_sparse_irq_init(void) |
| 14 | for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc++) | 12 | { |
| 15 | 13 | } | |
| 16 | # define for_each_irq_desc_reverse(irq, desc) \ | ||
| 17 | for (irq = nr_irqs - 1, desc = irq_desc + (nr_irqs - 1); \ | ||
| 18 | irq >= 0; irq--, desc--) | ||
| 19 | #endif | 14 | #endif |
| 20 | 15 | ||
| 21 | #define for_each_irq_nr(irq) \ | ||
| 22 | for (irq = 0; irq < nr_irqs; irq++) | ||
| 23 | |||
| 24 | #endif | 16 | #endif |
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h index 4a145caeee07..4ee4b3d2316f 100644 --- a/include/linux/kernel_stat.h +++ b/include/linux/kernel_stat.h | |||
| @@ -28,7 +28,9 @@ struct cpu_usage_stat { | |||
| 28 | 28 | ||
| 29 | struct kernel_stat { | 29 | struct kernel_stat { |
| 30 | struct cpu_usage_stat cpustat; | 30 | struct cpu_usage_stat cpustat; |
| 31 | unsigned int irqs[NR_IRQS]; | 31 | #ifndef CONFIG_SPARSE_IRQ |
| 32 | unsigned int irqs[NR_IRQS]; | ||
| 33 | #endif | ||
| 32 | }; | 34 | }; |
| 33 | 35 | ||
| 34 | DECLARE_PER_CPU(struct kernel_stat, kstat); | 36 | DECLARE_PER_CPU(struct kernel_stat, kstat); |
| @@ -39,6 +41,10 @@ DECLARE_PER_CPU(struct kernel_stat, kstat); | |||
| 39 | 41 | ||
| 40 | extern unsigned long long nr_context_switches(void); | 42 | extern unsigned long long nr_context_switches(void); |
| 41 | 43 | ||
| 44 | #ifndef CONFIG_SPARSE_IRQ | ||
| 45 | #define kstat_irqs_this_cpu(irq) \ | ||
| 46 | (kstat_this_cpu.irqs[irq]) | ||
| 47 | |||
| 42 | struct irq_desc; | 48 | struct irq_desc; |
| 43 | 49 | ||
| 44 | static inline void kstat_incr_irqs_this_cpu(unsigned int irq, | 50 | static inline void kstat_incr_irqs_this_cpu(unsigned int irq, |
| @@ -46,11 +52,17 @@ static inline void kstat_incr_irqs_this_cpu(unsigned int irq, | |||
| 46 | { | 52 | { |
| 47 | kstat_this_cpu.irqs[irq]++; | 53 | kstat_this_cpu.irqs[irq]++; |
| 48 | } | 54 | } |
| 55 | #endif | ||
| 56 | |||
| 49 | 57 | ||
| 58 | #ifndef CONFIG_SPARSE_IRQ | ||
| 50 | static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) | 59 | static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) |
| 51 | { | 60 | { |
| 52 | return kstat_cpu(cpu).irqs[irq]; | 61 | return kstat_cpu(cpu).irqs[irq]; |
| 53 | } | 62 | } |
| 63 | #else | ||
| 64 | extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu); | ||
| 65 | #endif | ||
| 54 | 66 | ||
| 55 | /* | 67 | /* |
| 56 | * Number of interrupts per specific IRQ source, since bootup | 68 | * Number of interrupts per specific IRQ source, since bootup |
diff --git a/include/linux/random.h b/include/linux/random.h index 36f125c0c603..ad9daa2374d5 100644 --- a/include/linux/random.h +++ b/include/linux/random.h | |||
| @@ -44,6 +44,57 @@ struct rand_pool_info { | |||
| 44 | 44 | ||
| 45 | extern void rand_initialize_irq(int irq); | 45 | extern void rand_initialize_irq(int irq); |
| 46 | 46 | ||
| 47 | struct timer_rand_state; | ||
| 48 | #ifndef CONFIG_SPARSE_IRQ | ||
| 49 | |||
| 50 | extern struct timer_rand_state *irq_timer_state[]; | ||
| 51 | |||
| 52 | extern int nr_irqs; | ||
| 53 | static inline struct timer_rand_state *get_timer_rand_state(unsigned int irq) | ||
| 54 | { | ||
| 55 | if (irq >= nr_irqs) | ||
| 56 | return NULL; | ||
| 57 | |||
| 58 | return irq_timer_state[irq]; | ||
| 59 | } | ||
| 60 | |||
| 61 | static inline void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state) | ||
| 62 | { | ||
| 63 | if (irq >= nr_irqs) | ||
| 64 | return; | ||
| 65 | |||
| 66 | irq_timer_state[irq] = state; | ||
| 67 | } | ||
| 68 | |||
| 69 | #else | ||
| 70 | |||
| 71 | #include <linux/irq.h> | ||
| 72 | static inline struct timer_rand_state *get_timer_rand_state(unsigned int irq) | ||
| 73 | { | ||
| 74 | struct irq_desc *desc; | ||
| 75 | |||
| 76 | desc = irq_to_desc(irq); | ||
| 77 | |||
| 78 | if (!desc) | ||
| 79 | return NULL; | ||
| 80 | |||
| 81 | return desc->timer_rand_state; | ||
| 82 | } | ||
| 83 | |||
| 84 | static inline void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state) | ||
| 85 | { | ||
| 86 | struct irq_desc *desc; | ||
| 87 | |||
| 88 | desc = irq_to_desc(irq); | ||
| 89 | |||
| 90 | if (!desc) | ||
| 91 | return; | ||
| 92 | |||
| 93 | desc->timer_rand_state = state; | ||
| 94 | } | ||
| 95 | #endif | ||
| 96 | |||
| 97 | |||
| 47 | extern void add_input_randomness(unsigned int type, unsigned int code, | 98 | extern void add_input_randomness(unsigned int type, unsigned int code, |
| 48 | unsigned int value); | 99 | unsigned int value); |
| 49 | extern void add_interrupt_randomness(int irq); | 100 | extern void add_interrupt_randomness(int irq); |
