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

From: Thomas Gleixner
Date: Mon Mar 25 2024 - 18:34:28 EST


On Mon, Mar 25 2024 at 11:51, Adrian Huang wrote:
> * The following result is the average execution time of five-time
> measurements about seq_read_iter().
>
> no patch (us) patched (us) saved
> ------------- ------------ -------
> 158552 148094 6.6%
>
> [1] https://gist.github.com/AdrianHuang/6c60b8053b2b3ecf6da56dec7a0eae70

These gist links are useless within no time and not of real value. We
all know that there are holes.

> Tested-by: Jiwei Sun <sunjw10@xxxxxxxxxx>
> Signed-off-by: Adrian Huang <ahuang12@xxxxxxxxxx>
> ---
> kernel/irq/proc.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
> index 623b8136e9af..756bdc1fd07b 100644
> --- a/kernel/irq/proc.c
> +++ b/kernel/irq/proc.c
> @@ -485,7 +485,14 @@ int show_interrupts(struct seq_file *p, void *v)
>
> rcu_read_lock();
> desc = irq_to_desc(i);
> - if (!desc || irq_settings_is_hidden(desc))
> + if (!desc) {
> + /* Try to jump over the unallocated irq hole. */
> + *(int *) v = irq_get_next_irq(i + 1) - 1;

The position is loff_t and not int. See the type cast at the beginning
of that function. But let's leave this detail aside and let me ask the
real question:

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?

That's the obvious place, no?

Thanks,

tglx