irq: replace loop with nr_irqs with for_each_irq_desc
There are a handful of loops that go from 0 to nr_irqs and use get_irq_desc() on them. These would allocate all the irq_desc entries, regardless of the need for them. Use the smarter for_each_irq_desc() iterator that will only iterate over the present ones. v2: make sure arch without GENERIC_HARDIRQS work too Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
9059d8fa4a
commit
2c6927a38f
arch/x86/kernel
include/linux
kernel/irq
|
@ -1871,10 +1871,10 @@ unmask:
|
||||||
|
|
||||||
static void ir_irq_migration(struct work_struct *work)
|
static void ir_irq_migration(struct work_struct *work)
|
||||||
{
|
{
|
||||||
int irq;
|
unsigned int irq;
|
||||||
|
struct irq_desc *desc;
|
||||||
|
|
||||||
for (irq = 0; irq < nr_irqs; irq++) {
|
for_each_irq_desc(irq, desc) {
|
||||||
struct irq_desc *desc = irq_to_desc(irq);
|
|
||||||
if (desc->status & IRQ_MOVE_PENDING) {
|
if (desc->status & IRQ_MOVE_PENDING) {
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
|
|
@ -224,17 +224,16 @@ void fixup_irqs(cpumask_t map)
|
||||||
{
|
{
|
||||||
unsigned int irq;
|
unsigned int irq;
|
||||||
static int warned;
|
static int warned;
|
||||||
|
struct irq_desc *desc;
|
||||||
|
|
||||||
for (irq = 0; irq < nr_irqs; irq++) {
|
for_each_irq_desc(irq, desc) {
|
||||||
cpumask_t mask;
|
cpumask_t mask;
|
||||||
int break_affinity = 0;
|
int break_affinity = 0;
|
||||||
int set_affinity = 1;
|
int set_affinity = 1;
|
||||||
struct irq_desc *desc;
|
|
||||||
|
|
||||||
if (irq == 2)
|
if (irq == 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
desc = irq_to_desc(irq);
|
|
||||||
/* interrupt's are disabled at this point */
|
/* interrupt's are disabled at this point */
|
||||||
spin_lock(&desc->lock);
|
spin_lock(&desc->lock);
|
||||||
|
|
||||||
|
|
|
@ -142,25 +142,18 @@ void __init init_ISA_irqs(void)
|
||||||
init_bsp_APIC();
|
init_bsp_APIC();
|
||||||
init_8259A(0);
|
init_8259A(0);
|
||||||
|
|
||||||
for (i = 0; i < nr_irqs; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
struct irq_desc *desc = irq_to_desc(i);
|
struct irq_desc *desc = irq_to_desc(i);
|
||||||
|
|
||||||
desc->status = IRQ_DISABLED;
|
desc->status = IRQ_DISABLED;
|
||||||
desc->action = NULL;
|
desc->action = NULL;
|
||||||
desc->depth = 1;
|
desc->depth = 1;
|
||||||
|
|
||||||
if (i < 16) {
|
/*
|
||||||
/*
|
* 16 old-style INTA-cycle interrupts:
|
||||||
* 16 old-style INTA-cycle interrupts:
|
*/
|
||||||
*/
|
set_irq_chip_and_handler_name(i, &i8259A_chip,
|
||||||
set_irq_chip_and_handler_name(i, &i8259A_chip,
|
|
||||||
handle_level_irq, "XT");
|
handle_level_irq, "XT");
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* 'high' PCI IRQs filled in on demand
|
|
||||||
*/
|
|
||||||
desc->chip = &no_irq_chip;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,9 +202,16 @@ extern struct irq_desc irq_desc[NR_IRQS];
|
||||||
extern struct irq_desc *irq_desc;
|
extern struct irq_desc *irq_desc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_GENERIC_HARDIRQS
|
||||||
|
#define for_each_irq_desc(irq, desc) \
|
||||||
|
for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc = &irq_desc[irq])
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
extern struct irq_desc *sparse_irqs;
|
extern struct irq_desc *sparse_irqs;
|
||||||
|
#define for_each_irq_desc(irqX, desc) \
|
||||||
|
for (desc = sparse_irqs, irqX = desc->irq; desc && irqX != -1U; desc = desc->next, irqX = desc ? desc->irq : -1U)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@ extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
|
||||||
unsigned long flags);
|
unsigned long flags);
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
extern void register_irq_proc(unsigned int irq);
|
extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
|
||||||
extern void register_handler_proc(unsigned int irq, struct irqaction *action);
|
extern void register_handler_proc(unsigned int irq, struct irqaction *action);
|
||||||
extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
|
extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
|
||||||
#else
|
#else
|
||||||
static inline void register_irq_proc(unsigned int irq) { }
|
static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
|
||||||
static inline void register_handler_proc(unsigned int irq,
|
static inline void register_handler_proc(unsigned int irq,
|
||||||
struct irqaction *action) { }
|
struct irqaction *action) { }
|
||||||
static inline void unregister_handler_proc(unsigned int irq,
|
static inline void unregister_handler_proc(unsigned int irq,
|
||||||
|
|
|
@ -478,7 +478,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
|
||||||
spin_unlock_irqrestore(&desc->lock, flags);
|
spin_unlock_irqrestore(&desc->lock, flags);
|
||||||
|
|
||||||
new->irq = irq;
|
new->irq = irq;
|
||||||
register_irq_proc(irq);
|
register_irq_proc(irq, desc);
|
||||||
new->dir = NULL;
|
new->dir = NULL;
|
||||||
register_handler_proc(irq, new);
|
register_handler_proc(irq, new);
|
||||||
|
|
||||||
|
|
|
@ -182,11 +182,10 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
|
||||||
|
|
||||||
#define MAX_NAMELEN 10
|
#define MAX_NAMELEN 10
|
||||||
|
|
||||||
void register_irq_proc(unsigned int irq)
|
void register_irq_proc(unsigned int irq, struct irq_desc *desc)
|
||||||
{
|
{
|
||||||
char name [MAX_NAMELEN];
|
char name [MAX_NAMELEN];
|
||||||
struct proc_dir_entry *entry;
|
struct proc_dir_entry *entry;
|
||||||
struct irq_desc *desc = irq_to_desc(irq);
|
|
||||||
|
|
||||||
if (!root_irq_dir || (desc->chip == &no_irq_chip) || desc->dir)
|
if (!root_irq_dir || (desc->chip == &no_irq_chip) || desc->dir)
|
||||||
return;
|
return;
|
||||||
|
@ -230,7 +229,8 @@ void register_default_affinity_proc(void)
|
||||||
|
|
||||||
void init_irq_proc(void)
|
void init_irq_proc(void)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int irq;
|
||||||
|
struct irq_desc *desc;
|
||||||
|
|
||||||
/* create /proc/irq */
|
/* create /proc/irq */
|
||||||
root_irq_dir = proc_mkdir("irq", NULL);
|
root_irq_dir = proc_mkdir("irq", NULL);
|
||||||
|
@ -242,7 +242,7 @@ void init_irq_proc(void)
|
||||||
/*
|
/*
|
||||||
* Create entries for all existing IRQs.
|
* Create entries for all existing IRQs.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nr_irqs; i++)
|
for_each_irq_desc(irq, desc)
|
||||||
register_irq_proc(i);
|
register_irq_proc(irq, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue