Linux Trace Kernel
 help / color / mirror / Atom feed
* [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline
       [not found] <cover.1785153469.git.hongyan.xia@transsion.com>
@ 2026-07-27 12:25 ` Hongyan Xia
  2026-07-27 19:22   ` Nick Desaulniers
  2026-07-29 18:08   ` Steven Rostedt
  0 siblings, 2 replies; 6+ messages in thread
From: Hongyan Xia @ 2026-07-27 12:25 UTC (permalink / raw)
  To: Will Deacon, Masami Hiramatsu, Catalin Marinas, Dennis Zhou,
	Tejun Heo, Christoph Lameter, Oleg Nesterov, Naveen N Rao,
	David S. Miller, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt
  Cc: Jiazi Li, Pu Hu, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev

From: Hongyan Xia <hongyan.xia@transsion.com>

Static inline should be enough to actually inline functions for most
compilers, but my Clang-19 somehow thinks it's better to outline them.
These tiny helpers then live in normal .text sections instead of
.noinstr sections, violating noinstr.

Mark them __always_inline so the compiler can never outline them.

Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
---
 arch/arm64/include/asm/esr.h       | 2 +-
 arch/arm64/include/asm/percpu.h    | 2 +-
 arch/arm64/include/asm/preempt.h   | 4 ++--
 arch/arm64/include/asm/ptrace.h    | 4 ++--
 arch/arm64/kernel/debug-monitors.c | 2 +-
 include/linux/kprobes.h            | 8 ++++----
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/arm64/include/asm/esr.h b/arch/arm64/include/asm/esr.h
index f816f5d77f1a..a75bfdb7e5fe 100644
--- a/arch/arm64/include/asm/esr.h
+++ b/arch/arm64/include/asm/esr.h
@@ -437,7 +437,7 @@
 #ifndef __ASSEMBLER__
 #include <asm/types.h>
 
-static inline unsigned long esr_brk_comment(unsigned long esr)
+static __always_inline unsigned long esr_brk_comment(unsigned long esr)
 {
 	return esr & ESR_ELx_BRK64_ISS_COMMENT_MASK;
 }
diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
index b57b2bb00967..d4cae47fde8c 100644
--- a/arch/arm64/include/asm/percpu.h
+++ b/arch/arm64/include/asm/percpu.h
@@ -29,7 +29,7 @@ static inline unsigned long __hyp_my_cpu_offset(void)
 	return read_sysreg(tpidr_el2);
 }
 
-static inline unsigned long __kern_my_cpu_offset(void)
+static __always_inline unsigned long __kern_my_cpu_offset(void)
 {
 	unsigned long off;
 
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/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index 39582511ad72..460726224299 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -336,11 +336,11 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,
 struct task_struct;
 int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task);
 
-static inline unsigned long instruction_pointer(struct pt_regs *regs)
+static __always_inline unsigned long instruction_pointer(struct pt_regs *regs)
 {
 	return regs->pc;
 }
-static inline void instruction_pointer_set(struct pt_regs *regs,
+static __always_inline void instruction_pointer_set(struct pt_regs *regs,
 		unsigned long val)
 {
 	regs->pc = val;
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index a970ab6327cd..66cb8151f5df 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -146,7 +146,7 @@ postcore_initcall(debug_monitors_init);
 /*
  * Single step API and exception handling.
  */
-static void set_user_regs_spsr_ss(struct user_pt_regs *regs)
+static __always_inline void set_user_regs_spsr_ss(struct user_pt_regs *regs)
 {
 	regs->pstate |= DBG_SPSR_SS;
 }
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 8c4f3bb24429..5880445ed0f0 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -384,17 +384,17 @@ static inline void kprobe_ftrace_kill(void) {}
 struct kprobe *get_kprobe(void *addr);
 
 /* kprobe_running() will just return the current_kprobe on this CPU */
-static inline struct kprobe *kprobe_running(void)
+static __always_inline struct kprobe *kprobe_running(void)
 {
 	return __this_cpu_read(current_kprobe);
 }
 
-static inline void reset_current_kprobe(void)
+static __always_inline void reset_current_kprobe(void)
 {
 	__this_cpu_write(current_kprobe, NULL);
 }
 
-static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
+static __always_inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
 {
 	return this_cpu_ptr(&kprobe_ctlblk);
 }
@@ -449,7 +449,7 @@ static inline struct kprobe *get_kprobe(void *addr)
 {
 	return NULL;
 }
-static inline struct kprobe *kprobe_running(void)
+static __always_inline struct kprobe *kprobe_running(void)
 {
 	return NULL;
 }
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline
  2026-07-27 12:25 ` [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline Hongyan Xia
@ 2026-07-27 19:22   ` Nick Desaulniers
  2026-07-27 21:49     ` Will Deacon
  2026-07-28  2:03     ` Hongyan Xia
  2026-07-29 18:08   ` Steven Rostedt
  1 sibling, 2 replies; 6+ messages in thread
From: Nick Desaulniers @ 2026-07-27 19:22 UTC (permalink / raw)
  To: Hongyan Xia
  Cc: Will Deacon, Masami Hiramatsu, Catalin Marinas, Dennis Zhou,
	Tejun Heo, Christoph Lameter, Oleg Nesterov, Naveen N Rao,
	David S. Miller, Nathan Chancellor, Bill Wendling, Justin Stitt,
	Jiazi Li, Pu Hu, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev

On Mon, Jul 27, 2026 at 5:25 AM Hongyan Xia <hongyan.xia@transsion.com> wrote:
>
> From: Hongyan Xia <hongyan.xia@transsion.com>
>
> Static inline should be enough to actually inline functions for most
> compilers, but my Clang-19 somehow thinks it's better to outline them.
> These tiny helpers then live in normal .text sections instead of
> .noinstr sections, violating noinstr.

Anything special about your build or config?  For example, we've seen
a recent influx of bugs around AutoFDO not inlining functions (despite
constant propagating initdata constants into them) leading to modpost
errors.

Can you perhaps share your config so that someone else could repro and
take a look?

Happy to follow up in our issue tracker, too.
https://github.com/ClangBuiltLinux/linux/issues

>
> Mark them __always_inline so the compiler can never outline them.
>
> Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
> ---
>  arch/arm64/include/asm/esr.h       | 2 +-
>  arch/arm64/include/asm/percpu.h    | 2 +-
>  arch/arm64/include/asm/preempt.h   | 4 ++--
>  arch/arm64/include/asm/ptrace.h    | 4 ++--
>  arch/arm64/kernel/debug-monitors.c | 2 +-
>  include/linux/kprobes.h            | 8 ++++----

It might not be appropriate for the changes to kprobes.h to go through
the arm64 tree, but maybe it is?

-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline
  2026-07-27 19:22   ` Nick Desaulniers
@ 2026-07-27 21:49     ` Will Deacon
  2026-07-28  2:03     ` Hongyan Xia
  1 sibling, 0 replies; 6+ messages in thread
From: Will Deacon @ 2026-07-27 21:49 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Hongyan Xia, Masami Hiramatsu, Catalin Marinas, Dennis Zhou,
	Tejun Heo, Christoph Lameter, Oleg Nesterov, Naveen N Rao,
	David S. Miller, Nathan Chancellor, Bill Wendling, Justin Stitt,
	Jiazi Li, Pu Hu, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev

On Mon, Jul 27, 2026 at 12:22:32PM -0700, Nick Desaulniers wrote:
> On Mon, Jul 27, 2026 at 5:25 AM Hongyan Xia <hongyan.xia@transsion.com> wrote:
> >  arch/arm64/include/asm/esr.h       | 2 +-
> >  arch/arm64/include/asm/percpu.h    | 2 +-
> >  arch/arm64/include/asm/preempt.h   | 4 ++--
> >  arch/arm64/include/asm/ptrace.h    | 4 ++--
> >  arch/arm64/kernel/debug-monitors.c | 2 +-
> >  include/linux/kprobes.h            | 8 ++++----
> 
> It might not be appropriate for the changes to kprobes.h to go through
> the arm64 tree, but maybe it is?

They look pretty trivial, so we can take 'em with Masami's Ack once the
rest of the series has been reviewed.

Will

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline
  2026-07-27 19:22   ` Nick Desaulniers
  2026-07-27 21:49     ` Will Deacon
@ 2026-07-28  2:03     ` Hongyan Xia
  1 sibling, 0 replies; 6+ messages in thread
From: Hongyan Xia @ 2026-07-28  2:03 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Will Deacon, Masami Hiramatsu, Catalin Marinas, Dennis Zhou,
	Tejun Heo, Christoph Lameter, Oleg Nesterov, Naveen N Rao,
	David S. Miller, Nathan Chancellor, Bill Wendling, Justin Stitt,
	Jiazi Li, Pu Hu, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev

On 7/28/2026 3:22 AM, Nick Desaulniers wrote:
> On Mon, Jul 27, 2026 at 5:25 AM Hongyan Xia <hongyan.xia@transsion.com> wrote:
>>
>> From: Hongyan Xia <hongyan.xia@transsion.com>
>>
>> Static inline should be enough to actually inline functions for most
>> compilers, but my Clang-19 somehow thinks it's better to outline them.
>> These tiny helpers then live in normal .text sections instead of
>> .noinstr sections, violating noinstr.
>
> Anything special about your build or config?  For example, we've seen
> a recent influx of bugs around AutoFDO not inlining functions (despite
> constant propagating initdata constants into them) leading to modpost
> errors.

I doubt there's anything special. The compiler is Debian clang version
19.1.7 (3+b1) installed through apt install in vanilla x86_64 Debian
Trixie, compiled with 'make LLVM=1 ARCH=arm64 Image'.

> Can you perhaps share your config so that someone else could repro and
> take a look?

Sure. Not sure how I can share the giant config without bombarding all
the recipients. Let me just send to you privately first.

> Happy to follow up in our issue tracker, too.
> https://github.com/ClangBuiltLinux/linux/issues
>
>>
>> Mark them __always_inline so the compiler can never outline them.
>>
>> Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
>> ---
>>   arch/arm64/include/asm/esr.h       | 2 +-
>>   arch/arm64/include/asm/percpu.h    | 2 +-
>>   arch/arm64/include/asm/preempt.h   | 4 ++--
>>   arch/arm64/include/asm/ptrace.h    | 4 ++--
>>   arch/arm64/kernel/debug-monitors.c | 2 +-
>>   include/linux/kprobes.h            | 8 ++++----
>
> It might not be appropriate for the changes to kprobes.h to go through
> the arm64 tree, but maybe it is?

I see Will has replied, so this might be a question for Kprobe
maintainers. I do wonder that, if I see this in clang-19 compiling for
arm64 without any special configs, eventually it might happen for other
people after moving to clang-19?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline
  2026-07-27 12:25 ` [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline Hongyan Xia
  2026-07-27 19:22   ` Nick Desaulniers
@ 2026-07-29 18:08   ` Steven Rostedt
  2026-07-30  0:03     ` Masami Hiramatsu
  1 sibling, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2026-07-29 18:08 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Hongyan Xia, Will Deacon, Catalin Marinas, Dennis Zhou, Tejun Heo,
	Christoph Lameter, Oleg Nesterov, Naveen N Rao, David S. Miller,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Jiazi Li, Pu Hu, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev


Masami,


On Mon, 27 Jul 2026 12:25:48 +0000
Hongyan Xia <hongyan.xia@transsion.com> wrote:

> From: Hongyan Xia <hongyan.xia@transsion.com>
> 
> Static inline should be enough to actually inline functions for most
> compilers, but my Clang-19 somehow thinks it's better to outline them.
> These tiny helpers then live in normal .text sections instead of
> .noinstr sections, violating noinstr.
> 
> Mark them __always_inline so the compiler can never outline them.
> 
> Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
> ---
>  arch/arm64/include/asm/esr.h       | 2 +-
>  arch/arm64/include/asm/percpu.h    | 2 +-
>  arch/arm64/include/asm/preempt.h   | 4 ++--
>  arch/arm64/include/asm/ptrace.h    | 4 ++--
>  arch/arm64/kernel/debug-monitors.c | 2 +-
>  include/linux/kprobes.h            | 8 ++++----

Are you OK with this patch? If so, can you ack it?

-- Steve

>  6 files changed, 11 insertions(+), 11 deletions(-)
> 

[..]

> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index 8c4f3bb24429..5880445ed0f0 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -384,17 +384,17 @@ static inline void kprobe_ftrace_kill(void) {}
>  struct kprobe *get_kprobe(void *addr);
>  
>  /* kprobe_running() will just return the current_kprobe on this CPU */
> -static inline struct kprobe *kprobe_running(void)
> +static __always_inline struct kprobe *kprobe_running(void)
>  {
>  	return __this_cpu_read(current_kprobe);
>  }
>  
> -static inline void reset_current_kprobe(void)
> +static __always_inline void reset_current_kprobe(void)
>  {
>  	__this_cpu_write(current_kprobe, NULL);
>  }
>  
> -static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
> +static __always_inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
>  {
>  	return this_cpu_ptr(&kprobe_ctlblk);
>  }
> @@ -449,7 +449,7 @@ static inline struct kprobe *get_kprobe(void *addr)
>  {
>  	return NULL;
>  }
> -static inline struct kprobe *kprobe_running(void)
> +static __always_inline struct kprobe *kprobe_running(void)
>  {
>  	return NULL;
>  }


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline
  2026-07-29 18:08   ` Steven Rostedt
@ 2026-07-30  0:03     ` Masami Hiramatsu
  0 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2026-07-30  0:03 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Hongyan Xia, Will Deacon, Catalin Marinas, Dennis Zhou, Tejun Heo,
	Christoph Lameter, Oleg Nesterov, Naveen N Rao, David S. Miller,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Jiazi Li, Pu Hu, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev

On Wed, 29 Jul 2026 14:08:46 -0400
Steven Rostedt <steven@rostedt.org> wrote:

> 
> Masami,
> 
> 
> On Mon, 27 Jul 2026 12:25:48 +0000
> Hongyan Xia <hongyan.xia@transsion.com> wrote:
> 
> > From: Hongyan Xia <hongyan.xia@transsion.com>
> > 
> > Static inline should be enough to actually inline functions for most
> > compilers, but my Clang-19 somehow thinks it's better to outline them.
> > These tiny helpers then live in normal .text sections instead of
> > .noinstr sections, violating noinstr.
> > 
> > Mark them __always_inline so the compiler can never outline them.
> > 
> > Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
> > ---
> >  arch/arm64/include/asm/esr.h       | 2 +-
> >  arch/arm64/include/asm/percpu.h    | 2 +-
> >  arch/arm64/include/asm/preempt.h   | 4 ++--
> >  arch/arm64/include/asm/ptrace.h    | 4 ++--
> >  arch/arm64/kernel/debug-monitors.c | 2 +-
> >  include/linux/kprobes.h            | 8 ++++----
> 
> Are you OK with this patch? If so, can you ack it?

Yeah, this patch looks good to me. Anyway these are expected to be
inlined.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

For other patches, Sashiko noted some comments, I need to check it.

Thank you,

> 
> -- Steve
> 
> >  6 files changed, 11 insertions(+), 11 deletions(-)
> > 
> 
> [..]
> 
> > diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> > index 8c4f3bb24429..5880445ed0f0 100644
> > --- a/include/linux/kprobes.h
> > +++ b/include/linux/kprobes.h
> > @@ -384,17 +384,17 @@ static inline void kprobe_ftrace_kill(void) {}
> >  struct kprobe *get_kprobe(void *addr);
> >  
> >  /* kprobe_running() will just return the current_kprobe on this CPU */
> > -static inline struct kprobe *kprobe_running(void)
> > +static __always_inline struct kprobe *kprobe_running(void)
> >  {
> >  	return __this_cpu_read(current_kprobe);
> >  }
> >  
> > -static inline void reset_current_kprobe(void)
> > +static __always_inline void reset_current_kprobe(void)
> >  {
> >  	__this_cpu_write(current_kprobe, NULL);
> >  }
> >  
> > -static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
> > +static __always_inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
> >  {
> >  	return this_cpu_ptr(&kprobe_ctlblk);
> >  }
> > @@ -449,7 +449,7 @@ static inline struct kprobe *get_kprobe(void *addr)
> >  {
> >  	return NULL;
> >  }
> > -static inline struct kprobe *kprobe_running(void)
> > +static __always_inline struct kprobe *kprobe_running(void)
> >  {
> >  	return NULL;
> >  }
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-30  0:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1785153469.git.hongyan.xia@transsion.com>
2026-07-27 12:25 ` [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline Hongyan Xia
2026-07-27 19:22   ` Nick Desaulniers
2026-07-27 21:49     ` Will Deacon
2026-07-28  2:03     ` Hongyan Xia
2026-07-29 18:08   ` Steven Rostedt
2026-07-30  0:03     ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox