From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Hongyan Xia <hongyan.xia@transsion.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Will Deacon <will@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Jiazi Li <jiazi.li@transsion.com>, Pu Hu <hupu@transsion.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH v2 1/4] arm64/entry: Make debug_exception_enter/exit() noinstr
Date: Fri, 14 Aug 2026 00:57:58 +0900 [thread overview]
Message-ID: <20260814005758.c8cc04d276a0f82689ccddca@kernel.org> (raw)
In-Reply-To: <c3a90368dd6c096af9d918e036a27728696fb8a4.1786603168.git.hongyan.xia@transsion.com>
On Thu, 13 Aug 2026 06:49:27 +0000
Hongyan Xia <hongyan.xia@transsion.com> wrote:
> From: Hongyan Xia <hongyan.xia@transsion.com>
>
> Commit 879a6754d3d11e30af24b7dc486f561510d62641 ran into a crash because
> debug_exception_enter/exit() triggered page faults caused by perf dwarf
> call graph tracing. That patch was a band-aid on top.
>
> Instead of trying to band-aid all possible paths that can happen during
> instrumentation or perf tracing, simply force-inline these functions and
> use the notrace variant of preempt handling to avoid all the complexity.
>
> Drop the RCU_LOCKDEP_WARN(): arm64_enter_el1_dbg() runs first and
> enters NMI context via ct_nmi_enter(), so RCU is always watching by the
> time debug_exception_enter() runs.
>
> Also mark __preempt_count_add/sub() __always_inline so the preempt
> count updates fold into the noinstr callers instead of becoming
> outlined calls to instrumentable text.
Looks good to me as a kprobe maintainer.
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks,
>
> Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
> ---
> arch/arm64/include/asm/preempt.h | 4 ++--
> arch/arm64/kernel/entry-common.c | 13 ++++---------
> 2 files changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h
> index 932ea4b62042..326f221c3f56 100644
> --- a/arch/arm64/include/asm/preempt.h
> +++ b/arch/arm64/include/asm/preempt.h
> @@ -41,14 +41,14 @@ static inline bool test_preempt_need_resched(void)
> return !current_thread_info()->preempt.need_resched;
> }
>
> -static inline void __preempt_count_add(int val)
> +static __always_inline void __preempt_count_add(int val)
> {
> u32 pc = READ_ONCE(current_thread_info()->preempt.count);
> pc += val;
> WRITE_ONCE(current_thread_info()->preempt.count, pc);
> }
>
> -static inline void __preempt_count_sub(int val)
> +static __always_inline void __preempt_count_sub(int val)
> {
> u32 pc = READ_ONCE(current_thread_info()->preempt.count);
> pc -= val;
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index ceb4eb11232a..d5c1d6defe29 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -292,20 +292,15 @@ static __always_inline void fpsimd_syscall_exit(void)
> * accidentally schedule in exception context and it will force a warning
> * if we somehow manage to schedule by accident.
> */
> -static void debug_exception_enter(struct pt_regs *regs)
> +static __always_inline void debug_exception_enter(struct pt_regs *regs)
> {
> - preempt_disable();
> -
> - /* This code is a bit fragile. Test it. */
> - RCU_LOCKDEP_WARN(!rcu_is_watching(), "exception_enter didn't work");
> + preempt_disable_notrace();
> }
> -NOKPROBE_SYMBOL(debug_exception_enter);
>
> -static void debug_exception_exit(struct pt_regs *regs)
> +static __always_inline void debug_exception_exit(struct pt_regs *regs)
> {
> - preempt_enable_no_resched();
> + preempt_enable_no_resched_notrace();
> }
> -NOKPROBE_SYMBOL(debug_exception_exit);
>
> UNHANDLED(el1t, 64, sync)
> UNHANDLED(el1t, 64, irq)
> --
> 2.47.3
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2026-08-13 15:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 6:47 [RFC PATCH v2 0/4] Mark Kprobe debug exception paths noinstr Hongyan Xia
2026-08-13 6:49 ` [RFC PATCH v2 1/4] arm64/entry: Make debug_exception_enter/exit() noinstr Hongyan Xia
2026-08-13 15:57 ` Masami Hiramatsu [this message]
2026-08-13 6:49 ` [RFC PATCH v2 2/4] arm64/debug: Make the Kprobe functions noinstr Hongyan Xia
2026-08-13 15:59 ` Masami Hiramatsu
2026-08-13 6:50 ` [RFC PATCH v2 3/4] arm64/kprobes: Make the entire Kprobe noinstr Hongyan Xia
2026-08-13 6:50 ` [RFC PATCH v2 4/4] Revert "arm64: kprobes: Allow reentering kprobes while single-stepping" Hongyan Xia
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=20260814005758.c8cc04d276a0f82689ccddca@kernel.org \
--to=mhiramat@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=hongyan.xia@transsion.com \
--cc=hupu@transsion.com \
--cc=jiazi.li@transsion.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--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