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

From: Huang Adrian
Date: Tue Mar 26 2024 - 09:35:40 EST


On Tue, Mar 26, 2024 at 6:32 AM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> Why are you not handling it at the place where the seq_file position is
> iterated instead of doing this + 1 - 1 game here and getting the next
> number only when you already ran into the hole?

Thanks for the comments.

Yes, I did think about the changes in int_seq_next().

The reason I made the changes in show_interrupts() is to minimize the
traversal times of the 'sparse_irqs' maple tree since irq_to_desc() is
invoked in show_interrupts().

Does the following patch meet your expectations? If yes, I'll submit
it for review.

Thanks.

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