From: Jisheng Zhang <jszhang@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Thomas Gleixner <tglx@kernel.org>, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>, Guo Ren <guoren@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-csky@vger.kernel.org
Subject: [PATCH 2/3] genirq: use runtime constant to optimize handle_arch_irq access
Date: Fri, 20 Feb 2026 17:09:21 +0800 [thread overview]
Message-ID: <20260220090922.1506-3-jszhang@kernel.org> (raw)
In-Reply-To: <20260220090922.1506-1-jszhang@kernel.org>
Currently, on GENERIC_IRQ_MULTI_HANDLER platforms, the handle_arch_irq
is a pointer which is set during booting, and every irq processing needs
to access it, so it sits in hot code path. We can use the
runtime constant mechanism which was introduced by Linus to speed up
its accessing.
Tested on Sipeed Lichee Pi 4A (riscv64) board, the perf sched benchmark is
improved by ~5.8%
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
include/linux/irq.h | 4 +++-
kernel/irq/handle.c | 8 +++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 951acbdb9f84..2ba4a8afb71e 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1274,6 +1274,7 @@ void ipi_mux_process(void);
int ipi_mux_create(unsigned int nr_ipi, void (*mux_send)(unsigned int cpu));
#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
+#include <asm/runtime-const.h>
/*
* Registers a generic IRQ handling function as the top-level IRQ handler in
* the system, which is generally the first C code called from an assembly
@@ -1288,7 +1289,8 @@ int __init set_handle_irq(void (*handle_irq)(struct pt_regs *));
* Allows interrupt handlers to find the irqchip that's been registered as the
* top-level IRQ handler.
*/
-extern void (*handle_arch_irq)(struct pt_regs *) __ro_after_init;
+extern void (*_handle_arch_irq)(struct pt_regs *) __ro_after_init;
+#define handle_arch_irq runtime_const_ptr(_handle_arch_irq)
asmlinkage void generic_handle_arch_irq(struct pt_regs *regs);
#else
#ifndef set_handle_irq
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index b7d52821837b..aac9e7b1301e 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -15,13 +15,14 @@
#include <linux/kernel_stat.h>
#include <asm/irq_regs.h>
+#include <asm/runtime-const.h>
#include <trace/events/irq.h>
#include "internals.h"
#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
-void (*handle_arch_irq)(struct pt_regs *) __ro_after_init;
+void (*_handle_arch_irq)(struct pt_regs *) __ro_after_init;
#endif
/**
@@ -270,10 +271,11 @@ irqreturn_t handle_irq_event(struct irq_desc *desc)
#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
int __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
{
- if (handle_arch_irq)
+ if (_handle_arch_irq)
return -EBUSY;
- handle_arch_irq = handle_irq;
+ _handle_arch_irq = handle_irq;
+ runtime_const_init(ptr, _handle_arch_irq);
return 0;
}
--
2.51.0
next prev parent reply other threads:[~2026-02-20 9:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 9:09 [PATCH 0/3] use runtime constant to optimize handle_arch_irq access Jisheng Zhang
2026-02-20 9:09 ` [PATCH 1/3] vmlinux.lds.h: add _handle_arch_irq RUNTIME_CONST section Jisheng Zhang
2026-02-24 2:01 ` Guo Ren
2026-02-20 9:09 ` Jisheng Zhang [this message]
2026-02-22 22:06 ` [PATCH 2/3] genirq: use runtime constant to optimize handle_arch_irq access Thomas Gleixner
2026-02-23 12:41 ` Jisheng Zhang
2026-02-23 13:11 ` Mark Rutland
2026-02-23 13:22 ` Jisheng Zhang
2026-02-23 13:55 ` Mark Rutland
2026-02-24 1:40 ` Guo Ren
2026-02-24 1:59 ` Guo Ren
2026-02-20 9:09 ` [PATCH 3/3] arm64: " Jisheng Zhang
2026-02-20 12:34 ` Leo Yan
2026-02-20 13:16 ` Jisheng Zhang
2026-02-20 13:34 ` Jisheng Zhang
2026-02-20 16:47 ` Leo Yan
2026-02-21 0:14 ` Jisheng Zhang
2026-02-23 9:15 ` Leo Yan
2026-02-25 14:40 ` Jisheng Zhang
2026-02-23 12:56 ` Mark Rutland
2026-02-23 12:58 ` Jisheng Zhang
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=20260220090922.1506-3-jszhang@kernel.org \
--to=jszhang@kernel.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=guoren@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=tglx@kernel.org \
--cc=will@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