Commit 9332fccd authored by Mike Travis's avatar Mike Travis Committed by Ingo Molnar

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: default avatarMike Travis <travis@sgi.com>
parent 0fa0ebbf
...@@ -132,12 +132,8 @@ ...@@ -132,12 +132,8 @@
#define APIC_BASE_MSR 0x800 #define APIC_BASE_MSR 0x800
#define X2APIC_ENABLE (1UL << 10) #define X2APIC_ENABLE (1UL << 10)
#ifdef CONFIG_X86_32 /* get MAX_IO_APICS */
# define MAX_IO_APICS 64 #include <asm/apicnum.h>
#else
# define MAX_IO_APICS 128
# define MAX_LOCAL_APIC 32768
#endif
/* /*
* All x86-64 systems are xAPIC compatible. * All x86-64 systems are xAPIC compatible.
......
#ifndef _ASM_X86_APICNUM_H
#define _ASM_X86_APICNUM_H
/* define MAX_IO_APICS */
#ifdef CONFIG_X86_32
# define MAX_IO_APICS 64
#else
# define MAX_IO_APICS 128
# define MAX_LOCAL_APIC 32768
#endif
#endif /* _ASM_X86_APICNUM_H */
...@@ -105,6 +105,8 @@ ...@@ -105,6 +105,8 @@
#if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_VOYAGER) #if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_VOYAGER)
#include <asm/apicnum.h> /* need MAX_IO_APICS */
#ifndef CONFIG_SPARSE_IRQ #ifndef CONFIG_SPARSE_IRQ
# if NR_CPUS < MAX_IO_APICS # if NR_CPUS < MAX_IO_APICS
# define NR_IRQS (NR_VECTORS + (32 * NR_CPUS)) # define NR_IRQS (NR_VECTORS + (32 * NR_CPUS))
...@@ -112,11 +114,15 @@ ...@@ -112,11 +114,15 @@
# define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS)) # define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS))
# endif # endif
#else #else
# if (8 * NR_CPUS) > (32 * MAX_IO_APICS)
# define NR_IRQS (NR_VECTORS + (8 * NR_CPUS)) /* defined as a macro so nr_irqs = max_nr_irqs(nr_cpu_ids) can be used */
# else # define max_nr_irqs(nr_cpus) \
# define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS)) ((8 * nr_cpus) > (32 * MAX_IO_APICS) ? \
# endif (NR_VECTORS + (8 * NR_CPUS)) : \
(NR_VECTORS + (32 * MAX_IO_APICS))) \
# define NR_IRQS max_nr_irqs(NR_CPUS)
#endif #endif
#elif defined(CONFIG_X86_VOYAGER) #elif defined(CONFIG_X86_VOYAGER)
......
...@@ -20,11 +20,18 @@ ...@@ -20,11 +20,18 @@
# define for_each_irq_desc_reverse(irq, desc) \ # define for_each_irq_desc_reverse(irq, desc) \
for (irq = nr_irqs - 1; irq >= 0; irq--) for (irq = nr_irqs - 1; irq >= 0; irq--)
#else /* CONFIG_GENERIC_HARDIRQS */ #else /* CONFIG_GENERIC_HARDIRQS */
#include <asm/irq_vectors.h> /* need possible max_nr_irqs() */
extern int nr_irqs; extern int nr_irqs;
extern struct irq_desc *irq_to_desc(unsigned int irq); extern struct irq_desc *irq_to_desc(unsigned int irq);
# ifndef max_nr_irqs
# define max_nr_irqs(nr_cpus) NR_IRQS
# endif
# define for_each_irq_desc(irq, desc) \ # define for_each_irq_desc(irq, desc) \
for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \ for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
irq++, desc = irq_to_desc(irq)) \ irq++, desc = irq_to_desc(irq)) \
......
...@@ -133,6 +133,9 @@ int __init early_irq_init(void) ...@@ -133,6 +133,9 @@ int __init early_irq_init(void)
int legacy_count; int legacy_count;
int i; int i;
/* initialize nr_irqs based on nr_cpu_ids */
nr_irqs = max_nr_irqs(nr_cpu_ids);
printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs); printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs);
desc = irq_desc_legacy; desc = irq_desc_legacy;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment