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

From: Adrian Huang
Date: Mon May 13 2024 - 08:06:55 EST


From: Adrian Huang <ahuang12@xxxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Adrian Huang <ahuang12@xxxxxxxxxx>
---
fs/proc/interrupts.c | 6 ++++++
1 file changed, 6 insertions(+)

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;
}

--
2.25.1