From: Jiri Slaby <jirislaby@kernel.org>
To: ray <veidongray@qq.com>, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/irq: Precompute nr_legacy_irqs() for performance optimization
Date: Thu, 6 Nov 2025 07:44:37 +0100 [thread overview]
Message-ID: <f8c0f152-cd70-4a25-a52d-e1692c6dbc28@kernel.org> (raw)
In-Reply-To: <tencent_59CE737B39C37282F84B9CF7765A6C1D8006@qq.com>
Hi,
On 01. 11. 25, 12:26, ray wrote:
> Precompute the return value of nr_legacy_irqs() in init_ISA_irqs(),
> init_IRQ(), and native_init_IRQ() functions to avoid repeated function
> calls in loops, improving performance.
>
> Changes made:
> - Precompute nr_legacy_irqs() return value in three functions
> - Use local variables instead of function calls in loops
> - Maintain original logic unchanged
>
> Signed-off-by: ray <veidongray@qq.com>
Is this how you sign legal documents?
> index 6ab9eac64670..bb7cbf99f65c 100644
> --- a/arch/x86/kernel/irqinit.c
> +++ b/arch/x86/kernel/irqinit.c
...
> @@ -66,7 +66,9 @@ void __init init_ISA_irqs(void)
>
> legacy_pic->init(0);
>
> - for (i = 0; i < nr_legacy_irqs(); i++) {
> + nr_legacy = nr_legacy_irqs();
> +
> + for (i = 0; i < nr_legacy; i++) {
nr_legacy_irqs() is a static inline, so this was not a call per se.
Instead, this resolves to 2 memory reads. Is the change worth it at all,
provided these are NOT a fast path?
> @@ -106,7 +112,9 @@ void __init native_init_IRQ(void)
>
> lapic_assign_system_vectors();
>
> - if (!acpi_ioapic && !of_ioapic && nr_legacy_irqs()) {
> + nr_legacy = nr_legacy_irqs();
> +
> + if (!acpi_ioapic && !of_ioapic && nr_legacy) {
What's the added value in here at all?
thanks,
--
js
suse labs
prev parent reply other threads:[~2025-11-06 6:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-01 11:26 [PATCH] x86/irq: Precompute nr_legacy_irqs() for performance optimization ray
2025-11-06 6:44 ` Jiri Slaby [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f8c0f152-cd70-4a25-a52d-e1692c6dbc28@kernel.org \
--to=jirislaby@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=veidongray@qq.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox