diff mbox series

[1/2] genirq/proc: Try to jump over the unallocated irq hole whenever possible

Message ID 20240513120548.14046-2-ahuang12@lenovo.com (mailing list archive)
State New, archived
Headers show
Series genirq/proc: Speed up show_interrupts() | expand

Commit Message

Adrian Huang May 13, 2024, 12:05 p.m. UTC
From: Adrian Huang <ahuang12@lenovo.com>

Current approach blindly iterates the irq number until the number is
greater than 'nr_irqs', and checks if each irq is allocated. It is
inefficient if the big hole (the last allocated irq number to nr_irqs)
is available in the system.

The solution is to try jumping over the unallocated irq hole when an
unallocated irq is detected.

Tested-by: Jiwei Sun <sunjw10@lenovo.com>
Signed-off-by: Adrian Huang <ahuang12@lenovo.com>
---
 fs/proc/interrupts.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index cb0edc7cbf09..111ea8a3c553 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -19,6 +19,12 @@  static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
 	(*pos)++;
 	if (*pos > nr_irqs)
 		return NULL;
+
+	rcu_read_lock();
+	if (!irq_to_desc(*pos))
+		*pos = irq_get_next_irq(*pos);
+	rcu_read_unlock();
+
 	return pos;
 }