Skip to content

Commit

Permalink
genirq: Speedup show_interrupts()
Browse files Browse the repository at this point in the history
Since commit 425a507 ("genirq: Free irq_desc with rcu"),
show_interrupts() can be switched to rcu locking, which removes possible
contention on sparse_irq_lock.

The per_cpu count scan and print can be done without holding desc spinlock.

And there is no need to call kstat_irqs_cpu() and abuse irq_to_desc() while
holding rcu read lock, since desc and desc->kstat_irqs wont disappear or
change.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Link: https://lkml.kernel.org/r/20180620150332.163320-1-edumazet@google.com
  • Loading branch information
Eric Dumazet authored and Thomas Gleixner committed Jun 22, 2018
1 parent 0a13ec0 commit 74bdf78
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions kernel/irq/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,22 +475,24 @@ int show_interrupts(struct seq_file *p, void *v)
seq_putc(p, '\n');
}

irq_lock_sparse();
rcu_read_lock();
desc = irq_to_desc(i);
if (!desc)
goto outsparse;

raw_spin_lock_irqsave(&desc->lock, flags);
for_each_online_cpu(j)
any_count |= kstat_irqs_cpu(i, j);
action = desc->action;
if ((!action || irq_desc_is_chained(desc)) && !any_count)
goto out;
if (desc->kstat_irqs)
for_each_online_cpu(j)
any_count |= *per_cpu_ptr(desc->kstat_irqs, j);

if ((!desc->action || irq_desc_is_chained(desc)) && !any_count)
goto outsparse;

seq_printf(p, "%*d: ", prec, i);
for_each_online_cpu(j)
seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
seq_printf(p, "%10u ", desc->kstat_irqs ?
*per_cpu_ptr(desc->kstat_irqs, j) : 0);

raw_spin_lock_irqsave(&desc->lock, flags);
if (desc->irq_data.chip) {
if (desc->irq_data.chip->irq_print_chip)
desc->irq_data.chip->irq_print_chip(&desc->irq_data, p);
Expand All @@ -511,17 +513,17 @@ int show_interrupts(struct seq_file *p, void *v)
if (desc->name)
seq_printf(p, "-%-8s", desc->name);

action = desc->action;
if (action) {
seq_printf(p, " %s", action->name);
while ((action = action->next) != NULL)
seq_printf(p, ", %s", action->name);
}

seq_putc(p, '\n');
out:
raw_spin_unlock_irqrestore(&desc->lock, flags);
outsparse:
irq_unlock_sparse();
rcu_read_unlock();
return 0;
}
#endif

0 comments on commit 74bdf78

Please sign in to comment.