* [PATCH v3 01/22] x86/paravirt: Mark native pv_ops helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 7:43 ` Peter Zijlstra
2026-12-01 4:21 ` [PATCH v3 02/22] x86: Mark CPU state helpers used by resume and kexec notrace Song Liu
` (21 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
The native implementations of several pv_ops are static inline functions
in headers. pv_ops stores their address, so with CONFIG_PARAVIRT_XXL the
compiler emits an out-of-line copy of each one, and pv_ops calls go to
that copy. Today these copies are not traced only because the inline
macro implies notrace.
Some callers of these helpers must not be traced:
restore_processor_state() is notrace and runs during resume,
__switch_to() is __notrace_funcgraph, and arch/x86/kernel/cpu/common.c
and arch/x86/kernel/tsc.c, which call several of them, are built
without -pg.
Mark these helpers notrace explicitly, like native_write_msr() and
native_write_msr_safe() already are, so they stay untraced if inline no
longer implies notrace. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/x86/include/asm/cpuid/api.h | 4 ++--
arch/x86/include/asm/desc.h | 17 +++++++++--------
arch/x86/include/asm/gsseg.h | 2 +-
arch/x86/include/asm/io_bitmap.h | 2 +-
arch/x86/include/asm/msr.h | 6 +++---
arch/x86/include/asm/pgalloc.h | 2 +-
arch/x86/include/asm/pgtable_64.h | 10 +++++-----
arch/x86/include/asm/processor.h | 2 +-
arch/x86/include/asm/special_insns.h | 2 +-
include/linux/pgtable.h | 12 ++++++------
10 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/api.h
index 759b12d94bbf..f2f921f1b810 100644
--- a/arch/x86/include/asm/cpuid/api.h
+++ b/arch/x86/include/asm/cpuid/api.h
@@ -23,8 +23,8 @@ static inline bool cpuid_feature(void)
}
#endif
-static inline void native_cpuid(u32 *eax, u32 *ebx,
- u32 *ecx, u32 *edx)
+static inline void notrace native_cpuid(u32 *eax, u32 *ebx,
+ u32 *ecx, u32 *edx)
{
/* ecx is often an input as well as an output. */
asm volatile("cpuid"
diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index 00aeae843529..9a01dc9c191a 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -134,17 +134,18 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
#define store_ldt(ldt) asm("sldt %0" : "=m"(ldt))
-static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
+static inline void notrace native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
{
memcpy(&idt[entry], gate, sizeof(*gate));
}
-static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
+static inline void notrace
+native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
{
memcpy(&ldt[entry], desc, 8);
}
-static inline void
+static inline void notrace
native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int type)
{
unsigned int size;
@@ -189,7 +190,7 @@ static inline void __set_tss_desc(unsigned cpu, unsigned int entry, struct x86_h
#define set_tss_desc(cpu, addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
-static inline void native_set_ldt(const void *addr, unsigned int entries)
+static inline void notrace native_set_ldt(const void *addr, unsigned int entries)
{
if (likely(entries == 0))
asm volatile("lldt %w0"::"q" (0));
@@ -205,7 +206,7 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
}
}
-static inline void native_load_gdt(const struct desc_ptr *dtr)
+static inline void notrace native_load_gdt(const struct desc_ptr *dtr)
{
asm volatile("lgdt %0"::"m" (*dtr));
}
@@ -251,7 +252,7 @@ static inline void native_idt_invalidate(void)
* original writeable version when needed.
*/
#ifdef CONFIG_X86_64
-static inline void native_load_tr_desc(void)
+static inline void notrace native_load_tr_desc(void)
{
struct desc_ptr gdt;
int cpu = raw_smp_processor_id();
@@ -280,7 +281,7 @@ static inline void native_load_tr_desc(void)
}
#endif
-static inline unsigned long native_store_tr(void)
+static inline unsigned long notrace native_store_tr(void)
{
unsigned long tr;
@@ -289,7 +290,7 @@ static inline unsigned long native_store_tr(void)
return tr;
}
-static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
+static inline void notrace native_load_tls(struct thread_struct *t, unsigned int cpu)
{
struct desc_struct *gdt = get_cpu_gdt_rw(cpu);
unsigned int i;
diff --git a/arch/x86/include/asm/gsseg.h b/arch/x86/include/asm/gsseg.h
index ab6a595cea70..14596425f36a 100644
--- a/arch/x86/include/asm/gsseg.h
+++ b/arch/x86/include/asm/gsseg.h
@@ -25,7 +25,7 @@ static inline void native_lkgs(unsigned int selector)
: [sel] "+D" (sel));
}
-static inline void native_load_gs_index(unsigned int selector)
+static inline void notrace native_load_gs_index(unsigned int selector)
{
if (cpu_feature_enabled(X86_FEATURE_LKGS)) {
native_lkgs(selector);
diff --git a/arch/x86/include/asm/io_bitmap.h b/arch/x86/include/asm/io_bitmap.h
index 7f080f5c7def..af3b08a685e6 100644
--- a/arch/x86/include/asm/io_bitmap.h
+++ b/arch/x86/include/asm/io_bitmap.h
@@ -19,7 +19,7 @@ struct task_struct;
void io_bitmap_share(struct task_struct *tsk);
void io_bitmap_exit(struct task_struct *tsk);
-static inline void native_tss_invalidate_io_bitmap(void)
+static inline void notrace native_tss_invalidate_io_bitmap(void)
{
/*
* Invalidate the I/O bitmap by moving io_bitmap_base outside the
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 2f41a9289d79..ca138498a00b 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -101,7 +101,7 @@ static __always_inline u64 native_rdmsrq(u32 msr)
#define native_wrmsrq(msr, val) \
__wrmsrq((msr), (val))
-static inline u64 native_read_msr(u32 msr)
+static inline u64 notrace native_read_msr(u32 msr)
{
u64 val;
@@ -113,7 +113,7 @@ static inline u64 native_read_msr(u32 msr)
return val;
}
-static inline int native_read_msr_safe(u32 msr, u64 *p)
+static inline int notrace native_read_msr_safe(u32 msr, u64 *p)
{
int err;
EAX_EDX_DECLARE_ARGS(val, low, high);
@@ -159,7 +159,7 @@ static inline int notrace native_write_msr_safe(u32 msr, u64 val)
extern int rdmsr_safe_regs(u32 regs[8]);
extern int wrmsr_safe_regs(u32 regs[8]);
-static inline u64 native_read_pmc(int counter)
+static inline u64 notrace native_read_pmc(int counter)
{
EAX_EDX_DECLARE_ARGS(val, low, high);
diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index c88691b15f3c..8d233e2e72bf 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -12,7 +12,7 @@
#define __HAVE_ARCH_PGD_FREE
#include <asm-generic/pgalloc.h>
-static inline int __paravirt_pgd_alloc(struct mm_struct *mm) { return 0; }
+static inline int notrace __paravirt_pgd_alloc(struct mm_struct *mm) { return 0; }
#ifdef CONFIG_PARAVIRT_XXL
#include <asm/paravirt.h>
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index c861f3832bed..092e5f65f68e 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -40,7 +40,7 @@ static inline bool mm_p4d_folded(struct mm_struct *mm)
void set_pte_vaddr_p4d(p4d_t *p4d_page, unsigned long vaddr, pte_t new_pte);
void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte);
-static inline void native_set_pte(pte_t *ptep, pte_t pte)
+static inline void notrace native_set_pte(pte_t *ptep, pte_t pte)
{
WRITE_ONCE(*ptep, pte);
}
@@ -56,7 +56,7 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
native_set_pte(ptep, pte);
}
-static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
+static inline void notrace native_set_pmd(pmd_t *pmdp, pmd_t pmd)
{
WRITE_ONCE(*pmdp, pmd);
}
@@ -92,7 +92,7 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
#endif
}
-static inline void native_set_pud(pud_t *pudp, pud_t pud)
+static inline void notrace native_set_pud(pud_t *pudp, pud_t pud)
{
WRITE_ONCE(*pudp, pud);
}
@@ -117,7 +117,7 @@ static inline pud_t native_pudp_get_and_clear(pud_t *xp)
#endif
}
-static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
+static inline void notrace native_set_p4d(p4d_t *p4dp, p4d_t p4d)
{
pgd_t pgd;
@@ -137,7 +137,7 @@ static inline void native_p4d_clear(p4d_t *p4d)
native_set_p4d(p4d, native_make_p4d(0));
}
-static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
+static inline void notrace native_set_pgd(pgd_t *pgdp, pgd_t pgd)
{
WRITE_ONCE(*pgdp, pti_set_user_pgtbl(pgdp, pgd));
}
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 77488ff5eb8c..f1a0d99ddd22 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -548,7 +548,7 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset,
fpu_thread_struct_whitelist(offset, size);
}
-static inline void
+static inline void notrace
native_load_sp0(unsigned long sp0)
{
this_cpu_write(cpu_tss_rw.x86_tss.sp0, sp0);
diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
index 6c80f69cf62b..f39891c94e7b 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -12,7 +12,7 @@
void native_write_cr0(unsigned long val);
-static inline unsigned long native_read_cr0(void)
+static inline unsigned long notrace native_read_cr0(void)
{
unsigned long val;
asm volatile("mov %%cr0,%0" : "=r" (val));
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 66d369870a74..09cf1831bf48 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -1607,9 +1607,9 @@ static inline int pmd_none_or_clear_bad(pmd_t *pmd)
return 0;
}
-static inline pte_t __ptep_modify_prot_start(struct vm_area_struct *vma,
- unsigned long addr,
- pte_t *ptep)
+static inline pte_t notrace __ptep_modify_prot_start(struct vm_area_struct *vma,
+ unsigned long addr,
+ pte_t *ptep)
{
/*
* Get the current pte state, but zero it out to make it
@@ -1619,9 +1619,9 @@ static inline pte_t __ptep_modify_prot_start(struct vm_area_struct *vma,
return ptep_get_and_clear(vma->vm_mm, addr, ptep);
}
-static inline void __ptep_modify_prot_commit(struct vm_area_struct *vma,
- unsigned long addr,
- pte_t *ptep, pte_t pte)
+static inline void notrace __ptep_modify_prot_commit(struct vm_area_struct *vma,
+ unsigned long addr,
+ pte_t *ptep, pte_t pte)
{
/*
* The pte is non-present, so there's no hardware state to
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 01/22] x86/paravirt: Mark native pv_ops helpers notrace
2026-12-01 4:21 ` [PATCH v3 01/22] x86/paravirt: Mark native pv_ops helpers notrace Song Liu
@ 2026-12-01 7:43 ` Peter Zijlstra
0 siblings, 0 replies; 39+ messages in thread
From: Peter Zijlstra @ 2026-12-01 7:43 UTC (permalink / raw)
To: Song Liu
Cc: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf, rostedt,
mhiramat, mark.rutland, tglx, frederic, paulmck, catalin.marinas,
will, maddy, mpe, npiggin, chleroy, pjw, palmer, aou, alex, ast,
daniel, andrii, ojeda, kernel-team
On Mon, Nov 30, 2026 at 08:21:40PM -0800, Song Liu wrote:
> The native implementations of several pv_ops are static inline functions
> in headers. pv_ops stores their address, so with CONFIG_PARAVIRT_XXL the
> compiler emits an out-of-line copy of each one, and pv_ops calls go to
> that copy. Today these copies are not traced only because the inline
> macro implies notrace.
>
> Some callers of these helpers must not be traced:
> restore_processor_state() is notrace and runs during resume,
> __switch_to() is __notrace_funcgraph, and arch/x86/kernel/cpu/common.c
> and arch/x86/kernel/tsc.c, which call several of them, are built
> without -pg.
>
> Mark these helpers notrace explicitly, like native_write_msr() and
> native_write_msr_safe() already are, so they stay untraced if inline no
> longer implies notrace. No functional change.
I must say.. I hate this with a passion. This is unmaintainable garbage.
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 02/22] x86: Mark CPU state helpers used by resume and kexec notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
2026-12-01 4:21 ` [PATCH v3 01/22] x86/paravirt: Mark native pv_ops helpers notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 03/22] bpf: Mark bpf_spin_lock helpers notrace Song Liu
` (20 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
__restore_processor_state() is notrace because it starts running before
%gs and the IDT are restored, when the function tracer cannot run yet.
Before it restores MSR_GS_BASE, it calls wrmsrq(), __write_cr4(),
write_cr3(), write_cr0(), load_idt() and loadsegment(), and after that
it calls load_gs_index(). With CONFIG_PARAVIRT_XXL, wrmsrq() calls
paravirt_write_msr(). machine_kexec() calls virt_to_phys() after
load_segments() has reset %gs. All of these are plain inline functions.
If the compiler emits one of them out of line, that copy is untraced
only because inline implies notrace.
Mark them notrace explicitly, together with the other paravirt MSR
accessors, so they stay consistent with paravirt_write_msr(). No
functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/x86/include/asm/gsseg.h | 2 +-
arch/x86/include/asm/io.h | 2 +-
arch/x86/include/asm/msr.h | 2 +-
arch/x86/include/asm/paravirt.h | 20 ++++++++++----------
arch/x86/include/asm/segment.h | 4 ++--
arch/x86/include/asm/special_insns.h | 6 +++---
6 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/arch/x86/include/asm/gsseg.h b/arch/x86/include/asm/gsseg.h
index 14596425f36a..d46d6effb631 100644
--- a/arch/x86/include/asm/gsseg.h
+++ b/arch/x86/include/asm/gsseg.h
@@ -52,7 +52,7 @@ static inline void __init lkgs_init(void)
#ifndef CONFIG_PARAVIRT_XXL
-static inline void load_gs_index(unsigned int selector)
+static inline void notrace load_gs_index(unsigned int selector)
{
#ifdef CONFIG_X86_64
native_load_gs_index(selector);
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 7f4847b2b904..721ce7878966 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -126,7 +126,7 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
* this function
*/
-static inline phys_addr_t virt_to_phys(volatile void *address)
+static inline phys_addr_t notrace virt_to_phys(volatile void *address)
{
return __pa(address);
}
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index ca138498a00b..7c311dbcd0bf 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -194,7 +194,7 @@ static inline void wrmsr(u32 msr, u32 low, u32 high)
#define rdmsrq(msr, val) \
((val) = native_read_msr((msr)))
-static inline void wrmsrq(u32 msr, u64 val)
+static inline void notrace wrmsrq(u32 msr, u64 val)
{
native_write_msr(msr, val);
}
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 0591aa38fd85..c30af937103b 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -98,7 +98,7 @@ static inline unsigned long read_cr0(void)
return PVOP_CALL0(unsigned long, pv_ops, cpu.read_cr0);
}
-static inline void write_cr0(unsigned long x)
+static inline void notrace write_cr0(unsigned long x)
{
PVOP_VCALL1(pv_ops, cpu.write_cr0, x);
}
@@ -120,32 +120,32 @@ static inline unsigned long __read_cr3(void)
"mov %%cr3, %%rax", ALT_NOT_XEN);
}
-static inline void write_cr3(unsigned long x)
+static inline void notrace write_cr3(unsigned long x)
{
PVOP_ALT_VCALL1(pv_ops, mmu.write_cr3, x, "mov %%rdi, %%cr3", ALT_NOT_XEN);
}
-static inline void __write_cr4(unsigned long x)
+static inline void notrace __write_cr4(unsigned long x)
{
PVOP_VCALL1(pv_ops, cpu.write_cr4, x);
}
-static inline u64 paravirt_read_msr(u32 msr)
+static inline u64 notrace paravirt_read_msr(u32 msr)
{
return PVOP_CALL1(u64, pv_ops, cpu.read_msr, msr);
}
-static inline void paravirt_write_msr(u32 msr, u64 val)
+static inline void notrace paravirt_write_msr(u32 msr, u64 val)
{
PVOP_VCALL2(pv_ops, cpu.write_msr, msr, val);
}
-static inline int paravirt_read_msr_safe(u32 msr, u64 *val)
+static inline int notrace paravirt_read_msr_safe(u32 msr, u64 *val)
{
return PVOP_CALL2(int, pv_ops, cpu.read_msr_safe, msr, val);
}
-static inline int paravirt_write_msr_safe(u32 msr, u64 val)
+static inline int notrace paravirt_write_msr_safe(u32 msr, u64 val)
{
return PVOP_CALL2(int, pv_ops, cpu.write_msr_safe, msr, val);
}
@@ -167,7 +167,7 @@ do { \
val = paravirt_read_msr(msr); \
} while (0)
-static inline void wrmsrq(u32 msr, u64 val)
+static inline void notrace wrmsrq(u32 msr, u64 val)
{
paravirt_write_msr(msr, val);
}
@@ -215,7 +215,7 @@ static inline void load_gdt(const struct desc_ptr *dtr)
{
PVOP_VCALL1(pv_ops, cpu.load_gdt, dtr);
}
-static inline void load_idt(const struct desc_ptr *dtr)
+static inline void notrace load_idt(const struct desc_ptr *dtr)
{
PVOP_VCALL1(pv_ops, cpu.load_idt, dtr);
}
@@ -234,7 +234,7 @@ static inline void load_TLS(struct thread_struct *t, unsigned cpu)
PVOP_VCALL2(pv_ops, cpu.load_tls, t, cpu);
}
-static inline void load_gs_index(unsigned int gs)
+static inline void notrace load_gs_index(unsigned int gs)
{
PVOP_VCALL1(pv_ops, cpu.load_gs_index, gs);
}
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index dbd90fede5e7..01ed6f1f7952 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -303,7 +303,7 @@ extern const char xen_early_idt_handler_array[NUM_EXCEPTION_VECTORS][XEN_EARLY_I
* FS and GS.
*/
#define LOAD_SEGMENT(seg) \
-static inline void __loadsegment_##seg(u16 value) \
+static inline void notrace __loadsegment_##seg(u16 value) \
{ \
asm volatile("1: movl %k0,%%" #seg "\n" \
_ASM_EXTABLE_TYPE_REG(1b, 1b, EX_TYPE_ZERO_REG, %k0)\
@@ -325,7 +325,7 @@ LOAD_SEGMENT(gs)
#else
-static inline void __loadsegment_fs(u16 value)
+static inline void notrace __loadsegment_fs(u16 value)
{
asm volatile("1: movw %0, %%fs\n"
"2:\n"
diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
index f39891c94e7b..10c30ae70798 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -134,7 +134,7 @@ static inline unsigned long read_cr0(void)
return native_read_cr0();
}
-static inline void write_cr0(unsigned long x)
+static inline void notrace write_cr0(unsigned long x)
{
native_write_cr0(x);
}
@@ -158,12 +158,12 @@ static inline unsigned long __read_cr3(void)
return __native_read_cr3();
}
-static inline void write_cr3(unsigned long x)
+static inline void notrace write_cr3(unsigned long x)
{
native_write_cr3(x);
}
-static inline void __write_cr4(unsigned long x)
+static inline void notrace __write_cr4(unsigned long x)
{
native_write_cr4(x);
}
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 03/22] bpf: Mark bpf_spin_lock helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
2026-12-01 4:21 ` [PATCH v3 01/22] x86/paravirt: Mark native pv_ops helpers notrace Song Liu
2026-12-01 4:21 ` [PATCH v3 02/22] x86: Mark CPU state helpers used by resume and kexec notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:55 ` bot+bpf-ci
2026-12-01 4:21 ` [PATCH v3 04/22] bpf: Mark the BPF trampoline " Song Liu
` (19 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
Commit 178c54666f9c ("bpf: Mark bpf_spin_{lock,unlock}() helpers with
notrace correctly") made bpf_spin_lock() and bpf_spin_unlock()
untraceable, so that an fentry program that also takes the lock cannot
deadlock. These helpers call the static inline functions
__bpf_spin_lock_irqsave(), __bpf_spin_unlock_irqrestore(),
__bpf_spin_lock() and __bpf_spin_unlock(). __bpf_spin_unlock() releases
the lock with queued_spin_unlock(), which is a plain inline function on
x86 with CONFIG_PARAVIRT_SPINLOCKS. The generic version is
__always_inline. __bpf_spin_unlock_irqrestore(), __bpf_spin_unlock()
and queued_spin_unlock() run with the lock held, so an fentry program
attached to an out-of-line copy of one of them can hit the same
deadlock. These copies are untraced today only because inline implies
notrace.
Mark all of these helpers notrace explicitly, so that nothing called by
bpf_spin_lock() and bpf_spin_unlock() is traceable. No functional
change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/x86/include/asm/paravirt-spinlock.h | 2 +-
kernel/bpf/helpers.c | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/x86/include/asm/paravirt-spinlock.h b/arch/x86/include/asm/paravirt-spinlock.h
index 302bc2ba3a75..e064307b39bc 100644
--- a/arch/x86/include/asm/paravirt-spinlock.h
+++ b/arch/x86/include/asm/paravirt-spinlock.h
@@ -71,7 +71,7 @@ static inline void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
pv_queued_spin_lock_slowpath(lock, val);
}
-static inline void queued_spin_unlock(struct qspinlock *lock)
+static inline void notrace queued_spin_unlock(struct qspinlock *lock)
{
kcsan_release();
pv_queued_spin_unlock(lock);
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index cebf9d8dfe36..5a48308f9fa2 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -284,7 +284,7 @@ const struct bpf_func_proto bpf_get_current_comm_proto = {
#if defined(CONFIG_QUEUED_SPINLOCKS) || defined(CONFIG_BPF_ARCH_SPINLOCK)
-static inline void __bpf_spin_lock(struct bpf_spin_lock *lock)
+static inline void notrace __bpf_spin_lock(struct bpf_spin_lock *lock)
{
arch_spinlock_t *l = (void *)lock;
union {
@@ -299,7 +299,7 @@ static inline void __bpf_spin_lock(struct bpf_spin_lock *lock)
arch_spin_lock(l);
}
-static inline void __bpf_spin_unlock(struct bpf_spin_lock *lock)
+static inline void notrace __bpf_spin_unlock(struct bpf_spin_lock *lock)
{
arch_spinlock_t *l = (void *)lock;
@@ -309,7 +309,7 @@ static inline void __bpf_spin_unlock(struct bpf_spin_lock *lock)
#else
-static inline void __bpf_spin_lock(struct bpf_spin_lock *lock)
+static inline void notrace __bpf_spin_lock(struct bpf_spin_lock *lock)
{
atomic_t *l = (void *)lock;
@@ -319,7 +319,7 @@ static inline void __bpf_spin_lock(struct bpf_spin_lock *lock)
} while (atomic_xchg(l, 1));
}
-static inline void __bpf_spin_unlock(struct bpf_spin_lock *lock)
+static inline void notrace __bpf_spin_unlock(struct bpf_spin_lock *lock)
{
atomic_t *l = (void *)lock;
@@ -330,7 +330,7 @@ static inline void __bpf_spin_unlock(struct bpf_spin_lock *lock)
static DEFINE_PER_CPU(unsigned long, irqsave_flags);
-static inline void __bpf_spin_lock_irqsave(struct bpf_spin_lock *lock)
+static inline void notrace __bpf_spin_lock_irqsave(struct bpf_spin_lock *lock)
{
unsigned long flags;
@@ -353,7 +353,7 @@ const struct bpf_func_proto bpf_spin_lock_proto = {
.arg1_btf_id = BPF_PTR_POISON,
};
-static inline void __bpf_spin_unlock_irqrestore(struct bpf_spin_lock *lock)
+static inline void notrace __bpf_spin_unlock_irqrestore(struct bpf_spin_lock *lock)
{
unsigned long flags;
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 03/22] bpf: Mark bpf_spin_lock helpers notrace
2026-12-01 4:21 ` [PATCH v3 03/22] bpf: Mark bpf_spin_lock helpers notrace Song Liu
@ 2026-12-01 4:55 ` bot+bpf-ci
0 siblings, 0 replies; 39+ messages in thread
From: bot+bpf-ci @ 2026-12-01 4:55 UTC (permalink / raw)
To: song, linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, song, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, mason,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2279 bytes --]
> bpf: Mark bpf_spin_lock helpers notrace
TL;DR: Commit message only: the claim that nothing called by
bpf_spin_lock()/unlock() is traceable looks inaccurate, since out-of-line
callees like queued_spin_release_traced() and the qspinlock slowpath remain
traceable; narrow it or cover them.
> bpf: Mark bpf_spin_lock helpers notrace
>
> [ ... ]
> __bpf_spin_unlock_irqrestore(), __bpf_spin_unlock()
> and queued_spin_unlock() run with the lock held, so an fentry program
> attached to an out-of-line copy of one of them can hit the same
> deadlock. These copies are untraced today only because inline implies
> notrace.
> Mark all of these helpers notrace explicitly, so that nothing called by
> bpf_spin_lock() and bpf_spin_unlock() is traceable. No functional
> change.
> [ ... ]
> Signed-off-by: Song Liu <song@kernel.org>
Is the claim that "nothing called by bpf_spin_lock() and bpf_spin_unlock()
is traceable" accurate?
The patch only covers the inline helpers, and btf_id_deny in
kernel/bpf/verifier.c has no lock entries. Some out-of-line callees
remain traceable.
With CONFIG_QUEUED_SPINLOCKS_TRACE_CONTENDED_RELEASE and no x86
PARAVIRT_SPINLOCKS, the generic queued_spin_unlock() calls the extern
queued_spin_release_traced():
kernel/locking/qspinlock.c:queued_spin_release_traced()
It runs with the lock still held, which is the same deadlock the message
describes, and it is not marked notrace (qspinlock.o is not built without
-pg).
queued_spin_lock_slowpath() / native_queued_spin_lock_slowpath() in
qspinlock.c is also a traceable out-of-line function called from the
bpf_spin_lock() path.
The x86 "static inline queued_spin_lock_slowpath" wrapper and
native_queued_spin_unlock() in paravirt-spinlock.h are plain inline and
are not marked. The end of this series (a833438864c3) removes notrace from
inline, so an out-of-line copy of that wrapper in helpers.c would then
become traceable.
Could the sentence be narrowed, or should these callees be covered as well?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 04/22] bpf: Mark the BPF trampoline helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (2 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 03/22] bpf: Mark bpf_spin_lock helpers notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 5:08 ` bot+bpf-ci
2026-12-01 4:21 ` [PATCH v3 05/22] bpf: Mark the bpf_mem_alloc fast path " Song Liu
` (18 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
The BPF trampoline calls __bpf_prog_enter*() before each program and
__bpf_prog_exit*() after it, and calls __bpf_tramp_enter() and
__bpf_tramp_exit() around the traced function. These functions are
notrace: if anything they call could run a BPF program, attaching a
program there would recurse without bound. The recursion check in
__bpf_prog_enter_recur() does not prevent this, because the trampoline
calls the enter and exit functions even for a program it then skips.
For the same reason, btf_id_deny already rejects attaching to the
out-of-line migrate_disable() and migrate_enable(), and, with
CONFIG_PREEMPT_RCU, to __rcu_read_lock() and __rcu_read_unlock().
Many of the helpers they call are plain inline functions:
- bpf_set_run_ctx(), bpf_reset_run_ctx(),
bpf_prog_get_recursion_context() and
bpf_prog_put_recursion_context();
- __migrate_disable() and __migrate_enable();
- the !CONFIG_PREEMPT_RCU __rcu_read_lock() and __rcu_read_unlock(),
rcu_read_unlock() and rcu_read_unlock_migrate(), and the lockdep
annotations rcu_lock_acquire(), rcu_try_lock_acquire() and
rcu_lock_release();
- rcu_read_lock_trace(), rcu_read_unlock_trace() and
srcu_lock_release();
- percpu_ref_get(), percpu_ref_put(), percpu_ref_get_many(),
percpu_ref_put_many() and __ref_is_percpu();
- local_inc() and local_add() on x86, called through u64_stats_inc()
and u64_stats_add() from bpf_prog_inc_misses_counter() and
__update_prog_stats().
An out-of-line copy of any of them is untraced only because inline
implies notrace. Mark them notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/x86/include/asm/local.h | 4 ++--
include/linux/bpf.h | 8 ++++----
include/linux/percpu-refcount.h | 12 ++++++------
include/linux/rcupdate.h | 14 +++++++-------
include/linux/rcupdate_trace.h | 4 ++--
include/linux/sched.h | 8 ++++----
include/linux/srcu.h | 2 +-
7 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
index 68af7b74450a..07b1d52e9ab4 100644
--- a/arch/x86/include/asm/local.h
+++ b/arch/x86/include/asm/local.h
@@ -16,7 +16,7 @@ typedef struct {
#define local_read(l) atomic_long_read(&(l)->a)
#define local_set(l, i) atomic_long_set(&(l)->a, (i))
-static inline void local_inc(local_t *l)
+static inline void notrace local_inc(local_t *l)
{
asm volatile(_ASM_INC "%0"
: "+m" (l->a.counter));
@@ -28,7 +28,7 @@ static inline void local_dec(local_t *l)
: "+m" (l->a.counter));
}
-static inline void local_add(long i, local_t *l)
+static inline void notrace local_add(long i, local_t *l)
{
asm volatile(_ASM_ADD "%1,%0"
: "+m" (l->a.counter)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index a6976776e90b..62714645aa2b 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -2330,7 +2330,7 @@ struct bpf_struct_ops_common_value {
enum bpf_struct_ops_state state;
};
-static inline bool bpf_prog_get_recursion_context(struct bpf_prog *prog)
+static inline bool notrace bpf_prog_get_recursion_context(struct bpf_prog *prog)
{
#ifdef CONFIG_ARM64
u8 rctx = interrupt_context_level();
@@ -2350,7 +2350,7 @@ static inline bool bpf_prog_get_recursion_context(struct bpf_prog *prog)
#endif
}
-static inline void bpf_prog_put_recursion_context(struct bpf_prog *prog)
+static inline void notrace bpf_prog_put_recursion_context(struct bpf_prog *prog)
{
#ifdef CONFIG_ARM64
u8 rctx = interrupt_context_level();
@@ -2769,7 +2769,7 @@ struct bpf_tramp_run_ctx {
struct bpf_run_ctx *saved_run_ctx;
};
-static inline struct bpf_run_ctx *bpf_set_run_ctx(struct bpf_run_ctx *new_ctx)
+static inline notrace struct bpf_run_ctx *bpf_set_run_ctx(struct bpf_run_ctx *new_ctx)
{
struct bpf_run_ctx *old_ctx = NULL;
@@ -2780,7 +2780,7 @@ static inline struct bpf_run_ctx *bpf_set_run_ctx(struct bpf_run_ctx *new_ctx)
return old_ctx;
}
-static inline void bpf_reset_run_ctx(struct bpf_run_ctx *old_ctx)
+static inline void notrace bpf_reset_run_ctx(struct bpf_run_ctx *old_ctx)
{
#ifdef CONFIG_BPF_SYSCALL
current->bpf_ctx = old_ctx;
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
index 1e3212e2c827..ebfcbf668a7e 100644
--- a/include/linux/percpu-refcount.h
+++ b/include/linux/percpu-refcount.h
@@ -155,8 +155,8 @@ static inline void percpu_ref_kill(struct percpu_ref *ref)
* because doing so forces the compiler to generate two conditional
* branches as it can't assume that @ref->percpu_count is not NULL.
*/
-static inline bool __ref_is_percpu(struct percpu_ref *ref,
- unsigned long __percpu **percpu_countp)
+static inline bool notrace __ref_is_percpu(struct percpu_ref *ref,
+ unsigned long __percpu **percpu_countp)
{
unsigned long percpu_ptr;
@@ -195,7 +195,7 @@ static inline bool __ref_is_percpu(struct percpu_ref *ref,
*
* This function is safe to call as long as @ref is between init and exit.
*/
-static inline void percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr)
+static inline void notrace percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr)
{
unsigned long __percpu *percpu_count;
@@ -217,7 +217,7 @@ static inline void percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr)
*
* This function is safe to call as long as @ref is between init and exit.
*/
-static inline void percpu_ref_get(struct percpu_ref *ref)
+static inline void notrace percpu_ref_get(struct percpu_ref *ref)
{
percpu_ref_get_many(ref, 1);
}
@@ -324,7 +324,7 @@ static inline bool percpu_ref_tryget_live(struct percpu_ref *ref)
*
* This function is safe to call as long as @ref is between init and exit.
*/
-static inline void percpu_ref_put_many(struct percpu_ref *ref, unsigned long nr)
+static inline void notrace percpu_ref_put_many(struct percpu_ref *ref, unsigned long nr)
{
unsigned long __percpu *percpu_count;
@@ -347,7 +347,7 @@ static inline void percpu_ref_put_many(struct percpu_ref *ref, unsigned long nr)
*
* This function is safe to call as long as @ref is between init and exit.
*/
-static inline void percpu_ref_put(struct percpu_ref *ref)
+static inline void notrace percpu_ref_put(struct percpu_ref *ref)
{
percpu_ref_put_many(ref, 1);
}
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 3f74ae6d6e1f..5ac08bebc17b 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -107,12 +107,12 @@ void __rcu_read_unlock(void);
void rcu_read_unlock_strict(void);
#endif
-static inline void __rcu_read_lock(void)
+static inline void notrace __rcu_read_lock(void)
{
preempt_disable();
}
-static inline void __rcu_read_unlock(void)
+static inline void notrace __rcu_read_unlock(void)
{
if (IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD))
rcu_read_unlock_strict();
@@ -304,17 +304,17 @@ extern struct lockdep_map rcu_callback_map;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-static inline void rcu_lock_acquire(struct lockdep_map *map)
+static inline void notrace rcu_lock_acquire(struct lockdep_map *map)
{
lock_acquire(map, 0, 0, 2, 0, NULL, _THIS_IP_);
}
-static inline void rcu_try_lock_acquire(struct lockdep_map *map)
+static inline void notrace rcu_try_lock_acquire(struct lockdep_map *map)
{
lock_acquire(map, 0, 1, 2, 0, NULL, _THIS_IP_);
}
-static inline void rcu_lock_release(struct lockdep_map *map)
+static inline void notrace rcu_lock_release(struct lockdep_map *map)
{
lock_release(map, _THIS_IP_);
}
@@ -872,7 +872,7 @@ static __always_inline void rcu_read_lock(void)
*
* See rcu_read_lock() for more information.
*/
-static inline void rcu_read_unlock(void)
+static inline void notrace rcu_read_unlock(void)
__releases_shared(RCU)
{
RCU_LOCKDEP_WARN(!rcu_is_watching(),
@@ -991,7 +991,7 @@ static __always_inline void rcu_read_lock_dont_migrate(void)
rcu_read_lock();
}
-static inline void rcu_read_unlock_migrate(void)
+static inline void notrace rcu_read_unlock_migrate(void)
__releases_shared(RCU)
{
rcu_read_unlock();
diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h
index 273c59a03251..aa1ad9433d36 100644
--- a/include/linux/rcupdate_trace.h
+++ b/include/linux/rcupdate_trace.h
@@ -93,7 +93,7 @@ static inline void rcu_read_unlock_tasks_trace(struct srcu_ctr __percpu *scp)
*
* For more details, please see the documentation for rcu_read_lock().
*/
-static inline void rcu_read_lock_trace(void)
+static inline void notrace rcu_read_lock_trace(void)
{
int n;
struct task_struct *t = current;
@@ -120,7 +120,7 @@ static inline void rcu_read_lock_trace(void)
*
* For more details, please see the documentation for rcu_read_unlock().
*/
-static inline void rcu_read_unlock_trace(void)
+static inline void notrace rcu_read_unlock_trace(void)
{
int n;
struct srcu_ctr __percpu *scp;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e4f6323d7855..f3f0def6da0d 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2441,7 +2441,7 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
#endif
#define this_rq_pinned() (*(unsigned int *)((void *)this_rq_raw() + RQ_nr_pinned))
-static inline void __migrate_enable(void)
+static inline void notrace __migrate_enable(void)
{
struct task_struct *p = current;
@@ -2476,7 +2476,7 @@ static inline void __migrate_enable(void)
this_rq_pinned()--;
}
-static inline void __migrate_disable(void)
+static inline void notrace __migrate_disable(void)
{
struct task_struct *p = current;
@@ -2496,8 +2496,8 @@ static inline void __migrate_disable(void)
p->migration_disabled = 1;
}
#else /* !COMPILE_OFFSETS */
-static inline void __migrate_disable(void) { }
-static inline void __migrate_enable(void) { }
+static inline void notrace __migrate_disable(void) { }
+static inline void notrace __migrate_enable(void) { }
#endif /* !COMPILE_OFFSETS */
/*
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 380b5964fcb4..36f4c6445642 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -250,7 +250,7 @@ static inline void srcu_lock_acquire(struct lockdep_map *map)
}
/* Annotates a srcu_read_lock() */
-static inline void srcu_lock_release(struct lockdep_map *map)
+static inline void notrace srcu_lock_release(struct lockdep_map *map)
{
lock_map_release(map);
}
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 04/22] bpf: Mark the BPF trampoline helpers notrace
2026-12-01 4:21 ` [PATCH v3 04/22] bpf: Mark the BPF trampoline " Song Liu
@ 2026-12-01 5:08 ` bot+bpf-ci
0 siblings, 0 replies; 39+ messages in thread
From: bot+bpf-ci @ 2026-12-01 5:08 UTC (permalink / raw)
To: song, linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, song, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, mason,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 5110 bytes --]
> bpf: Mark the BPF trampoline helpers notrace
TL;DR:
- Possible unbounded BPF trampoline recursion if powerpc local_add helpers
stay unmarked notrace
- Same possible recursion on arm64 via unmarked __percpu_add_case_64() used by
percpu_ref helpers
> diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
> --- a/arch/x86/include/asm/local.h
> +++ b/arch/x86/include/asm/local.h
> @@ -16,7 +16,7 @@ typedef struct {
> #define local_read(l) atomic_long_read(&(l)->a)
> #define local_set(l, i) atomic_long_set(&(l)->a, (i))
>
> -static inline void local_inc(local_t *l)
> +static inline void notrace local_inc(local_t *l)
The commit message says local_inc() and local_add() are marked "on x86",
because u64_stats_inc() and u64_stats_add() reach them from
bpf_prog_inc_misses_counter() and __update_prog_stats().
Should the powerpc equivalents be covered as well? powerpc64 also
supports BPF trampolines and has its own plain __inline__ helpers in
arch/powerpc/include/asm/local.h:
#define LOCAL_OP_RETURN(op, c_op) \
static __inline__ long local_##op##_return(long a, local_t *l) \
...
#define local_inc_return(l) local_add_return(1LL, l)
#define local_inc(l) local_inc_return(l)
On 64-bit, local64_inc() and local64_add() map to local_inc() and
local_add() (include/asm-generic/local64.h), so:
__bpf_prog_enter_recur()
bpf_prog_inc_misses_counter()
u64_stats_inc()
local64_inc()
local_add_return()
__bpf_prog_exit*()
__update_prog_stats()
u64_stats_inc()/u64_stats_add()
local_add_return()/local_add()
Nothing in this series touches arch/powerpc/include/asm/local.h, and a
later commit in the series (compiler_types: Move notrace from inline to
__always_inline) removes the implied notrace from plain inline. If an
out-of-line local_add_return() gets a patchable entry, attaching to it
would make __bpf_prog_enter_recur() reject the program and call
bpf_prog_inc_misses_counter(), which re-enters the trampoline, without
bound.
loongarch looks similar one level down: local_inc()/local_add() are
macros for atomic_long_inc()/atomic_long_add(), ending in
arch_atomic64_add(), a plain static inline in
arch/loongarch/include/asm/atomic-amo.h.
Should the powerpc local_add()/local_add_return() helpers be marked
notrace together with the x86 ones?
[ ... ]
> diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
> --- a/include/linux/percpu-refcount.h
> +++ b/include/linux/percpu-refcount.h
[ ... ]
> @@ -195,7 +195,7 @@ static inline bool __ref_is_percpu(struct percpu_ref *ref,
> *
> * This function is safe to call as long as @ref is between init and exit.
> */
> -static inline void percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr)
> +static inline void notrace percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr)
> {
> unsigned long __percpu *percpu_count;
>
This marks percpu_ref_get_many() and percpu_ref_put_many() notrace because
__bpf_tramp_enter() and __bpf_tramp_exit() call them. On arm64, though,
the per-CPU op they use is still a plain inline helper that nothing in the
series marks:
this_cpu_add()
this_cpu_add_8()
__percpu_add_case_64()
and this_cpu_sub() is this_cpu_add() with a negated value. In
arch/arm64/include/asm/percpu.h the helper is generated as:
#define __PERCPU_OP_CASE(w, sfx, name, sz, op_llsc, op_lse) \
static inline void \
__percpu_##name##_case_##sz(void __percpu *pcp, unsigned long val) \
The arm64 trampoline calls __bpf_tramp_enter() before the fentry programs
when BPF_TRAMP_F_CALL_ORIG is set, so:
arm64 trampoline
__bpf_tramp_enter()
percpu_ref_get()
percpu_ref_get_many()
this_cpu_add()
__percpu_add_case_64()
and likewise __bpf_tramp_exit() -> percpu_ref_put_many() -> this_cpu_sub().
The only later commit in the series touching arch/arm64/include/asm/percpu.h
is "arm64: Mark helpers called from noinstr code notrace", which marks only
__kern_my_cpu_offset(). Its changelog says clang emits an out-of-line copy
of that helper in an arm64 defconfig build, and __percpu_add_case_64() has a
longer ALTERNATIVE asm body, so an out-of-line copy seems at least as
plausible.
Once "compiler_types: Move notrace from inline to __always_inline" lands,
such a copy gets a patchable entry. An fexit or fmod_ret program attached
to it would recurse:
trampoline -> __bpf_tramp_enter() -> __percpu_add_case_64() -> trampoline
-> __bpf_tramp_enter() -> ...
This happens before any __bpf_prog_enter*() recursion check runs. On x86
this_cpu_add() is an asm macro, so this is specific to arm64.
Should the arm64 __percpu_*_case_*() helpers, or at least the add case used
here, be marked notrace as part of this commit?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 05/22] bpf: Mark the bpf_mem_alloc fast path helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (3 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 04/22] bpf: Mark the BPF trampoline " Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 06/22] u64_stats: Mark the update helpers used by BPF notrace Song Liu
` (17 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
unit_alloc(), unit_free() and unit_free_rcu() are notrace so that BPF
programs cannot attach to them and corrupt the per-CPU free lists, as
the comment above unit_alloc() says. To take and release c->active and
to update the free lists, they call local_inc_return()
(local_add_return() on x86), local_dec(), __llist_add() and
llist_add(). These are plain inline functions, as are
__llist_add_batch() and llist_add_batch(), which the llist helpers call.
An out-of-line copy of any of them is untraced only because inline
implies notrace.
Mark them notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/x86/include/asm/local.h | 4 ++--
include/linux/llist.h | 16 ++++++++--------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
index 07b1d52e9ab4..e2f5710af4cb 100644
--- a/arch/x86/include/asm/local.h
+++ b/arch/x86/include/asm/local.h
@@ -22,7 +22,7 @@ static inline void notrace local_inc(local_t *l)
: "+m" (l->a.counter));
}
-static inline void local_dec(local_t *l)
+static inline void notrace local_dec(local_t *l)
{
asm volatile(_ASM_DEC "%0"
: "+m" (l->a.counter));
@@ -103,7 +103,7 @@ static inline bool local_add_negative(long i, local_t *l)
*
* Atomically adds @i to @l and returns @i + @l
*/
-static inline long local_add_return(long i, local_t *l)
+static inline long notrace local_add_return(long i, local_t *l)
{
long __i = i;
asm volatile(_ASM_XADD "%0, %1"
diff --git a/include/linux/llist.h b/include/linux/llist.h
index 413249764f7b..bebfaad36818 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -231,9 +231,9 @@ static inline struct llist_node *llist_next(struct llist_node *node)
*
* Return whether list is empty before adding.
*/
-static inline bool llist_add_batch(struct llist_node *new_first,
- struct llist_node *new_last,
- struct llist_head *head)
+static inline bool notrace llist_add_batch(struct llist_node *new_first,
+ struct llist_node *new_last,
+ struct llist_head *head)
{
struct llist_node *first = READ_ONCE(head->first);
@@ -244,9 +244,9 @@ static inline bool llist_add_batch(struct llist_node *new_first,
return !first;
}
-static inline bool __llist_add_batch(struct llist_node *new_first,
- struct llist_node *new_last,
- struct llist_head *head)
+static inline bool notrace __llist_add_batch(struct llist_node *new_first,
+ struct llist_node *new_last,
+ struct llist_head *head)
{
new_last->next = head->first;
head->first = new_first;
@@ -260,12 +260,12 @@ static inline bool __llist_add_batch(struct llist_node *new_first,
*
* Returns true if the list was empty prior to adding this entry.
*/
-static inline bool llist_add(struct llist_node *new, struct llist_head *head)
+static inline bool notrace llist_add(struct llist_node *new, struct llist_head *head)
{
return llist_add_batch(new, new, head);
}
-static inline bool __llist_add(struct llist_node *new, struct llist_head *head)
+static inline bool notrace __llist_add(struct llist_node *new, struct llist_head *head)
{
return __llist_add_batch(new, new, head);
}
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 06/22] u64_stats: Mark the update helpers used by BPF notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (4 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 05/22] bpf: Mark the bpf_mem_alloc fast path " Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:55 ` bot+bpf-ci
2026-12-01 4:21 ` [PATCH v3 07/22] tracepoint: Mark __do_trace_##name() notrace Song Liu
` (16 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
bpf_prog_inc_misses_counter() is notrace because it runs when a BPF
program was not run due to recursion. If it could call traced code, an
fentry program attached to that code would recurse forever. It calls
u64_stats_update_begin_irqsave(), u64_stats_inc() and
u64_stats_update_end_irqrestore(). The BPF trampoline calls
u64_stats_add() and u64_stats_inc() from __update_prog_stats() in the
same way. These are plain inline helpers, so an out-of-line copy is
untraced only because inline implies notrace.
Mark these helpers, and the __u64_stats_*() helpers they call, notrace
explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/u64_stats_sync.h | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h
index f47cf4d78ad7..06e5bffd0287 100644
--- a/include/linux/u64_stats_sync.h
+++ b/include/linux/u64_stats_sync.h
@@ -92,7 +92,7 @@ static inline void u64_stats_set(u64_stats_t *p, u64 val)
local64_set(&p->v, val);
}
-static inline void u64_stats_add(u64_stats_t *p, unsigned long val)
+static inline void notrace u64_stats_add(u64_stats_t *p, unsigned long val)
{
local64_add(val, &p->v);
}
@@ -102,16 +102,16 @@ static inline void u64_stats_sub(u64_stats_t *p, s64 val)
local64_sub(val, &p->v);
}
-static inline void u64_stats_inc(u64_stats_t *p)
+static inline void notrace u64_stats_inc(u64_stats_t *p)
{
local64_inc(&p->v);
}
static inline void u64_stats_init(struct u64_stats_sync *syncp) { }
-static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp) { }
-static inline void __u64_stats_update_end(struct u64_stats_sync *syncp) { }
-static inline unsigned long __u64_stats_irqsave(void) { return 0; }
-static inline void __u64_stats_irqrestore(unsigned long flags) { }
+static inline void notrace __u64_stats_update_begin(struct u64_stats_sync *syncp) { }
+static inline void notrace __u64_stats_update_end(struct u64_stats_sync *syncp) { }
+static inline unsigned long notrace __u64_stats_irqsave(void) { return 0; }
+static inline void notrace __u64_stats_irqrestore(unsigned long flags) { }
static inline unsigned int __u64_stats_fetch_begin(const struct u64_stats_sync *syncp)
{
return 0;
@@ -145,7 +145,7 @@ static inline void u64_stats_set(u64_stats_t *p, u64 val)
p->v = val;
}
-static inline void u64_stats_add(u64_stats_t *p, unsigned long val)
+static inline void notrace u64_stats_add(u64_stats_t *p, unsigned long val)
{
p->v += val;
}
@@ -155,7 +155,7 @@ static inline void u64_stats_sub(u64_stats_t *p, s64 val)
p->v -= val;
}
-static inline void u64_stats_inc(u64_stats_t *p)
+static inline void notrace u64_stats_inc(u64_stats_t *p)
{
p->v++;
}
@@ -166,19 +166,19 @@ static inline void u64_stats_inc(u64_stats_t *p)
seqcount_init(&__s->seq); \
} while (0)
-static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp)
+static inline void notrace __u64_stats_update_begin(struct u64_stats_sync *syncp)
{
preempt_disable_nested();
write_seqcount_begin(&syncp->seq);
}
-static inline void __u64_stats_update_end(struct u64_stats_sync *syncp)
+static inline void notrace __u64_stats_update_end(struct u64_stats_sync *syncp)
{
write_seqcount_end(&syncp->seq);
preempt_enable_nested();
}
-static inline unsigned long __u64_stats_irqsave(void)
+static inline unsigned long notrace __u64_stats_irqsave(void)
{
unsigned long flags;
@@ -186,7 +186,7 @@ static inline unsigned long __u64_stats_irqsave(void)
return flags;
}
-static inline void __u64_stats_irqrestore(unsigned long flags)
+static inline void notrace __u64_stats_irqrestore(unsigned long flags)
{
local_irq_restore(flags);
}
@@ -213,7 +213,7 @@ static inline void u64_stats_update_end(struct u64_stats_sync *syncp)
__u64_stats_update_end(syncp);
}
-static inline unsigned long u64_stats_update_begin_irqsave(struct u64_stats_sync *syncp)
+static inline unsigned long notrace u64_stats_update_begin_irqsave(struct u64_stats_sync *syncp)
{
unsigned long flags = __u64_stats_irqsave();
@@ -221,8 +221,8 @@ static inline unsigned long u64_stats_update_begin_irqsave(struct u64_stats_sync
return flags;
}
-static inline void u64_stats_update_end_irqrestore(struct u64_stats_sync *syncp,
- unsigned long flags)
+static inline void notrace u64_stats_update_end_irqrestore(struct u64_stats_sync *syncp,
+ unsigned long flags)
{
__u64_stats_update_end(syncp);
__u64_stats_irqrestore(flags);
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 06/22] u64_stats: Mark the update helpers used by BPF notrace
2026-12-01 4:21 ` [PATCH v3 06/22] u64_stats: Mark the update helpers used by BPF notrace Song Liu
@ 2026-12-01 4:55 ` bot+bpf-ci
0 siblings, 0 replies; 39+ messages in thread
From: bot+bpf-ci @ 2026-12-01 4:55 UTC (permalink / raw)
To: song, linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, song, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, mason,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 1997 bytes --]
> u64_stats: Mark the update helpers used by BPF notrace
TL;DR: The seqcount helpers called by the u64_stats helpers
(32-bit/PREEMPT_RT) aren't marked notrace, so once plain inline stops implying
notrace, an fentry program may possibly recurse from BPF stats updates.
> diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h
> --- a/include/linux/u64_stats_sync.h
> +++ b/include/linux/u64_stats_sync.h
[ ... ]
> @@ -166,19 +166,19 @@ static inline void u64_stats_inc(u64_stats_t *p)
> seqcount_init(&__s->seq); \
> } while (0)
>
> -static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp)
> +static inline void notrace __u64_stats_update_begin(struct u64_stats_sync *syncp)
> {
> preempt_disable_nested();
> write_seqcount_begin(&syncp->seq);
> }
>
> -static inline void __u64_stats_update_end(struct u64_stats_sync *syncp)
> +static inline void notrace __u64_stats_update_end(struct u64_stats_sync *syncp)
> {
> write_seqcount_end(&syncp->seq);
> preempt_enable_nested();
> }
On 32-bit and PREEMPT_RT, these helpers call write_seqcount_begin() and
write_seqcount_end(), which expand to do_write_seqcount_begin() and
do_write_seqcount_end() in include/linux/seqlock.h, and then to the
do_raw_write_seqcount_*() helpers.
Those are plain static inline without notrace. Once the last patch in this
series removes notrace from plain inline, can an out-of-line copy of them
be traced?
If so, could an fentry program attached there and run from
bpf_prog_inc_misses_counter() or __update_prog_stats() recurse, which is
what this patch is meant to prevent?
Should the seqcount helpers be marked notrace as well, or is the
commit message claim that the helpers they call are covered too broad?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 07/22] tracepoint: Mark __do_trace_##name() notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (5 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 06/22] u64_stats: Mark the update helpers used by BPF notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 08/22] srcu: Mark the fast notrace read-side helpers notrace Song Liu
` (15 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
__do_trace_##name() takes the tracepoint SRCU read lock and calls the
probes. It is called from trace_##name(), trace_call__##name(), and the
notrace rust_do_trace_##name(). It is a plain inline function, so if
the compiler emits it out of line, that copy is untraced only because
inline implies notrace.
Mark it notrace explicitly. No functional change.
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/tracepoint.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index e0d838c9ce93..1cd18b56c0a8 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -308,7 +308,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
#define __DECLARE_TRACE(name, proto, args, cond, data_proto) \
__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
- static inline void __do_trace_##name(proto) \
+ static inline void notrace __do_trace_##name(proto) \
{ \
TRACEPOINT_CHECK(name) \
if (cond) { \
@@ -332,7 +332,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
#define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto) \
__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
- static inline void __do_trace_##name(proto) \
+ static inline void notrace __do_trace_##name(proto) \
{ \
TRACEPOINT_CHECK(name) \
guard(rcu_tasks_trace)(); \
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 08/22] srcu: Mark the fast notrace read-side helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (6 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 07/22] tracepoint: Mark __do_trace_##name() notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:39 ` sashiko-bot
2026-12-01 4:21 ` [PATCH v3 09/22] arm64: Mark the preempt count " Song Liu
` (14 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
srcu_read_lock_fast_notrace() and srcu_read_unlock_fast_notrace() are
used by tracepoints, and their comments say they cannot be traced. They
are plain inline functions, as are srcu_check_read_flavor() and the
Tiny SRCU versions of __srcu_read_lock_fast() and
__srcu_read_unlock_fast() that they call. An out-of-line copy of any of
them is untraced only because inline implies notrace.
Mark them notrace explicitly, as srcu_read_lock_notrace() and the Tree
SRCU __srcu_read_lock_fast() and __srcu_read_unlock_fast() already are.
No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/srcu.h | 8 +++++---
include/linux/srcutiny.h | 5 +++--
include/linux/srcutree.h | 2 +-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 36f4c6445642..fab834f2d870 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -487,7 +487,8 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast_updown(struct srcu_s
* Used by tracing, cannot be traced and cannot call lockdep.
* See srcu_read_lock_fast() for more information.
*/
-static inline struct srcu_ctr __percpu *srcu_read_lock_fast_notrace(struct srcu_struct *ssp)
+static inline struct srcu_ctr __percpu notrace *
+srcu_read_lock_fast_notrace(struct srcu_struct *ssp)
__acquires_shared(ssp)
{
struct srcu_ctr __percpu *retval;
@@ -651,8 +652,9 @@ srcu_read_unlock_fast_updown(struct srcu_struct *ssp, struct srcu_ctr __percpu *
* Used by tracing, cannot be traced and cannot call lockdep.
* See srcu_read_unlock_fast() for more information.
*/
-static inline void srcu_read_unlock_fast_notrace(struct srcu_struct *ssp,
- struct srcu_ctr __percpu *scp) __releases_shared(ssp)
+static inline void notrace
+srcu_read_unlock_fast_notrace(struct srcu_struct *ssp,
+ struct srcu_ctr __percpu *scp) __releases_shared(ssp)
{
srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_FAST);
__srcu_read_unlock_fast(ssp, scp);
diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h
index 47a368f945e3..c6f9ff9e1557 100644
--- a/include/linux/srcutiny.h
+++ b/include/linux/srcutiny.h
@@ -114,13 +114,14 @@ static inline struct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ss
return (struct srcu_ctr __percpu *)(intptr_t)idx;
}
-static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct *ssp)
+static inline struct srcu_ctr __percpu notrace *__srcu_read_lock_fast(struct srcu_struct *ssp)
__acquires_shared(ssp)
{
return __srcu_ctr_to_ptr(ssp, __srcu_read_lock(ssp));
}
-static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
+static inline void notrace
+__srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
__releases_shared(ssp)
{
__srcu_read_unlock(ssp, __srcu_ptr_to_ctr(ssp, scp));
diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
index 93b76e543894..8ca6ae6a74ad 100644
--- a/include/linux/srcutree.h
+++ b/include/linux/srcutree.h
@@ -381,7 +381,7 @@ __srcu_read_unlock_fast_updown(struct srcu_struct *ssp, struct srcu_ctr __percpu
void __srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor);
// Record SRCU-reader usage type only for CONFIG_PROVE_RCU=y kernels.
-static inline void srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor)
+static inline void notrace srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor)
{
if (IS_ENABLED(CONFIG_PROVE_RCU))
__srcu_check_read_flavor(ssp, read_flavor);
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 08/22] srcu: Mark the fast notrace read-side helpers notrace
2026-12-01 4:21 ` [PATCH v3 08/22] srcu: Mark the fast notrace read-side helpers notrace Song Liu
@ 2026-12-01 4:39 ` sashiko-bot
0 siblings, 0 replies; 39+ messages in thread
From: sashiko-bot @ 2026-12-01 4:39 UTC (permalink / raw)
To: Song Liu, linux-trace-kernel, live-patching, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] srcu: missing notrace on Tiny SRCU inline helpers called by fast
lock/unlock
--
commit 58446ad08cebec81369ae61a32f8e4673fca1dc1
Author: Song Liu <song@kernel.org>
srcu: Mark the fast notrace read-side helpers notrace
This commit adds explicit notrace annotations to
srcu_read_lock_fast_notrace(), srcu_read_unlock_fast_notrace(),
srcu_check_read_flavor(), and the Tiny SRCU implementations of
__srcu_read_lock_fast() and __srcu_read_unlock_fast().
> diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h
> index 47a368f945e34..c6f9ff9e15579 100644
> --- a/include/linux/srcutiny.h
> +++ b/include/linux/srcutiny.h
> @@ -114,13 +114,14 @@ static inline struct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ss
> return (struct srcu_ctr __percpu *)(intptr_t)idx;
> }
>
> -static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct *ssp)
> +static inline struct srcu_ctr __percpu notrace *__srcu_read_lock_fast(struct srcu_struct *ssp)
> __acquires_shared(ssp)
> {
> return __srcu_ctr_to_ptr(ssp, __srcu_read_lock(ssp));
> }
>
> -static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
> +static inline void notrace
> +__srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
> __releases_shared(ssp)
> {
> __srcu_read_unlock(ssp, __srcu_ptr_to_ctr(ssp, scp));
[Severity: Low]
Should __srcu_read_lock(), __srcu_ctr_to_ptr(), and __srcu_ptr_to_ctr() in
include/linux/srcutiny.h also be marked notrace?
__srcu_read_lock_fast() and __srcu_read_unlock_fast() call those plain
static inline helpers directly (and srcu_read_lock_notrace() also calls
__srcu_read_lock()). Once commit "compiler_types: Move notrace from
inline to __always_inline" drops notrace from inline, any out-of-line copy
of those helpers under CONFIG_TINY_SRCU will be traceable when called from
tracepoints.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201042201.3199928-1-song@kernel.org?part=8
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 09/22] arm64: Mark the preempt count helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (7 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 08/22] srcu: Mark the fast notrace read-side helpers notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 10/22] powerpc, csky, mips, sh: Mark the accessors behind current notrace Song Liu
` (13 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
ftrace_test_recursion_trylock() reads preempt_count() to find the
current context, and preempt_disable_notrace() and
preempt_enable_notrace() use __preempt_count_add(),
__preempt_count_sub(), __preempt_count_dec_and_test() and
should_resched(). On arm64 these are plain inline functions. If the
compiler emits one of them out of line, that copy is untraced only
because inline implies notrace, and tracing it would recurse before the
recursion check takes effect.
Mark them, and preempt_count_set(), notrace explicitly. The x86 and
generic versions are __always_inline. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/arm64/include/asm/preempt.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h
index 75a592b7f47f..d371e09c1521 100644
--- a/arch/arm64/include/asm/preempt.h
+++ b/arch/arm64/include/asm/preempt.h
@@ -7,12 +7,12 @@
#define PREEMPT_NEED_RESCHED BIT(32)
#define PREEMPT_ENABLED (PREEMPT_NEED_RESCHED)
-static inline int preempt_count(void)
+static inline int notrace preempt_count(void)
{
return READ_ONCE(current_thread_info()->preempt.count);
}
-static inline void preempt_count_set(u64 pc)
+static inline void notrace preempt_count_set(u64 pc)
{
/* Preserve existing value of PREEMPT_NEED_RESCHED */
WRITE_ONCE(current_thread_info()->preempt.count, pc);
@@ -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 inline void notrace __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 inline void notrace __preempt_count_sub(int val)
{
u32 pc = READ_ONCE(current_thread_info()->preempt.count);
pc -= val;
@@ -75,13 +75,13 @@ static inline int __preempt_count_sub_return(int val)
return pc;
}
-static inline bool should_resched(int preempt_offset)
+static inline bool notrace should_resched(int preempt_offset)
{
u64 pc = READ_ONCE(current_thread_info()->preempt_count);
return unlikely(pc == preempt_offset);
}
-static inline bool __preempt_count_dec_and_test(void)
+static inline bool notrace __preempt_count_dec_and_test(void)
{
/*
* We must load the combined 'preempt_count' after decrementing
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 10/22] powerpc, csky, mips, sh: Mark the accessors behind current notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (8 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 09/22] arm64: Mark the preempt count " Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 5:08 ` bot+bpf-ci
2026-12-01 4:21 ` [PATCH v3 11/22] rcu: Mark the Tiny RCU rcu_is_watching() notrace Song Liu
` (12 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
ftrace_test_recursion_trylock() reads current->trace_recursion before
it knows whether it is safe to trace, so reading current must never be
a traced call. On powerpc, get_current() is a plain inline function. On
csky, mips and sh, current comes from the generic get_current(), which
calls current_thread_info(), and current_thread_info() is a plain inline
function. An out-of-line copy of any of these is untraced only because
inline implies notrace.
Mark them notrace explicitly. On the other architectures that support
the function tracer, get_current() is already __always_inline. No
functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/csky/include/asm/thread_info.h | 2 +-
arch/mips/include/asm/thread_info.h | 2 +-
arch/powerpc/include/asm/current.h | 2 +-
arch/sh/include/asm/thread_info.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/csky/include/asm/thread_info.h b/arch/csky/include/asm/thread_info.h
index fdd4f8ad45ac..d39498883c9a 100644
--- a/arch/csky/include/asm/thread_info.h
+++ b/arch/csky/include/asm/thread_info.h
@@ -42,7 +42,7 @@ struct thread_info {
#define thread_saved_lr(tsk) \
((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r15))
-static inline struct thread_info *current_thread_info(void)
+static inline notrace struct thread_info *current_thread_info(void)
{
unsigned long sp;
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index 2707dad260dd..4d531efd89ec 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -64,7 +64,7 @@ extern struct thread_info *__current_thread_info;
register struct thread_info *__current_thread_info __asm__("$28");
#endif
-static inline struct thread_info *current_thread_info(void)
+static inline notrace struct thread_info *current_thread_info(void)
{
return __current_thread_info;
}
diff --git a/arch/powerpc/include/asm/current.h b/arch/powerpc/include/asm/current.h
index bbfb94800415..9663d3737d5c 100644
--- a/arch/powerpc/include/asm/current.h
+++ b/arch/powerpc/include/asm/current.h
@@ -12,7 +12,7 @@ struct task_struct;
#include <linux/stddef.h>
#include <asm/paca.h>
-static inline struct task_struct *get_current(void)
+static inline notrace struct task_struct *get_current(void)
{
struct task_struct *task;
diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h
index 471db5173036..9e1ccdd70a7d 100644
--- a/arch/sh/include/asm/thread_info.h
+++ b/arch/sh/include/asm/thread_info.h
@@ -63,7 +63,7 @@ struct thread_info {
register unsigned long current_stack_pointer asm("r15") __used;
/* how to get the thread information struct from C */
-static inline struct thread_info *current_thread_info(void)
+static inline notrace struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
#if defined(CONFIG_CPU_HAS_SR_RB)
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 10/22] powerpc, csky, mips, sh: Mark the accessors behind current notrace
2026-12-01 4:21 ` [PATCH v3 10/22] powerpc, csky, mips, sh: Mark the accessors behind current notrace Song Liu
@ 2026-12-01 5:08 ` bot+bpf-ci
0 siblings, 0 replies; 39+ messages in thread
From: bot+bpf-ci @ 2026-12-01 5:08 UTC (permalink / raw)
To: song, linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, song, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, mason,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 3041 bytes --]
> powerpc, csky, mips, sh: Mark the accessors behind current notrace
TL;DR: Microblaze's current_thread_info() is not marked notrace; once inline
stops implying notrace, ftrace may possibly recurse without bound before the
recursion bit is set. Should it get the same annotation?
> diff --git a/arch/csky/include/asm/thread_info.h b/arch/csky/include/asm/thread_info.h
> --- a/arch/csky/include/asm/thread_info.h
> +++ b/arch/csky/include/asm/thread_info.h
> @@ -42,7 +42,7 @@ struct thread_info {
> #define thread_saved_lr(tsk) \
> ((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r15))
>
> -static inline struct thread_info *current_thread_info(void)
> +static inline notrace struct thread_info *current_thread_info(void)
> {
> unsigned long sp;
>
[ ... ]
Microblaze also selects HAVE_FUNCTION_TRACER and does not select
THREAD_INFO_IN_TASK, and its current_thread_info() is still a plain inline:
arch/microblaze/include/asm/thread_info.h:
static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm("r1");
return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
}
On microblaze, current is the r31 register variable, so this helper is not
behind current. It is behind preempt_count() though, because microblaze
uses the generic include/asm-generic/preempt.h:
static __always_inline int preempt_count(void)
{
return READ_ONCE(current_thread_info()->preempt_count);
}
The recursion protection reaches it before the recursion bit is set:
function_trace_call()
ftrace_test_recursion_trylock()
trace_test_and_set_recursion()
trace_get_context_bit()
interrupt_context_level()
preempt_count()
current_thread_info()
preempt_disable_notrace() at the end of trace_test_and_set_recursion() also
reaches it through preempt_count_ptr().
Right now the helper is still notrace because inline implies notrace. Once
a833438864c3 ("compiler_types: Move notrace from inline to __always_inline")
removes that, can an out-of-line copy of microblaze's current_thread_info()
get an mcount call, so that tracing it re-enters the callback before the
recursion bit is set and recurses without bound?
This is the same condition the patch handles on csky, mips and sh, where
current_thread_info() is behind both current and the generic
preempt_count(). The arm64 patch 4a65f9d5e118 says the generic preempt count
helpers are __always_inline, but they depend on the arch's
current_thread_info().
No commit in this series touches arch/microblaze. m68k, nios2 and arc keep
a plain inline current_thread_info() but do not select HAVE_FUNCTION_TRACER.
Should arch/microblaze/include/asm/thread_info.h get the same notrace
annotation, here or in the preempt count patch?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 11/22] rcu: Mark the Tiny RCU rcu_is_watching() notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (9 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 10/22] powerpc, csky, mips, sh: Mark the accessors behind current notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 12/22] tracing: Mark the tracing_gen_ctx helpers notrace Song Liu
` (11 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
ftrace_test_recursion_trylock() calls rcu_is_watching() before it has
taken the recursion lock. The Tree RCU version is a notrace function,
but the Tiny RCU version is a plain inline function. An out-of-line copy
of it is untraced only because inline implies notrace.
Mark it notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/rcutiny.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index e56ded733b1b..38a3427de0c7 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -123,7 +123,7 @@ static inline void rcu_preempt_deferred_qs(struct task_struct *t) { }
void rcu_scheduler_starting(void);
static inline void rcu_end_inkernel_boot(void) { }
static inline bool rcu_inkernel_boot_has_ended(void) { return true; }
-static inline bool rcu_is_watching(void) { return true; }
+static inline bool notrace rcu_is_watching(void) { return true; }
static inline void rcu_momentary_eqs(void) { }
/* Avoid RCU read-side critical sections leaking across. */
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 12/22] tracing: Mark the tracing_gen_ctx helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (10 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 11/22] rcu: Mark the Tiny RCU rcu_is_watching() notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 13/22] ktime: Mark ktime_to_ns() notrace Song Liu
` (10 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
tracing_gen_ctx(), tracing_gen_ctx_flags() and tracing_gen_ctx_dec()
are called by ftrace callbacks before they take any recursion
protection, for example function_test_events_call() in
kernel/trace/trace_events.c, which is built with -pg when
CONFIG_FUNCTION_SELF_TRACING=y. They are plain inline functions, so an
out-of-line copy is untraced only because inline implies notrace.
Mark them notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/trace_events.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 7a0aa23825de..6ff256b6655c 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -197,13 +197,13 @@ enum trace_flag_type {
TRACE_FLAG_BH_OFF = 0x80,
};
-static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
+static inline unsigned int notrace tracing_gen_ctx_flags(unsigned long irqflags)
{
unsigned int irq_status = irqs_disabled_flags(irqflags) ?
TRACE_FLAG_IRQS_OFF : 0;
return tracing_gen_ctx_irq_test(irq_status);
}
-static inline unsigned int tracing_gen_ctx(void)
+static inline unsigned int notrace tracing_gen_ctx(void)
{
unsigned long irqflags;
@@ -211,7 +211,7 @@ static inline unsigned int tracing_gen_ctx(void)
return tracing_gen_ctx_flags(irqflags);
}
-static inline unsigned int tracing_gen_ctx_dec(void)
+static inline unsigned int notrace tracing_gen_ctx_dec(void)
{
unsigned int trace_ctx;
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 13/22] ktime: Mark ktime_to_ns() notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (11 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 12/22] tracing: Mark the tracing_gen_ctx helpers notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 14/22] kallsyms: Mark the kernel text address checks notrace Song Liu
` (9 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
The NMI safe accessors used as trace clocks, such as
ktime_get_mono_fast_ns() and ktime_get_boot_fast_ns(), are notrace and
call ktime_to_ns(). ktime_to_ns() is a plain inline function, so an
out-of-line copy is untraced only because inline implies notrace, and
tracing it would recurse through the trace clock.
Mark it notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/ktime.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index f247e564602f..ed56774f68ea 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -75,7 +75,7 @@ static inline ktime_t timespec64_to_ktime(struct timespec64 ts)
#define ktime_to_timespec64(kt) ns_to_timespec64((kt))
/* Convert ktime_t to nanoseconds */
-static inline s64 ktime_to_ns(const ktime_t kt)
+static inline s64 notrace ktime_to_ns(const ktime_t kt)
{
return kt;
}
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 14/22] kallsyms: Mark the kernel text address checks notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (12 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 13/22] ktime: Mark ktime_to_ns() notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:36 ` sashiko-bot
2026-12-01 4:21 ` [PATCH v3 15/22] uaccess: Mark pagefault_disable() and pagefault_enable() notrace Song Liu
` (8 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
Commit c0d80ddab899 ("kernel/extable.c: mark core_kernel_text notrace")
made core_kernel_text() notrace, because the MIPS function graph tracer
calls it and tracing it recursed without bound. core_kernel_text()
calls is_kernel_text() and is_kernel_inittext(), and is_kernel_text()
calls __is_kernel_text(). These are plain inline functions, so an
out-of-line copy of any of them is untraced only because inline implies
notrace.
Mark them notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/asm-generic/sections.h | 4 ++--
include/linux/kallsyms.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 0755bc39b0d8..d478ddc02316 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -193,7 +193,7 @@ static inline bool is_kernel_ro_after_init(unsigned long addr)
*
* Returns: true if the address is located in .init.text, false otherwise.
*/
-static inline bool is_kernel_inittext(unsigned long addr)
+static inline bool notrace is_kernel_inittext(unsigned long addr)
{
return addr >= (unsigned long)_sinittext &&
addr < (unsigned long)_einittext;
@@ -208,7 +208,7 @@ static inline bool is_kernel_inittext(unsigned long addr)
* Returns: true if the address is located in .text, false otherwise.
* Note: an internal helper, only check the range of _stext to _etext.
*/
-static inline bool __is_kernel_text(unsigned long addr)
+static inline bool notrace __is_kernel_text(unsigned long addr)
{
return addr >= (unsigned long)_stext &&
addr < (unsigned long)_etext;
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index d5dd54c53ace..93c830b35aeb 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -24,7 +24,7 @@
struct cred;
struct module;
-static inline int is_kernel_text(unsigned long addr)
+static inline int notrace is_kernel_text(unsigned long addr)
{
if (__is_kernel_text(addr))
return 1;
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 14/22] kallsyms: Mark the kernel text address checks notrace
2026-12-01 4:21 ` [PATCH v3 14/22] kallsyms: Mark the kernel text address checks notrace Song Liu
@ 2026-12-01 4:36 ` sashiko-bot
0 siblings, 0 replies; 39+ messages in thread
From: sashiko-bot @ 2026-12-01 4:36 UTC (permalink / raw)
To: Song Liu, linux-trace-kernel, live-patching, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] kallsyms: missing notrace on in_gate_area_no_mm() called by
is_kernel_text()
--
commit 2feaa205ac66915ee68ecd74dd6cf20dacbb4d93
Author: Song Liu <song@kernel.org>
kallsyms: Mark the kernel text address checks notrace
This commit marks is_kernel_inittext(), __is_kernel_text(), and
is_kernel_text() as notrace so out-of-line copies of these inline helpers
cannot be traced when called from core_kernel_text().
[ ... ]
> diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
> index d5dd54c53ace6..93c830b35aeba 100644
> --- a/include/linux/kallsyms.h
> +++ b/include/linux/kallsyms.h
> @@ -24,7 +24,7 @@
> struct cred;
> struct module;
>
> -static inline int is_kernel_text(unsigned long addr)
> +static inline int notrace is_kernel_text(unsigned long addr)
> {
> if (__is_kernel_text(addr))
> return 1;
[Severity: Medium]
Should in_gate_area_no_mm() also be marked notrace?
When __is_kernel_text(addr) returns false (for example, on module or
.init.text addresses before core_kernel_text() reaches
is_kernel_inittext()), is_kernel_text() calls in_gate_area_no_mm(addr).
On MIPS and other architectures without __HAVE_ARCH_GATE_AREA,
in_gate_area_no_mm() in include/linux/mm.h is a plain static inline
function without notrace, so an out-of-line copy of it can still cause the
MIPS function graph tracer to recurse without bound when inline no longer
implies notrace.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201042201.3199928-1-song@kernel.org?part=14
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 15/22] uaccess: Mark pagefault_disable() and pagefault_enable() notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (13 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 14/22] kallsyms: Mark the kernel text address checks notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 16/22] context_tracking: Mark exception_enter() and exception_exit() notrace Song Liu
` (7 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
copy_to_kernel_nofault() and copy_to_user_nofault() are declared
notrace in <linux/uaccess.h>. They call pagefault_disable() and
pagefault_enable(), which are plain inline functions, so an out-of-line
copy is untraced only because inline implies notrace.
Mark them notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/uaccess.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 67cdb0a4f583..dd83c33ec23a 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -260,7 +260,7 @@ static __always_inline void pagefault_disabled_dec(void)
* User access methods will not sleep when called from a pagefault_disabled()
* environment.
*/
-static inline void pagefault_disable(void)
+static inline void notrace pagefault_disable(void)
{
pagefault_disabled_inc();
/*
@@ -270,7 +270,7 @@ static inline void pagefault_disable(void)
barrier();
}
-static inline void pagefault_enable(void)
+static inline void notrace pagefault_enable(void)
{
/*
* make sure to issue those last loads/stores before enabling
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 16/22] context_tracking: Mark exception_enter() and exception_exit() notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (14 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 15/22] uaccess: Mark pagefault_disable() and pagefault_enable() notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 17/22] thread_info: Mark the thread flag helpers notrace Song Liu
` (6 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
The tracing code uses preempt_enable_notrace(), which calls
preempt_schedule_notrace(). Tracing can happen before the kernel has
left user context, so preempt_schedule_notrace() calls exception_enter()
to leave it before calling the scheduler. exception_enter() therefore
runs while RCU may not be watching. exception_enter() and
exception_exit() are plain inline functions, so an out-of-line copy is
untraced only because inline implies notrace. With clang, a powerpc
ppc64le_defconfig build has such a copy of exception_enter(), called
from preempt_schedule_notrace().
Mark them notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/context_tracking.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index af9fe87a0922..0059328995cc 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -48,7 +48,7 @@ static __always_inline void user_exit_irqoff(void)
__ct_user_exit(CT_STATE_USER);
}
-static inline enum ctx_state exception_enter(void)
+static inline enum ctx_state notrace exception_enter(void)
{
enum ctx_state prev_ctx;
@@ -63,7 +63,7 @@ static inline enum ctx_state exception_enter(void)
return prev_ctx;
}
-static inline void exception_exit(enum ctx_state prev_ctx)
+static inline void notrace exception_exit(enum ctx_state prev_ctx)
{
if (!IS_ENABLED(CONFIG_HAVE_CONTEXT_TRACKING_USER_OFFSTACK) &&
context_tracking_enabled()) {
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 17/22] thread_info: Mark the thread flag helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (15 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 16/22] context_tracking: Mark exception_enter() and exception_exit() notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:21 ` [PATCH v3 18/22] arm64: Mark helpers called from noinstr code notrace Song Liu
` (5 subsequent siblings)
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
set_ti_thread_flag(), clear_ti_thread_flag() and the other thread flag
helpers are plain inline functions. Some idle code uses them while RCU
is not watching: snooze_loop() on pseries is a cpuidle state without
CPUIDLE_FLAG_RCU_IDLE, so it runs after cpuidle_enter_state() has called
ct_cpuidle_enter(), and it sets and clears TIF_POLLING_NRFLAG. With
clang, a powerpc ppc64le_defconfig build has out-of-line copies of
set_ti_thread_flag() and clear_ti_thread_flag(), called from
snooze_loop(). The copies are untraced only because inline implies
notrace.
Mark the thread flag helpers notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/thread_info.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 307b8390fc67..e62633233cad 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -99,17 +99,17 @@ static inline long set_restart_fn(struct restart_block *restart,
* - pass TIF_xxxx constants to these functions
*/
-static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
+static inline notrace void set_ti_thread_flag(struct thread_info *ti, int flag)
{
set_bit(flag, (unsigned long *)&ti->flags);
}
-static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
+static inline notrace void clear_ti_thread_flag(struct thread_info *ti, int flag)
{
clear_bit(flag, (unsigned long *)&ti->flags);
}
-static inline void update_ti_thread_flag(struct thread_info *ti, int flag,
+static inline notrace void update_ti_thread_flag(struct thread_info *ti, int flag,
bool value)
{
if (value)
@@ -118,17 +118,17 @@ static inline void update_ti_thread_flag(struct thread_info *ti, int flag,
clear_ti_thread_flag(ti, flag);
}
-static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
+static inline notrace int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
{
return test_and_set_bit(flag, (unsigned long *)&ti->flags);
}
-static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
+static inline notrace int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
{
return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
}
-static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
+static inline notrace int test_ti_thread_flag(struct thread_info *ti, int flag)
{
return test_bit(flag, (unsigned long *)&ti->flags);
}
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 18/22] arm64: Mark helpers called from noinstr code notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (16 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 17/22] thread_info: Mark the thread flag helpers notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:53 ` sashiko-bot
2026-12-01 4:21 ` [PATCH v3 19/22] arm64: Mark the stack unwinder helpers notrace Song Liu
` (4 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
Some arm64 noinstr code calls plain inline helpers at points where
tracing is not safe:
- el0_ia(), el0_pc(), el0_breakpt() and el0_softstp() call
is_ttbr0_addr(), which reads TCR_EL1 with read_tcr() to compute
TASK_SIZE, and arm64_apply_bp_hardening(), which reads the per-CPU
offset with __kern_my_cpu_offset(). el0_pc() also calls
instruction_pointer(). This runs before arm64_enter_from_user_mode(),
while RCU is not watching.
- __sdei_handler() calls system_uses_hw_pan(), cpu_has_pan(),
arm64_kernel_unmapped_at_el0() and __kern_my_cpu_offset() before
irqentry_nmi_enter().
- The context tracking code, irqentry_nmi_enter() and
irqentry_nmi_exit() use __kern_my_cpu_offset() for per-CPU accesses
while RCU is not watching, and the noinstr sched_clock() read
functions raw_counter_get_cntpct_stable() and
raw_counter_get_cntvct_stable() use it too.
- The alternative callback kvm_patch_ich_vtr_el2() calls
is_hyp_mode_available().
- cpu_idle_poll() calls cpu_relax() between ct_cpuidle_enter() and
ct_cpuidle_exit(), while RCU is not watching. The other function it
calls there, tick_check_broadcast_expired(), is noinstr.
With clang, an arm64 defconfig build has out-of-line copies of all of
these helpers, called from the functions above. The copies are untraced
only because inline implies notrace.
Mark them notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/arm64/include/asm/cpufeature.h | 4 ++--
arch/arm64/include/asm/memory.h | 2 +-
arch/arm64/include/asm/mmu.h | 2 +-
arch/arm64/include/asm/percpu.h | 2 +-
arch/arm64/include/asm/ptrace.h | 2 +-
arch/arm64/include/asm/vdso/processor.h | 2 +-
arch/arm64/include/asm/virt.h | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 7d7b8eb7f72f..e1602d5de94f 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -774,7 +774,7 @@ static __always_inline bool system_supports_fpsimd(void)
return alternative_has_cap_likely(ARM64_HAS_FPSIMD);
}
-static inline bool system_uses_hw_pan(void)
+static inline bool notrace system_uses_hw_pan(void)
{
return alternative_has_cap_unlikely(ARM64_HAS_PAN);
}
@@ -955,7 +955,7 @@ static inline bool cpu_has_hw_af(void)
ID_AA64MMFR1_EL1_HAFDBS_SHIFT);
}
-static inline bool cpu_has_pan(void)
+static inline bool notrace cpu_has_pan(void)
{
u64 mmfr1 = read_cpuid(ID_AA64MMFR1_EL1);
return cpuid_feature_extract_unsigned_field(mmfr1,
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index a2b7a33966ff..e9a89fb32d50 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -223,7 +223,7 @@
#include <asm/sections.h>
#include <asm/sysreg.h>
-static inline u64 __pure read_tcr(void)
+static inline u64 __pure notrace read_tcr(void)
{
u64 tcr;
diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
index 5e1211c540ab..0889a37c4299 100644
--- a/arch/arm64/include/asm/mmu.h
+++ b/arch/arm64/include/asm/mmu.h
@@ -55,7 +55,7 @@ typedef struct {
*/
#define ASID(mm) (atomic64_read(&(mm)->context.id) & 0xffff)
-static inline bool arm64_kernel_unmapped_at_el0(void)
+static inline bool notrace arm64_kernel_unmapped_at_el0(void)
{
return alternative_has_cap_unlikely(ARM64_UNMAP_KERNEL_AT_EL0);
}
diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
index 3cc316091d66..0cb3a02b1f5f 100644
--- a/arch/arm64/include/asm/percpu.h
+++ b/arch/arm64/include/asm/percpu.h
@@ -37,7 +37,7 @@ static inline unsigned long __hyp_my_cpu_offset(void)
"mrs " dst ", tpidr_el2", \
ARM64_HAS_VIRT_HOST_EXTN)
-static inline unsigned long __kern_my_cpu_offset(void)
+static inline unsigned long notrace __kern_my_cpu_offset(void)
{
unsigned long off;
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index ad0ad30b36cd..5927ccfdf6b5 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -360,7 +360,7 @@ 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 inline unsigned long notrace instruction_pointer(struct pt_regs *regs)
{
return regs->pc;
}
diff --git a/arch/arm64/include/asm/vdso/processor.h b/arch/arm64/include/asm/vdso/processor.h
index 7abb0cc81cd6..4b246882d41c 100644
--- a/arch/arm64/include/asm/vdso/processor.h
+++ b/arch/arm64/include/asm/vdso/processor.h
@@ -7,7 +7,7 @@
#ifndef __ASSEMBLER__
-static inline void cpu_relax(void)
+static inline void notrace cpu_relax(void)
{
asm volatile("yield" ::: "memory");
}
diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
index a5bde8cc5df5..6b5e557b8ba2 100644
--- a/arch/arm64/include/asm/virt.h
+++ b/arch/arm64/include/asm/virt.h
@@ -104,7 +104,7 @@ static inline bool pkvm_force_reclaim_guest_page(phys_addr_t phys)
#endif
/* Reports the availability of HYP mode */
-static inline bool is_hyp_mode_available(void)
+static inline bool notrace is_hyp_mode_available(void)
{
/*
* If KVM protected mode is initialized, all CPUs must have been booted
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 18/22] arm64: Mark helpers called from noinstr code notrace
2026-12-01 4:21 ` [PATCH v3 18/22] arm64: Mark helpers called from noinstr code notrace Song Liu
@ 2026-12-01 4:53 ` sashiko-bot
0 siblings, 0 replies; 39+ messages in thread
From: sashiko-bot @ 2026-12-01 4:53 UTC (permalink / raw)
To: Song Liu, linux-trace-kernel, live-patching, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] arm64: noinstr helpers use static inline notrace instead of
__always_inline
- [Medium] arm64: missing notrace/__always_inline on
is_pkvm_initialized() and gic_read_pmr()
--
commit 58c12e9a90cffb79899ef34a6a22fce486bc0793
Author: Song Liu <song@kernel.org>
arm64: Mark helpers called from noinstr code notrace
This commit marks several arm64 inline helpers called from noinstr and
cpuidle paths as notrace so out-of-line copies emitted by Clang are not
traced by ftrace.
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 7d7b8eb7f72fb..e1602d5de94f2 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -774,7 +774,7 @@ static __always_inline bool system_supports_fpsimd(void)
> return alternative_has_cap_likely(ARM64_HAS_FPSIMD);
> }
>
> -static inline bool system_uses_hw_pan(void)
> +static inline bool notrace system_uses_hw_pan(void)
> {
> return alternative_has_cap_unlikely(ARM64_HAS_PAN);
> }
> @@ -955,7 +955,7 @@ static inline bool cpu_has_hw_af(void)
> ID_AA64MMFR1_EL1_HAFDBS_SHIFT);
> }
>
> -static inline bool cpu_has_pan(void)
> +static inline bool notrace cpu_has_pan(void)
> {
> u64 mmfr1 = read_cpuid(ID_AA64MMFR1_EL1);
> return cpuid_feature_extract_unsigned_field(mmfr1,
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index a2b7a33966ff1..e9a89fb32d505 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -223,7 +223,7 @@
> #include <asm/sections.h>
> #include <asm/sysreg.h>
>
> -static inline u64 __pure read_tcr(void)
> +static inline u64 __pure notrace read_tcr(void)
> {
> u64 tcr;
>
> diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
> index 5e1211c540ab2..0889a37c42997 100644
> --- a/arch/arm64/include/asm/mmu.h
> +++ b/arch/arm64/include/asm/mmu.h
> @@ -55,7 +55,7 @@ typedef struct {
> */
> #define ASID(mm) (atomic64_read(&(mm)->context.id) & 0xffff)
>
> -static inline bool arm64_kernel_unmapped_at_el0(void)
> +static inline bool notrace arm64_kernel_unmapped_at_el0(void)
> {
> return alternative_has_cap_unlikely(ARM64_UNMAP_KERNEL_AT_EL0);
> }
> diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
> index 3cc316091d665..0cb3a02b1f5f2 100644
> --- a/arch/arm64/include/asm/percpu.h
> +++ b/arch/arm64/include/asm/percpu.h
> @@ -37,7 +37,7 @@ static inline unsigned long __hyp_my_cpu_offset(void)
> "mrs " dst ", tpidr_el2", \
> ARM64_HAS_VIRT_HOST_EXTN)
>
> -static inline unsigned long __kern_my_cpu_offset(void)
> +static inline unsigned long notrace __kern_my_cpu_offset(void)
> {
> unsigned long off;
>
> diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> index ad0ad30b36cda..5927ccfdf6b54 100644
> --- a/arch/arm64/include/asm/ptrace.h
> +++ b/arch/arm64/include/asm/ptrace.h
> @@ -360,7 +360,7 @@ 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 inline unsigned long notrace instruction_pointer(struct pt_regs *regs)
> {
> return regs->pc;
> }
> diff --git a/arch/arm64/include/asm/vdso/processor.h b/arch/arm64/include/asm/vdso/processor.h
> index 7abb0cc81cd6e..4b246882d41cb 100644
> --- a/arch/arm64/include/asm/vdso/processor.h
> +++ b/arch/arm64/include/asm/vdso/processor.h
> @@ -7,7 +7,7 @@
>
> #ifndef __ASSEMBLER__
>
> -static inline void cpu_relax(void)
> +static inline void notrace cpu_relax(void)
> {
> asm volatile("yield" ::: "memory");
> }
> diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
> index a5bde8cc5df51..6b5e557b8ba2e 100644
> --- a/arch/arm64/include/asm/virt.h
> +++ b/arch/arm64/include/asm/virt.h
> @@ -104,7 +104,7 @@ static inline bool pkvm_force_reclaim_guest_page(phys_addr_t phys)
> #endif
>
> /* Reports the availability of HYP mode */
> -static inline bool is_hyp_mode_available(void)
> +static inline bool notrace is_hyp_mode_available(void)
> {
> /*
> * If KVM protected mode is initialized, all CPUs must have been booted
[Severity: Medium]
Should these eight helpers be marked static __always_inline instead of
static inline notrace?
Because noinstr and __cpuidle expand to include __no_profile, Clang
refuses to inline a plain inline callee that lacks __no_profile into a
noinstr or __cpuidle caller, emitting out-of-line copies in regular .text.
Even with notrace, those out-of-line copies sit outside .noinstr.text and
.cpuidle.text and lack __no_kcsan, __no_sanitize_address,
__no_sanitize_coverage and __no_sanitize_memory:
- They are not covered by the .noinstr.text kprobe blacklist, so placing a
kprobe on system_uses_hw_pan(), cpu_has_pan(),
arm64_kernel_unmapped_at_el0() or __kern_my_cpu_offset() called from
__sdei_handler() before exception registers are saved and before
vbar_el1 is switched off the KPTI trampoline vectors clobbers live
exception registers or traps into the unpopulated current-EL KPTI
vectors.
- In translation units that do not disable sanitizers or coverage in the
Makefile (such as kvm_patch_ich_vtr_el2() calling
is_hyp_mode_available(), or el0_pc() calling instruction_pointer()), the
out-of-line copies remain subject to KCOV, KASAN and KCSAN while RCU is
not watching.
- cpu_relax() called from __cpuidle cpu_idle_poll() executes in .text
outside __cpuidle_text_start..__cpuidle_text_end, causing cpu_in_idle()
to return false.
[Severity: Medium]
Should is_pkvm_initialized() and gic_read_pmr() also be marked
__always_inline (or notrace)?
is_hyp_mode_available() calls is_pkvm_initialized() unconditionally when
invoked from noinstr kvm_patch_ich_vtr_el2(), and __cpuidle cpu_do_idle()
calls gic_read_pmr() via arm_cpuidle_save_irq_context() while RCU is not
watching when CONFIG_ARM64_PSEUDO_NMI=y:
arch/arm64/include/asm/arch_gicv3.h:
static inline u32 gic_read_pmr(void)
{
return read_sysreg_s(SYS_ICC_PMR_EL1);
}
static __always_inline void gic_write_pmr(u32 val)
Once commit "compiler_types: Move notrace from inline to __always_inline"
removes notrace from plain inline, Clang emits an out-of-line traceable
copy of gic_read_pmr() from __cpuidle cpu_do_idle() (and of
is_pkvm_initialized() if is_hyp_mode_available() is inlined into
kvm_patch_ich_vtr_el2()), allowing ftrace to trace them while RCU is not
watching.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201042201.3199928-1-song@kernel.org?part=18
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 19/22] arm64: Mark the stack unwinder helpers notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (17 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 18/22] arm64: Mark helpers called from noinstr code notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:47 ` sashiko-bot
2026-12-01 4:21 ` [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace Song Liu
` (3 subsequent siblings)
22 siblings, 1 reply; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
Commit 0fbcd8abf337 ("arm64: Prohibit instrumentation on
arch_stack_walk()") made arch_stack_walk() noinstr, and made the inline
functions it calls __always_inline, so that it cannot be instrumented:
lockdep calls it through return_address(), and a kprobe on it crashed
the kernel. The helpers in <asm/stacktrace.h> and
<asm/stacktrace/common.h>, such as stackinfo_get_irq(), on_task_stack()
and unwind_consume_stack(), are still plain inline functions. With
clang, an arm64 defconfig build has out-of-line copies of several of
them, called from arch_stack_walk(), arch_stack_walk_reliable() and
arch_bpf_stack_walk(). The copies are untraced only because inline
implies notrace.
Mark these helpers notrace explicitly. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/arm64/include/asm/stacktrace.h | 16 ++++++++--------
arch/arm64/include/asm/stacktrace/common.h | 10 +++++-----
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h
index 6d3280932bf5..56d49234402d 100644
--- a/arch/arm64/include/asm/stacktrace.h
+++ b/arch/arm64/include/asm/stacktrace.h
@@ -22,7 +22,7 @@ extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
-static inline struct stack_info stackinfo_get_irq(void)
+static inline struct stack_info notrace stackinfo_get_irq(void)
{
unsigned long low = (unsigned long)raw_cpu_read(irq_stack_ptr);
unsigned long high = low + IRQ_STACK_SIZE;
@@ -33,13 +33,13 @@ static inline struct stack_info stackinfo_get_irq(void)
};
}
-static inline bool on_irq_stack(unsigned long sp, unsigned long size)
+static inline bool notrace on_irq_stack(unsigned long sp, unsigned long size)
{
struct stack_info info = stackinfo_get_irq();
return stackinfo_on_stack(&info, sp, size);
}
-static inline struct stack_info stackinfo_get_task(const struct task_struct *tsk)
+static inline struct stack_info notrace stackinfo_get_task(const struct task_struct *tsk)
{
unsigned long low = (unsigned long)task_stack_page(tsk);
unsigned long high = low + THREAD_SIZE;
@@ -50,7 +50,7 @@ static inline struct stack_info stackinfo_get_task(const struct task_struct *tsk
};
}
-static inline bool on_task_stack(const struct task_struct *tsk,
+static inline bool notrace on_task_stack(const struct task_struct *tsk,
unsigned long sp, unsigned long size)
{
struct stack_info info = stackinfo_get_task(tsk);
@@ -61,7 +61,7 @@ static inline bool on_task_stack(const struct task_struct *tsk,
DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack);
-static inline struct stack_info stackinfo_get_overflow(void)
+static inline struct stack_info notrace stackinfo_get_overflow(void)
{
unsigned long low = (unsigned long)raw_cpu_ptr(overflow_stack);
unsigned long high = low + OVERFLOW_STACK_SIZE;
@@ -76,7 +76,7 @@ static inline struct stack_info stackinfo_get_overflow(void)
DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
-static inline struct stack_info stackinfo_get_sdei_normal(void)
+static inline struct stack_info notrace stackinfo_get_sdei_normal(void)
{
unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
unsigned long high = low + SDEI_STACK_SIZE;
@@ -87,7 +87,7 @@ static inline struct stack_info stackinfo_get_sdei_normal(void)
};
}
-static inline struct stack_info stackinfo_get_sdei_critical(void)
+static inline struct stack_info notrace stackinfo_get_sdei_critical(void)
{
unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
unsigned long high = low + SDEI_STACK_SIZE;
@@ -105,7 +105,7 @@ static inline struct stack_info stackinfo_get_sdei_critical(void)
#ifdef CONFIG_EFI
extern u64 *efi_rt_stack_top;
-static inline struct stack_info stackinfo_get_efi(void)
+static inline struct stack_info notrace stackinfo_get_efi(void)
{
unsigned long high = (u64)efi_rt_stack_top;
unsigned long low = high - THREAD_SIZE;
diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
index 821a8fdd31af..d592e65db321 100644
--- a/arch/arm64/include/asm/stacktrace/common.h
+++ b/arch/arm64/include/asm/stacktrace/common.h
@@ -35,7 +35,7 @@ struct unwind_state {
int nr_stacks;
};
-static inline struct stack_info stackinfo_get_unknown(void)
+static inline struct stack_info notrace stackinfo_get_unknown(void)
{
return (struct stack_info) {
.low = 0,
@@ -43,7 +43,7 @@ static inline struct stack_info stackinfo_get_unknown(void)
};
}
-static inline bool stackinfo_on_stack(const struct stack_info *info,
+static inline bool notrace stackinfo_on_stack(const struct stack_info *info,
unsigned long sp, unsigned long size)
{
if (!info->low)
@@ -55,7 +55,7 @@ static inline bool stackinfo_on_stack(const struct stack_info *info,
return true;
}
-static inline void unwind_init_common(struct unwind_state *state)
+static inline void notrace unwind_init_common(struct unwind_state *state)
{
state->stack = stackinfo_get_unknown();
}
@@ -99,7 +99,7 @@ static struct stack_info *unwind_find_stack(struct unwind_state *state,
*
* Return: 0 upon success, an error code otherwise.
*/
-static inline void unwind_consume_stack(struct unwind_state *state,
+static inline void notrace unwind_consume_stack(struct unwind_state *state,
struct stack_info *info,
unsigned long sp,
unsigned long size)
@@ -142,7 +142,7 @@ static inline void unwind_consume_stack(struct unwind_state *state,
*
* Return: 0 upon success, an error code otherwise.
*/
-static inline int
+static inline int notrace
unwind_next_frame_record(struct unwind_state *state)
{
struct stack_info *info;
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 19/22] arm64: Mark the stack unwinder helpers notrace
2026-12-01 4:21 ` [PATCH v3 19/22] arm64: Mark the stack unwinder helpers notrace Song Liu
@ 2026-12-01 4:47 ` sashiko-bot
0 siblings, 0 replies; 39+ messages in thread
From: sashiko-bot @ 2026-12-01 4:47 UTC (permalink / raw)
To: Song Liu, linux-trace-kernel, live-patching, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] arm64: missing notrace or __always_inline on
unwind_find_stack()
--
commit b836a86f5820d0a3b22ab6c11f3d581e0f3097d0
Author: Song Liu <song@kernel.org>
arm64: Mark the stack unwinder helpers notrace
This commit marks the stack unwinder inline helpers in <asm/stacktrace.h>
and <asm/stacktrace/common.h> as notrace so that out-of-line copies cannot
be instrumented.
> diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
> index 821a8fdd31af4..d592e65db321c 100644
> --- a/arch/arm64/include/asm/stacktrace/common.h
> +++ b/arch/arm64/include/asm/stacktrace/common.h
[ ... ]
> @@ -99,7 +99,7 @@ static struct stack_info *unwind_find_stack(struct unwind_state *state,
> *
> * Return: 0 upon success, an error code otherwise.
> */
> -static inline void unwind_consume_stack(struct unwind_state *state,
> +static inline void notrace unwind_consume_stack(struct unwind_state *state,
> struct stack_info *info,
> unsigned long sp,
> unsigned long size)
> @@ -142,7 +142,7 @@ static inline void unwind_consume_stack(struct unwind_state *state,
> *
> * Return: 0 upon success, an error code otherwise.
> */
> -static inline int
> +static inline int notrace
> unwind_next_frame_record(struct unwind_state *state)
> {
> struct stack_info *info;
[Severity: Medium]
Should unwind_find_stack() in this header also be marked inline notrace?
It is defined as a plain static function without inline or notrace, and
is called on every frame by unwind_next_frame_record() and by the
__always_inline helpers in arch/arm64/kernel/stacktrace.c inside noinstr
arch_stack_walk(). An out-of-line copy of unwind_find_stack() remains
instrumented by ftrace and kprobeable, which can trigger recursive tracing
or a fatal kprobe recursion BUG() when lockdep unwinds via
return_address() -> arch_stack_walk().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201042201.3199928-1-song@kernel.org?part=19
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (18 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 19/22] arm64: Mark the stack unwinder helpers notrace Song Liu
@ 2026-12-01 4:21 ` Song Liu
2026-12-01 4:50 ` sashiko-bot
` (2 more replies)
2026-12-01 4:22 ` [PATCH v3 21/22] riscv: " Song Liu
` (2 subsequent siblings)
22 siblings, 3 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:21 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
Much of the powerpc code that must not be traced uses plain inline
helpers from headers: the atomic, bitops and barrier helpers, the
irqflags and hard irq helpers in <asm/hw_irq.h>, the interrupt entry
and exit helpers in <asm/entry-common.h>, and the MMIO accessors.
noinstr code calls them at points where tracing is not safe, for
example:
- The context tracking code updates its state with
arch_atomic_add_return_relaxed() while RCU is not watching.
- ct_idle_exit(), cpu_idle_poll(), snooze_loop() and the cede loops
call the irqflags and hard irq helpers, test_thread_local_flags()
and cede_processor() while RCU is not watching.
- DEFINE_INTERRUPT_HANDLER() and its variants call
arch_interrupt_enter_prepare() before irqentry_enter(). On entry
from user mode, irqentry_enter() calls arch_enter_from_user_mode(),
which uses regs_is_unrecoverable(), trap_is_syscall(), isync() and
irq_soft_mask_regs_set_state(), before user_exit_irqoff().
- get_pseries_errorlog(), which runs in real mode, calls the RTAS
error log helpers, and xive_teardown_cpu() calls out_8() on a CPU
that is going offline.
- soft_nmi_interrupt() calls wd_smp_lock().
With clang, a ppc64le_defconfig build has out-of-line copies of many of
these helpers, called from the functions above. The copies are
untraced only because inline implies notrace.
Mark them notrace explicitly, like the irq_soft_mask_*() helpers in
<asm/hw_irq.h> already are. On x86, arm64 and riscv, the atomic, bitops
and irqflags helpers are __always_inline. No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/powerpc/include/asm/atomic.h | 38 ++++++-------
arch/powerpc/include/asm/bitops.h | 29 +++++-----
arch/powerpc/include/asm/cmpxchg.h | 2 +-
arch/powerpc/include/asm/entry-common.h | 32 +++++------
arch/powerpc/include/asm/hw_irq.h | 68 +++++++++++------------
arch/powerpc/include/asm/interrupt.h | 2 +-
arch/powerpc/include/asm/io.h | 16 +++---
arch/powerpc/include/asm/plpar_wrappers.h | 4 +-
arch/powerpc/include/asm/ptrace.h | 14 ++---
arch/powerpc/include/asm/rtas.h | 10 ++--
arch/powerpc/include/asm/synch.h | 6 +-
arch/powerpc/include/asm/thread_info.h | 4 +-
arch/powerpc/kernel/watchdog.c | 4 +-
13 files changed, 115 insertions(+), 114 deletions(-)
diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
index d1ea554c33ed..60af4f955d99 100644
--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -24,7 +24,7 @@
#define __atomic_release_fence() \
__asm__ __volatile__(PPC_RELEASE_BARRIER "" : : : "memory")
-static __inline__ int arch_atomic_read(const atomic_t *v)
+static __inline__ notrace int arch_atomic_read(const atomic_t *v)
{
int t;
@@ -37,7 +37,7 @@ static __inline__ int arch_atomic_read(const atomic_t *v)
return t;
}
-static __inline__ void arch_atomic_set(atomic_t *v, int i)
+static __inline__ notrace void arch_atomic_set(atomic_t *v, int i)
{
/* -mprefixed can generate offsets beyond range, fall back hack */
if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
@@ -47,7 +47,7 @@ static __inline__ void arch_atomic_set(atomic_t *v, int i)
}
#define ATOMIC_OP(op, asm_op, suffix, sign, ...) \
-static __inline__ void arch_atomic_##op(int a, atomic_t *v) \
+static __inline__ notrace void arch_atomic_##op(int a, atomic_t *v) \
{ \
int t; \
\
@@ -62,7 +62,7 @@ static __inline__ void arch_atomic_##op(int a, atomic_t *v) \
} \
#define ATOMIC_OP_RETURN_RELAXED(op, asm_op, suffix, sign, ...) \
-static inline int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \
+static inline notrace int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \
{ \
int t; \
\
@@ -79,7 +79,7 @@ static inline int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \
}
#define ATOMIC_FETCH_OP_RELAXED(op, asm_op, suffix, sign, ...) \
-static inline int arch_atomic_fetch_##op##_relaxed(int a, atomic_t *v) \
+static inline notrace int arch_atomic_fetch_##op##_relaxed(int a, atomic_t *v) \
{ \
int res, t; \
\
@@ -136,7 +136,7 @@ ATOMIC_OPS(xor, xor, "", K)
* Atomically adds @a to @v, so long as it was not @u.
* Returns the old value of @v.
*/
-static __inline__ int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
+static __inline__ notrace int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
{
int t;
@@ -164,7 +164,7 @@ static __inline__ int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
* The function returns the old value of *v minus 1, even if
* the atomic variable, v, was not decremented.
*/
-static __inline__ int arch_atomic_dec_if_positive(atomic_t *v)
+static __inline__ notrace int arch_atomic_dec_if_positive(atomic_t *v)
{
int t;
@@ -190,7 +190,7 @@ static __inline__ int arch_atomic_dec_if_positive(atomic_t *v)
#define ATOMIC64_INIT(i) { (i) }
-static __inline__ s64 arch_atomic64_read(const atomic64_t *v)
+static __inline__ notrace s64 arch_atomic64_read(const atomic64_t *v)
{
s64 t;
@@ -203,7 +203,7 @@ static __inline__ s64 arch_atomic64_read(const atomic64_t *v)
return t;
}
-static __inline__ void arch_atomic64_set(atomic64_t *v, s64 i)
+static __inline__ notrace void arch_atomic64_set(atomic64_t *v, s64 i)
{
/* -mprefixed can generate offsets beyond range, fall back hack */
if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
@@ -213,7 +213,7 @@ static __inline__ void arch_atomic64_set(atomic64_t *v, s64 i)
}
#define ATOMIC64_OP(op, asm_op) \
-static __inline__ void arch_atomic64_##op(s64 a, atomic64_t *v) \
+static __inline__ notrace void arch_atomic64_##op(s64 a, atomic64_t *v) \
{ \
s64 t; \
\
@@ -228,7 +228,7 @@ static __inline__ void arch_atomic64_##op(s64 a, atomic64_t *v) \
}
#define ATOMIC64_OP_RETURN_RELAXED(op, asm_op) \
-static inline s64 \
+static inline notrace s64 \
arch_atomic64_##op##_return_relaxed(s64 a, atomic64_t *v) \
{ \
s64 t; \
@@ -246,7 +246,7 @@ arch_atomic64_##op##_return_relaxed(s64 a, atomic64_t *v) \
}
#define ATOMIC64_FETCH_OP_RELAXED(op, asm_op) \
-static inline s64 \
+static inline notrace s64 \
arch_atomic64_fetch_##op##_relaxed(s64 a, atomic64_t *v) \
{ \
s64 res, t; \
@@ -295,7 +295,7 @@ ATOMIC64_OPS(xor, xor)
#undef ATOMIC64_OP_RETURN_RELAXED
#undef ATOMIC64_OP
-static __inline__ void arch_atomic64_inc(atomic64_t *v)
+static __inline__ notrace void arch_atomic64_inc(atomic64_t *v)
{
s64 t;
@@ -310,7 +310,7 @@ static __inline__ void arch_atomic64_inc(atomic64_t *v)
}
#define arch_atomic64_inc arch_atomic64_inc
-static __inline__ s64 arch_atomic64_inc_return_relaxed(atomic64_t *v)
+static __inline__ notrace s64 arch_atomic64_inc_return_relaxed(atomic64_t *v)
{
s64 t;
@@ -326,7 +326,7 @@ static __inline__ s64 arch_atomic64_inc_return_relaxed(atomic64_t *v)
return t;
}
-static __inline__ void arch_atomic64_dec(atomic64_t *v)
+static __inline__ notrace void arch_atomic64_dec(atomic64_t *v)
{
s64 t;
@@ -341,7 +341,7 @@ static __inline__ void arch_atomic64_dec(atomic64_t *v)
}
#define arch_atomic64_dec arch_atomic64_dec
-static __inline__ s64 arch_atomic64_dec_return_relaxed(atomic64_t *v)
+static __inline__ notrace s64 arch_atomic64_dec_return_relaxed(atomic64_t *v)
{
s64 t;
@@ -364,7 +364,7 @@ static __inline__ s64 arch_atomic64_dec_return_relaxed(atomic64_t *v)
* Atomically test *v and decrement if it is greater than 0.
* The function returns the old value of *v minus 1.
*/
-static __inline__ s64 arch_atomic64_dec_if_positive(atomic64_t *v)
+static __inline__ notrace s64 arch_atomic64_dec_if_positive(atomic64_t *v)
{
s64 t;
@@ -394,7 +394,7 @@ static __inline__ s64 arch_atomic64_dec_if_positive(atomic64_t *v)
* Atomically adds @a to @v, so long as it was not @u.
* Returns the old value of @v.
*/
-static __inline__ s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u)
+static __inline__ notrace s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u)
{
s64 t;
@@ -424,7 +424,7 @@ static __inline__ s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u
* Atomically increments @v by 1, so long as @v is non-zero.
* Returns non-zero if @v was non-zero, and zero otherwise.
*/
-static __inline__ int arch_atomic64_inc_not_zero(atomic64_t *v)
+static __inline__ notrace int arch_atomic64_inc_not_zero(atomic64_t *v)
{
s64 t1, t2;
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 0d0470cd5ac3..f2123a148dbb 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -63,7 +63,7 @@
/* Macro for generating the ***_bits() functions */
#define DEFINE_BITOP(fn, op, prefix) \
-static inline void fn(unsigned long mask, \
+static inline notrace void fn(unsigned long mask, \
volatile unsigned long *_p) \
{ \
unsigned long old; \
@@ -94,7 +94,7 @@ static __always_inline bool is_rlwinm_mask_valid(unsigned long x)
}
#define DEFINE_CLROP(fn, prefix) \
-static inline void fn(unsigned long mask, volatile unsigned long *_p) \
+static inline notrace void fn(unsigned long mask, volatile unsigned long *_p) \
{ \
unsigned long old; \
unsigned long *p = (unsigned long *)_p; \
@@ -126,22 +126,22 @@ static inline void fn(unsigned long mask, volatile unsigned long *_p) \
DEFINE_CLROP(clear_bits, "")
DEFINE_CLROP(clear_bits_unlock, PPC_RELEASE_BARRIER)
-static inline void arch_set_bit(int nr, volatile unsigned long *addr)
+static inline notrace void arch_set_bit(int nr, volatile unsigned long *addr)
{
set_bits(BIT_MASK(nr), addr + BIT_WORD(nr));
}
-static inline void arch_clear_bit(int nr, volatile unsigned long *addr)
+static inline notrace void arch_clear_bit(int nr, volatile unsigned long *addr)
{
clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr));
}
-static inline void arch_clear_bit_unlock(int nr, volatile unsigned long *addr)
+static inline notrace void arch_clear_bit_unlock(int nr, volatile unsigned long *addr)
{
clear_bits_unlock(BIT_MASK(nr), addr + BIT_WORD(nr));
}
-static inline void arch_change_bit(int nr, volatile unsigned long *addr)
+static inline notrace void arch_change_bit(int nr, volatile unsigned long *addr)
{
change_bits(BIT_MASK(nr), addr + BIT_WORD(nr));
}
@@ -149,7 +149,7 @@ static inline void arch_change_bit(int nr, volatile unsigned long *addr)
/* Like DEFINE_BITOP(), with changes to the arguments to 'op' and the output
* operands. */
#define DEFINE_TESTOP(fn, op, prefix, postfix, eh) \
-static inline unsigned long fn( \
+static inline notrace unsigned long fn( \
unsigned long mask, \
volatile unsigned long *_p) \
{ \
@@ -175,7 +175,8 @@ DEFINE_TESTOP(test_and_set_bits_lock, or, "",
DEFINE_TESTOP(test_and_change_bits, xor, PPC_ATOMIC_ENTRY_BARRIER,
PPC_ATOMIC_EXIT_BARRIER, 0)
-static inline unsigned long test_and_clear_bits(unsigned long mask, volatile unsigned long *_p)
+static inline notrace unsigned long
+test_and_clear_bits(unsigned long mask, volatile unsigned long *_p)
{
unsigned long old, t;
unsigned long *p = (unsigned long *)_p;
@@ -208,32 +209,32 @@ static inline unsigned long test_and_clear_bits(unsigned long mask, volatile uns
return (old & mask);
}
-static inline int arch_test_and_set_bit(unsigned long nr,
+static inline notrace int arch_test_and_set_bit(unsigned long nr,
volatile unsigned long *addr)
{
return test_and_set_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0;
}
-static inline int arch_test_and_set_bit_lock(unsigned long nr,
+static inline notrace int arch_test_and_set_bit_lock(unsigned long nr,
volatile unsigned long *addr)
{
return test_and_set_bits_lock(BIT_MASK(nr),
addr + BIT_WORD(nr)) != 0;
}
-static inline int arch_test_and_clear_bit(unsigned long nr,
+static inline notrace int arch_test_and_clear_bit(unsigned long nr,
volatile unsigned long *addr)
{
return test_and_clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0;
}
-static inline int arch_test_and_change_bit(unsigned long nr,
+static inline notrace int arch_test_and_change_bit(unsigned long nr,
volatile unsigned long *addr)
{
return test_and_change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0;
}
-static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask,
+static inline notrace bool arch_xor_unlock_is_negative_byte(unsigned long mask,
volatile unsigned long *p)
{
unsigned long old, t;
@@ -254,7 +255,7 @@ static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask,
#include <asm-generic/bitops/non-atomic.h>
-static inline void arch___clear_bit_unlock(int nr, volatile unsigned long *addr)
+static inline notrace void arch___clear_bit_unlock(int nr, volatile unsigned long *addr)
{
__asm__ __volatile__(PPC_RELEASE_BARRIER "" ::: "memory");
__clear_bit(nr, addr);
diff --git a/arch/powerpc/include/asm/cmpxchg.h b/arch/powerpc/include/asm/cmpxchg.h
index dbb50c06f0bf..fe298147f024 100644
--- a/arch/powerpc/include/asm/cmpxchg.h
+++ b/arch/powerpc/include/asm/cmpxchg.h
@@ -14,7 +14,7 @@
#endif
#define XCHG_GEN(type, sfx, cl) \
-static inline u32 __xchg_##type##sfx(volatile void *p, u32 val) \
+static inline notrace u32 __xchg_##type##sfx(volatile void *p, u32 val) \
{ \
unsigned int prev, prev_mask, tmp, bitoff, off; \
\
diff --git a/arch/powerpc/include/asm/entry-common.h b/arch/powerpc/include/asm/entry-common.h
index 8e91489fdf2b..c487636dba78 100644
--- a/arch/powerpc/include/asm/entry-common.h
+++ b/arch/powerpc/include/asm/entry-common.h
@@ -31,7 +31,7 @@ unsigned long search_kernel_restart_table(unsigned long addr);
DECLARE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
-static inline bool is_implicit_soft_masked(struct pt_regs *regs)
+static inline notrace bool is_implicit_soft_masked(struct pt_regs *regs)
{
if (user_mode(regs))
return false;
@@ -42,28 +42,28 @@ static inline bool is_implicit_soft_masked(struct pt_regs *regs)
return search_kernel_soft_mask_table(regs->nip);
}
-static inline void srr_regs_clobbered(void)
+static inline notrace void srr_regs_clobbered(void)
{
local_paca->srr_valid = 0;
local_paca->hsrr_valid = 0;
}
#else
-static inline unsigned long search_kernel_restart_table(unsigned long addr)
+static inline notrace unsigned long search_kernel_restart_table(unsigned long addr)
{
return 0;
}
-static inline bool is_implicit_soft_masked(struct pt_regs *regs)
+static inline notrace bool is_implicit_soft_masked(struct pt_regs *regs)
{
return false;
}
-static inline void srr_regs_clobbered(void)
+static inline notrace void srr_regs_clobbered(void)
{
}
#endif
-static inline void nap_adjust_return(struct pt_regs *regs)
+static inline notrace void nap_adjust_return(struct pt_regs *regs)
{
#ifdef CONFIG_PPC_970_NAP
/*
@@ -103,7 +103,7 @@ static __always_inline void booke_load_dbcr0(void)
#endif
}
-static inline void booke_restore_dbcr0(void)
+static inline notrace void booke_restore_dbcr0(void)
{
#ifdef CONFIG_PPC_ADV_DEBUG_REGS
unsigned long dbcr0 = current->thread.debug.dbcr0;
@@ -115,7 +115,7 @@ static inline void booke_restore_dbcr0(void)
#endif
}
-static inline void check_return_regs_valid(struct pt_regs *regs)
+static inline notrace void check_return_regs_valid(struct pt_regs *regs)
{
#ifdef CONFIG_PPC_BOOK3S_64
unsigned long trap, srr0, srr1;
@@ -195,7 +195,7 @@ static inline void check_return_regs_valid(struct pt_regs *regs)
#endif
}
-static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
+static inline notrace void arch_interrupt_enter_prepare(struct pt_regs *regs)
{
#ifdef CONFIG_PPC64
irq_soft_mask_set(IRQS_ALL_DISABLED);
@@ -255,7 +255,7 @@ static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
* However arch_interrupt_nmi_exit_prepare does return directly to regs, because
* NMIs do not do "exit work" or replay soft-masked interrupts.
*/
-static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)
+static inline notrace void arch_interrupt_exit_prepare(struct pt_regs *regs)
{
if (user_mode(regs)) {
BUG_ON(regs_is_unrecoverable(regs));
@@ -271,7 +271,7 @@ static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)
hard_irq_disable();
}
-static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
+static inline notrace void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
{
#ifdef CONFIG_PPC64
/* Ensure arch_interrupt_enter_prepare does not enable MSR[EE] */
@@ -289,7 +289,7 @@ static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
#endif
}
-static inline void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
+static inline notrace void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
{
arch_interrupt_exit_prepare(regs);
}
@@ -303,7 +303,7 @@ struct interrupt_nmi_state {
#endif
};
-static inline bool nmi_disables_ftrace(struct pt_regs *regs)
+static inline notrace bool nmi_disables_ftrace(struct pt_regs *regs)
{
/* Allow DEC and PMI to be traced when they are soft-NMI */
if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) {
@@ -320,7 +320,7 @@ static inline bool nmi_disables_ftrace(struct pt_regs *regs)
return true;
}
-static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
+static inline notrace void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
struct interrupt_nmi_state *state)
{
#ifdef CONFIG_PPC64
@@ -358,7 +358,7 @@ static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
#endif
}
-static inline void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
+static inline notrace void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
struct interrupt_nmi_state *state)
{
/*
@@ -480,7 +480,7 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
#define arch_enter_from_user_mode arch_enter_from_user_mode
-static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
+static inline notrace void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
unsigned long ti_work)
{
unsigned long mathflags;
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index ddb850e62abd..3d076f5de73e 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -61,7 +61,7 @@
#ifndef __ASSEMBLER__
-static inline void __hard_irq_enable(void)
+static inline notrace void __hard_irq_enable(void)
{
if (IS_ENABLED(CONFIG_BOOKE))
wrtee(MSR_EE);
@@ -73,7 +73,7 @@ static inline void __hard_irq_enable(void)
mtmsr(mfmsr() | MSR_EE);
}
-static inline void __hard_irq_disable(void)
+static inline notrace void __hard_irq_disable(void)
{
if (IS_ENABLED(CONFIG_BOOKE))
wrtee(0);
@@ -85,7 +85,7 @@ static inline void __hard_irq_disable(void)
mtmsr(mfmsr() & ~MSR_EE);
}
-static inline void __hard_EE_RI_disable(void)
+static inline notrace void __hard_EE_RI_disable(void)
{
if (IS_ENABLED(CONFIG_BOOKE))
wrtee(0);
@@ -97,7 +97,7 @@ static inline void __hard_EE_RI_disable(void)
mtmsr(mfmsr() & ~(MSR_EE | MSR_RI));
}
-static inline void __hard_RI_enable(void)
+static inline notrace void __hard_RI_enable(void)
{
if (IS_ENABLED(CONFIG_BOOKE))
return;
@@ -184,39 +184,39 @@ static inline notrace unsigned long irq_soft_mask_andc_return(unsigned long mask
return flags;
}
-static inline unsigned long arch_local_save_flags(void)
+static inline notrace unsigned long arch_local_save_flags(void)
{
return irq_soft_mask_return();
}
-static inline void arch_local_irq_disable(void)
+static inline notrace void arch_local_irq_disable(void)
{
irq_soft_mask_set(IRQS_DISABLED);
}
extern void arch_local_irq_restore(unsigned long);
-static inline void arch_local_irq_enable(void)
+static inline notrace void arch_local_irq_enable(void)
{
arch_local_irq_restore(IRQS_ENABLED);
}
-static inline unsigned long arch_local_irq_save(void)
+static inline notrace unsigned long arch_local_irq_save(void)
{
return irq_soft_mask_or_return(IRQS_DISABLED);
}
-static inline bool arch_irqs_disabled_flags(unsigned long flags)
+static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
{
return flags & IRQS_DISABLED;
}
-static inline bool arch_irqs_disabled(void)
+static inline notrace bool arch_irqs_disabled(void)
{
return arch_irqs_disabled_flags(arch_local_save_flags());
}
-static inline void set_pmi_irq_pending(void)
+static inline notrace void set_pmi_irq_pending(void)
{
/*
* Invoked from PMU callback functions to set PMI bit in the paca.
@@ -228,7 +228,7 @@ static inline void set_pmi_irq_pending(void)
get_paca()->irq_happened |= PACA_IRQ_PMI;
}
-static inline void clear_pmi_irq_pending(void)
+static inline notrace void clear_pmi_irq_pending(void)
{
/*
* Invoked from PMU callback functions to clear the pending PMI bit
@@ -240,7 +240,7 @@ static inline void clear_pmi_irq_pending(void)
get_paca()->irq_happened &= ~PACA_IRQ_PMI;
}
-static inline bool pmi_irq_pending(void)
+static inline notrace bool pmi_irq_pending(void)
{
/*
* Invoked from PMU callback functions to check if there is a pending
@@ -310,7 +310,7 @@ static inline bool pmi_irq_pending(void)
} \
} while(0)
-static inline bool __lazy_irq_pending(u8 irq_happened)
+static inline notrace bool __lazy_irq_pending(u8 irq_happened)
{
return !!(irq_happened & ~PACA_IRQ_HARD_DIS);
}
@@ -318,7 +318,7 @@ static inline bool __lazy_irq_pending(u8 irq_happened)
/*
* Check if a lazy IRQ is pending. Should be called with IRQs hard disabled.
*/
-static inline bool lazy_irq_pending(void)
+static inline notrace bool lazy_irq_pending(void)
{
return __lazy_irq_pending(get_paca()->irq_happened);
}
@@ -328,7 +328,7 @@ static inline bool lazy_irq_pending(void)
* Should be called with IRQs hard disabled.
* For use in RI disabled code or other constrained situations.
*/
-static inline bool lazy_irq_pending_nocheck(void)
+static inline notrace bool lazy_irq_pending_nocheck(void)
{
return __lazy_irq_pending(local_paca->irq_happened);
}
@@ -342,7 +342,7 @@ bool power_pmu_wants_prompt_pmi(void);
* is a different soft-masked interrupt pending that requires hard
* masking.
*/
-static inline bool should_hard_irq_enable(struct pt_regs *regs)
+static inline notrace bool should_hard_irq_enable(struct pt_regs *regs)
{
if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG)) {
WARN_ON(irq_soft_mask_return() != IRQS_ALL_DISABLED);
@@ -381,7 +381,7 @@ static inline bool should_hard_irq_enable(struct pt_regs *regs)
* Do the hard enabling, only call this if should_hard_irq_enable is true.
* This allows PMI interrupts to profile irq handlers.
*/
-static inline void do_hard_irq_enable(void)
+static inline notrace void do_hard_irq_enable(void)
{
/*
* Asynch interrupts come in with IRQS_ALL_DISABLED,
@@ -393,7 +393,7 @@ static inline void do_hard_irq_enable(void)
__hard_irq_enable();
}
-static inline bool regs_irqs_disabled(struct pt_regs *regs)
+static inline notrace bool regs_irqs_disabled(struct pt_regs *regs)
{
return (regs->softe & IRQS_DISABLED);
}
@@ -406,7 +406,7 @@ extern void irq_set_pending_from_srr1(unsigned long srr1);
extern void force_external_irq_replay(void);
-static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
+static inline notrace void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
{
regs->softe = val;
}
@@ -417,12 +417,12 @@ static inline notrace unsigned long irq_soft_mask_return(void)
return 0;
}
-static inline unsigned long arch_local_save_flags(void)
+static inline notrace unsigned long arch_local_save_flags(void)
{
return mfmsr();
}
-static inline void arch_local_irq_restore(unsigned long flags)
+static inline notrace void arch_local_irq_restore(unsigned long flags)
{
if (IS_ENABLED(CONFIG_BOOKE))
wrtee(flags);
@@ -430,7 +430,7 @@ static inline void arch_local_irq_restore(unsigned long flags)
mtmsr(flags);
}
-static inline unsigned long arch_local_irq_save(void)
+static inline notrace unsigned long arch_local_irq_save(void)
{
unsigned long flags = arch_local_save_flags();
@@ -444,29 +444,29 @@ static inline unsigned long arch_local_irq_save(void)
return flags;
}
-static inline void arch_local_irq_disable(void)
+static inline notrace void arch_local_irq_disable(void)
{
__hard_irq_disable();
}
-static inline void arch_local_irq_enable(void)
+static inline notrace void arch_local_irq_enable(void)
{
__hard_irq_enable();
}
-static inline bool arch_irqs_disabled_flags(unsigned long flags)
+static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
{
return (flags & MSR_EE) == 0;
}
-static inline bool arch_irqs_disabled(void)
+static inline notrace bool arch_irqs_disabled(void)
{
return arch_irqs_disabled_flags(arch_local_save_flags());
}
#define hard_irq_disable() local_irq_disable()
-static inline bool regs_irqs_disabled(struct pt_regs *regs)
+static inline notrace bool regs_irqs_disabled(struct pt_regs *regs)
{
return !(regs->msr & MSR_EE);
}
@@ -476,21 +476,21 @@ static __always_inline bool should_hard_irq_enable(struct pt_regs *regs)
return false;
}
-static inline void do_hard_irq_enable(void)
+static inline notrace void do_hard_irq_enable(void)
{
BUILD_BUG();
}
-static inline void clear_pmi_irq_pending(void) { }
-static inline void set_pmi_irq_pending(void) { }
-static inline bool pmi_irq_pending(void) { return false; }
+static inline notrace void clear_pmi_irq_pending(void) { }
+static inline notrace void set_pmi_irq_pending(void) { }
+static inline notrace bool pmi_irq_pending(void) { return false; }
-static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
+static inline notrace void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
{
}
#endif /* CONFIG_PPC64 */
-static inline unsigned long mtmsr_isync_irqsafe(unsigned long msr)
+static inline notrace unsigned long mtmsr_isync_irqsafe(unsigned long msr)
{
#ifdef CONFIG_PPC64
if (arch_irqs_disabled()) {
diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h
index c7d0e71eac83..f358ea26e57b 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -397,7 +397,7 @@ void __noreturn unrecoverable_exception(struct pt_regs *regs);
void replay_system_reset(void);
void replay_soft_interrupts(void);
-static inline void interrupt_cond_local_irq_enable(struct pt_regs *regs)
+static inline notrace void interrupt_cond_local_irq_enable(struct pt_regs *regs)
{
if (!regs_irqs_disabled(regs))
local_irq_enable();
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 7a89754842d6..3295964f7bce 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -91,7 +91,7 @@ extern bool isa_io_special;
/* -mprefixed can generate offsets beyond range, fall back hack */
#ifdef CONFIG_PPC_KERNEL_PREFIXED
#define DEF_MMIO_IN_X(name, size, insn) \
-static inline u##size name(const volatile u##size __iomem *addr) \
+static inline notrace u##size name(const volatile u##size __iomem *addr) \
{ \
u##size ret; \
__asm__ __volatile__("sync;"#insn" %0,0,%1;twi 0,%0,0;isync" \
@@ -100,7 +100,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
}
#define DEF_MMIO_OUT_X(name, size, insn) \
-static inline void name(volatile u##size __iomem *addr, u##size val) \
+static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn" %1,0,%0" \
: : "r" (addr), "r" (val) : "memory"); \
@@ -108,7 +108,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
}
#define DEF_MMIO_IN_D(name, size, insn) \
-static inline u##size name(const volatile u##size __iomem *addr) \
+static inline notrace u##size name(const volatile u##size __iomem *addr) \
{ \
u##size ret; \
__asm__ __volatile__("sync;"#insn" %0,0(%1);twi 0,%0,0;isync"\
@@ -117,7 +117,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
}
#define DEF_MMIO_OUT_D(name, size, insn) \
-static inline void name(volatile u##size __iomem *addr, u##size val) \
+static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn" %1,0(%0)" \
: : "b" (addr), "r" (val) : "memory"); \
@@ -125,7 +125,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
}
#else
#define DEF_MMIO_IN_X(name, size, insn) \
-static inline u##size name(const volatile u##size __iomem *addr) \
+static inline notrace u##size name(const volatile u##size __iomem *addr) \
{ \
u##size ret; \
__asm__ __volatile__("sync;"#insn" %0,%y1;twi 0,%0,0;isync" \
@@ -134,7 +134,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
}
#define DEF_MMIO_OUT_X(name, size, insn) \
-static inline void name(volatile u##size __iomem *addr, u##size val) \
+static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn" %1,%y0" \
: "=Z" (*addr) : "r" (val) : "memory"); \
@@ -142,7 +142,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
}
#define DEF_MMIO_IN_D(name, size, insn) \
-static inline u##size name(const volatile u##size __iomem *addr) \
+static inline notrace u##size name(const volatile u##size __iomem *addr) \
{ \
u##size ret; \
__asm__ __volatile__("sync;"#insn"%U1%X1 %0,%1;twi 0,%0,0;isync"\
@@ -151,7 +151,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
}
#define DEF_MMIO_OUT_D(name, size, insn) \
-static inline void name(volatile u##size __iomem *addr, u##size val) \
+static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \
: "=m<>" (*addr) : "r" (val) : "memory"); \
diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
index f2b6cc4341bb..dd45f632272d 100644
--- a/arch/powerpc/include/asm/plpar_wrappers.h
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -13,12 +13,12 @@
#include <asm/lppaca.h>
#include <asm/page.h>
-static inline long poll_pending(void)
+static inline notrace long poll_pending(void)
{
return plpar_hcall_norets(H_POLL_PENDING);
}
-static inline long cede_processor(void)
+static inline notrace long cede_processor(void)
{
/*
* We cannot call tracepoints inside RCU idle regions which
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index d53c4dd4d8b6..7e8f89d4b8f4 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -255,17 +255,17 @@ static __always_inline void set_trap(struct pt_regs *regs, unsigned long val)
regs->trap = (regs->trap & TRAP_FLAGS_MASK) | (val & ~TRAP_FLAGS_MASK);
}
-static inline bool trap_is_scv(struct pt_regs *regs)
+static inline notrace bool trap_is_scv(struct pt_regs *regs)
{
return (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) == 0x3000);
}
-static inline bool trap_is_unsupported_scv(struct pt_regs *regs)
+static inline notrace bool trap_is_unsupported_scv(struct pt_regs *regs)
{
return IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) == 0x7ff0;
}
-static inline bool trap_is_syscall(struct pt_regs *regs)
+static inline notrace bool trap_is_syscall(struct pt_regs *regs)
{
return (trap_is_scv(regs) || TRAP(regs) == 0xc00);
}
@@ -305,23 +305,23 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
regs->gpr[3] = rc;
}
-static inline bool cpu_has_msr_ri(void)
+static inline notrace bool cpu_has_msr_ri(void)
{
return !IS_ENABLED(CONFIG_BOOKE);
}
-static inline bool regs_is_unrecoverable(struct pt_regs *regs)
+static inline notrace bool regs_is_unrecoverable(struct pt_regs *regs)
{
return unlikely(cpu_has_msr_ri() && !(regs->msr & MSR_RI));
}
-static inline void regs_set_recoverable(struct pt_regs *regs)
+static inline notrace void regs_set_recoverable(struct pt_regs *regs)
{
if (cpu_has_msr_ri())
regs_set_return_msr(regs, regs->msr | MSR_RI);
}
-static inline void regs_set_unrecoverable(struct pt_regs *regs)
+static inline notrace void regs_set_unrecoverable(struct pt_regs *regs)
{
if (cpu_has_msr_ri())
regs_set_return_msr(regs, regs->msr & ~MSR_RI);
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index d046bbd5017d..7c3431c272e0 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -343,7 +343,7 @@ static inline uint8_t rtas_error_initiator(const struct rtas_error_log *elog)
#define rtas_error_type(x) ((x)->byte3)
-static inline
+static inline notrace
uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog)
{
return be32_to_cpu(elog->extended_log_length);
@@ -354,13 +354,13 @@ uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog)
#define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8))
static
-inline uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log)
+inline notrace uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log)
{
return ext_log->byte2 & 0x0F;
}
static
-inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
+inline notrace uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
{
return be32_to_cpu(ext_log->company_id);
}
@@ -389,13 +389,13 @@ inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
#define PSERIES_ELOG_SECT_ID_MCE (('M' << 8) | 'C')
static
-inline uint16_t pseries_errorlog_id(struct pseries_errorlog *sect)
+inline notrace uint16_t pseries_errorlog_id(struct pseries_errorlog *sect)
{
return be16_to_cpu(sect->id);
}
static
-inline uint16_t pseries_errorlog_length(struct pseries_errorlog *sect)
+inline notrace uint16_t pseries_errorlog_length(struct pseries_errorlog *sect)
{
return be16_to_cpu(sect->length);
}
diff --git a/arch/powerpc/include/asm/synch.h b/arch/powerpc/include/asm/synch.h
index d0e9765dee28..178fe45c8927 100644
--- a/arch/powerpc/include/asm/synch.h
+++ b/arch/powerpc/include/asm/synch.h
@@ -12,7 +12,7 @@ extern unsigned int __start___lwsync_fixup, __stop___lwsync_fixup;
extern void do_lwsync_fixups(unsigned long value, void *fixup_start,
void *fixup_end);
-static inline void eieio(void)
+static inline notrace void eieio(void)
{
if (IS_ENABLED(CONFIG_BOOKE))
__asm__ __volatile__ ("mbar" : : : "memory");
@@ -20,12 +20,12 @@ static inline void eieio(void)
__asm__ __volatile__ ("eieio" : : : "memory");
}
-static inline void isync(void)
+static inline notrace void isync(void)
{
__asm__ __volatile__ ("isync" : : : "memory");
}
-static inline void ppc_after_tlbiel_barrier(void)
+static inline notrace void ppc_after_tlbiel_barrier(void)
{
asm volatile("ptesync": : :"memory");
/*
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 1e069a2e7ce8..04147dd91dfd 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -165,13 +165,13 @@ void arch_setup_new_exec(void);
#ifndef __ASSEMBLER__
-static inline void clear_thread_local_flags(unsigned int flags)
+static inline notrace void clear_thread_local_flags(unsigned int flags)
{
struct thread_info *ti = current_thread_info();
ti->local_flags &= ~flags;
}
-static inline bool test_thread_local_flags(unsigned int flags)
+static inline notrace bool test_thread_local_flags(unsigned int flags)
{
struct thread_info *ti = current_thread_info();
return (ti->local_flags & flags) != 0;
diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index 44f178e07531..00f4712290b5 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -121,7 +121,7 @@ static void wd_end_reporting(void)
WRITE_ONCE(__wd_reporting, 0);
}
-static inline void wd_smp_lock(unsigned long *flags)
+static inline notrace void wd_smp_lock(unsigned long *flags)
{
/*
* Avoid locking layers if possible.
@@ -138,7 +138,7 @@ static inline void wd_smp_lock(unsigned long *flags)
}
}
-static inline void wd_smp_unlock(unsigned long *flags)
+static inline notrace void wd_smp_unlock(unsigned long *flags)
{
clear_bit_unlock(0, &__wd_smp_lock);
raw_local_irq_restore(*flags);
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace
2026-12-01 4:21 ` [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace Song Liu
@ 2026-12-01 4:50 ` sashiko-bot
2026-12-01 5:08 ` bot+bpf-ci
2026-12-01 6:02 ` Christophe Leroy (CS GROUP)
2 siblings, 0 replies; 39+ messages in thread
From: sashiko-bot @ 2026-12-01 4:50 UTC (permalink / raw)
To: Song Liu, linux-trace-kernel, live-patching, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] powerpc: missing notrace on 64-bit byte-swapped MMIO helpers
in asm/io.h
- [Medium] powerpc: missing notrace on return register helpers in
asm/ptrace.h
- [Medium] powerpc: missing notrace on ftrace enable helpers in
asm/ftrace.h
- [Low] powerpc: missing notrace on CMPXCHG_GEN() in asm/cmpxchg.h
--
commit 8cbdd62036fd779308aae93f2caa0e8f191ee974
Author: Song Liu <song@kernel.org>
powerpc: Mark helpers called from noinstr code notrace
This commit adds explicit notrace annotations to inline helpers across
PowerPC headers and watchdog code that are called from noinstr and
untraced contexts.
> diff --git a/arch/powerpc/include/asm/cmpxchg.h b/arch/powerpc/include/asm/cmpxchg.h
> index dbb50c06f0bf4..fe298147f024b 100644
> --- a/arch/powerpc/include/asm/cmpxchg.h
> +++ b/arch/powerpc/include/asm/cmpxchg.h
> @@ -14,7 +14,7 @@
> #endif
>
> #define XCHG_GEN(type, sfx, cl) \
> -static inline u32 __xchg_##type##sfx(volatile void *p, u32 val) \
> +static inline notrace u32 __xchg_##type##sfx(volatile void *p, u32 val) \
> { \
> unsigned int prev, prev_mask, tmp, bitoff, off; \
> \
[Severity: Low]
Should the companion CMPXCHG_GEN() macro right below XCHG_GEN() also be
marked notrace? On !CONFIG_PPC_HAS_LBARX_LHARX builds it still defines
the sub-word __cmpxchg_u8* and __cmpxchg_u16* helpers as plain static
inline functions:
arch/powerpc/include/asm/cmpxchg.h:
#define CMPXCHG_GEN(type, sfx, br, br2, cl) \
static inline \
u32 __cmpxchg_##type##sfx(volatile void *p, u32 old, u32 new) \
> diff --git a/arch/powerpc/include/asm/entry-common.h b/arch/powerpc/include/asm/entry-common.h
> index 8e91489fdf2bb..c487636dba787 100644
> --- a/arch/powerpc/include/asm/entry-common.h
> +++ b/arch/powerpc/include/asm/entry-common.h
[ ... ]
> @@ -320,7 +320,7 @@ static inline bool nmi_disables_ftrace(struct pt_regs *regs)
> return true;
> }
>
> -static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
> +static inline notrace void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
> struct interrupt_nmi_state *state)
> {
> #ifdef CONFIG_PPC64
> @@ -358,7 +358,7 @@ static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
> #endif
> }
>
> -static inline void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
> +static inline notrace void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
> struct interrupt_nmi_state *state)
> {
> /*
[Severity: Medium]
Should this_cpu_get_ftrace_enabled() and this_cpu_set_ftrace_enabled() in
arch/powerpc/include/asm/ftrace.h also be marked notrace?
arch_interrupt_nmi_enter_prepare() and arch_interrupt_nmi_exit_prepare()
call them before irqentry_nmi_enter() and after irqentry_nmi_exit() to
save, disable and restore per-CPU ftrace state while paca->ftrace_enabled
is still non-zero (including in real mode when MSR_DR is 0). In
arch/powerpc/include/asm/ftrace.h those helpers are still plain static
inline functions, so an out-of-line copy can be traced in NMI entry/exit
once inline no longer implies notrace.
> diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
> index 7a89754842d69..3295964f7bce9 100644
> --- a/arch/powerpc/include/asm/io.h
> +++ b/arch/powerpc/include/asm/io.h
[ ... ]
> @@ -151,7 +151,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
> }
>
> #define DEF_MMIO_OUT_D(name, size, insn) \
> -static inline void name(volatile u##size __iomem *addr, u##size val) \
> +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
> { \
> __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \
> : "=m<>" (*addr) : "r" (val) : "memory"); \
[Severity: Medium]
Should the byte-swapped 64-bit MMIO helpers (in_le64() and out_le64() on
big-endian, and in_be64() and out_be64() on little-endian) in
arch/powerpc/include/asm/io.h also be marked notrace?
DEF_MMIO_IN_D and DEF_MMIO_OUT_D only generate the native-endian 64-bit
accessors, while the opposite-endian 64-bit wrappers around swab64() just
below them remain plain static inline functions. On little-endian builds,
in_be64() is called from the noinstr CPU teardown path via
xive_teardown_cpu() -> xive_cleanup_cpu_ipi() ->
xive_do_source_set_mask() -> xive_esb_read(), so an out-of-line copy of
in_be64() can be traced while a CPU is going offline.
> diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
> index d53c4dd4d8b67..7e8f89d4b8f48 100644
> --- a/arch/powerpc/include/asm/ptrace.h
> +++ b/arch/powerpc/include/asm/ptrace.h
[ ... ]
> @@ -305,23 +305,23 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
> regs->gpr[3] = rc;
> }
>
> -static inline bool cpu_has_msr_ri(void)
> +static inline notrace bool cpu_has_msr_ri(void)
> {
> return !IS_ENABLED(CONFIG_BOOKE);
> }
>
> -static inline bool regs_is_unrecoverable(struct pt_regs *regs)
> +static inline notrace bool regs_is_unrecoverable(struct pt_regs *regs)
> {
> return unlikely(cpu_has_msr_ri() && !(regs->msr & MSR_RI));
> }
>
> -static inline void regs_set_recoverable(struct pt_regs *regs)
> +static inline notrace void regs_set_recoverable(struct pt_regs *regs)
> {
> if (cpu_has_msr_ri())
> regs_set_return_msr(regs, regs->msr | MSR_RI);
> }
>
> -static inline void regs_set_unrecoverable(struct pt_regs *regs)
> +static inline notrace void regs_set_unrecoverable(struct pt_regs *regs)
> {
> if (cpu_has_msr_ri())
> regs_set_return_msr(regs, regs->msr & ~MSR_RI);
[Severity: Medium]
Should regs_set_return_msr(), regs_set_return_ip() and
set_return_regs_changed() in arch/powerpc/include/asm/ptrace.h also be
marked notrace?
regs_set_recoverable() and regs_set_unrecoverable() call
regs_set_return_msr() -> set_return_regs_changed(), and
arch_interrupt_nmi_exit_prepare() (which runs on NMI exit after
irqentry_nmi_exit()) and nap_adjust_return() call regs_set_return_ip() ->
set_return_regs_changed(). Because those three helpers remain plain
static inline functions, an out-of-line copy could be traced during NMI
exit once inline no longer implies notrace.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201042201.3199928-1-song@kernel.org?part=20
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace
2026-12-01 4:21 ` [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace Song Liu
2026-12-01 4:50 ` sashiko-bot
@ 2026-12-01 5:08 ` bot+bpf-ci
2026-12-01 6:02 ` Christophe Leroy (CS GROUP)
2 siblings, 0 replies; 39+ messages in thread
From: bot+bpf-ci @ 2026-12-01 5:08 UTC (permalink / raw)
To: song, linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, song, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, mason,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 4674 bytes --]
> powerpc: Mark helpers called from noinstr code notrace
TL;DR:
- wrtee() and mtmsr_isync() may be left traceable out of line in noinstr
paths; unverified in a build
- commit message has wrong riscv irqflags and soft_nmi_interrupt() claims
> powerpc: Mark helpers called from noinstr code notrace
>
> Much of the powerpc code that must not be traced uses plain inline
> helpers from headers: the atomic, bitops and barrier helpers, the
> irqflags and hard irq helpers in <asm/hw_irq.h>, the interrupt entry
> and exit helpers in <asm/entry-common.h>, and the MMIO accessors.
> noinstr code calls them at points where tracing is not safe, for
> example:
> [ ... ]
> - soft_nmi_interrupt() calls wd_smp_lock().
> With clang, a ppc64le_defconfig build has out-of-line copies of many of
> these helpers, called from the functions above. The copies are
> untraced only because inline implies notrace.
> Mark them notrace explicitly, like the irq_soft_mask_*() helpers in
> <asm/hw_irq.h> already are. On x86, arm64 and riscv, the atomic, bitops
> and irqflags helpers are __always_inline. No functional change.
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Song Liu <song@kernel.org>
The commit message says that on riscv the irqflags helpers are
__always_inline. Is that accurate?
In arch/riscv/include/asm/irqflags.h they are plain inline:
static inline unsigned long arch_local_save_flags(void)
static inline void arch_local_irq_enable(void)
static inline void arch_local_irq_disable(void)
The riscv patch later in this series, 0c13f314b0bd ("riscv: Mark helpers
called from noinstr code notrace"), says "On riscv, the arch_local_irq_*()
helpers behind these are plain inline functions. On x86 and arm64 they are
__always_inline." That patch adds notrace and leaves them plain inline, so
the sentence stays wrong after the series. The riscv atomic and bitops
helpers are __always_inline, so only the irqflags part is off.
Could the sentence name only x86 and arm64 for the irqflags helpers?
The commit message also gives soft_nmi_interrupt() calling wd_smp_lock() as
an example of noinstr code calling a helper where tracing is not safe. Is
that accurate?
powerpc interrupt handlers are deliberately not noinstr; interrupt.h says
"Don't use noinstr here like x86, but rather add NOKPROBE_SYMBOL".
soft_nmi_interrupt() is entered with IVEC=0x900 in virtual mode, so
DEFINE_INTERRUPT_HANDLER_NMI calls irqentry_nmi_enter() before the body
runs and RCU is watching when wd_smp_lock() is called. In addition,
nmi_disables_ftrace() has:
/* Allow DEC and PMI to be traced when they are soft-NMI */
and returns false for INTERRUPT_DECREMENTER on BOOK3S_64, so ftrace is left
enabled on purpose. The same handler body also calls wd_try_report(),
set_cpu_stuck() and pr_emerg(), which are all traceable.
Marking wd_smp_lock() and wd_smp_unlock() notrace looks harmless, but could
this example be dropped or reworded to give the real reason?
> diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
> --- a/arch/powerpc/include/asm/hw_irq.h
> +++ b/arch/powerpc/include/asm/hw_irq.h
[ ... ]
> -static inline unsigned long mtmsr_isync_irqsafe(unsigned long msr)
> +static inline notrace unsigned long mtmsr_isync_irqsafe(unsigned long msr)
> {
> #ifdef CONFIG_PPC64
> if (arch_irqs_disabled()) {
mtmsr_isync_irqsafe() and the BookE irqflags helpers call two leaf helpers
from arch/powerpc/include/asm/reg.h that stay plain inline and are not
marked anywhere in the series:
static inline void mtmsr_isync(unsigned long val)
static inline void wrtee(unsigned long val)
On Book3S-64 mtmsr_isync() is reached from code that is notrace on purpose:
arch_exit_to_user_mode_prepare() (notrace)
-> restore_math() (notrace)
-> msr_check_and_set() (notrace)
-> mtmsr_isync_irqsafe() -> mtmsr_isync()
On 32-bit BookE, ct_idle_exit() (noinstr) calls raw_local_irq_save() and
raw_local_irq_restore(), which reach arch_local_irq_save() -> wrtee(0) and
arch_local_irq_restore() -> wrtee(flags) before RCU is watching.
Once a833438864c3 ("compiler_types: Move notrace from inline to
__always_inline") is applied, an out-of-line copy of either function would
get an ftrace call site. Should wrtee() and mtmsr_isync() (and possibly
msr_check_and_clear(), which restore_math() also calls) be marked notrace
here? This was not seen in a build.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace
2026-12-01 4:21 ` [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace Song Liu
2026-12-01 4:50 ` sashiko-bot
2026-12-01 5:08 ` bot+bpf-ci
@ 2026-12-01 6:02 ` Christophe Leroy (CS GROUP)
2 siblings, 0 replies; 39+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-12-01 6:02 UTC (permalink / raw)
To: Song Liu, linux-kernel, linux-trace-kernel, live-patching,
linux-arch, linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, pjw, palmer, aou,
alex, ast, daniel, andrii, ojeda, kernel-team
Le 01/12/2026 à 05:21, Song Liu a écrit :
> Much of the powerpc code that must not be traced uses plain inline
> helpers from headers: the atomic, bitops and barrier helpers, the
> irqflags and hard irq helpers in <asm/hw_irq.h>, the interrupt entry
> and exit helpers in <asm/entry-common.h>, and the MMIO accessors.
> noinstr code calls them at points where tracing is not safe, for
> example:
>
> - The context tracking code updates its state with
> arch_atomic_add_return_relaxed() while RCU is not watching.
>
> - ct_idle_exit(), cpu_idle_poll(), snooze_loop() and the cede loops
> call the irqflags and hard irq helpers, test_thread_local_flags()
> and cede_processor() while RCU is not watching.
>
> - DEFINE_INTERRUPT_HANDLER() and its variants call
> arch_interrupt_enter_prepare() before irqentry_enter(). On entry
> from user mode, irqentry_enter() calls arch_enter_from_user_mode(),
> which uses regs_is_unrecoverable(), trap_is_syscall(), isync() and
> irq_soft_mask_regs_set_state(), before user_exit_irqoff().
>
> - get_pseries_errorlog(), which runs in real mode, calls the RTAS
> error log helpers, and xive_teardown_cpu() calls out_8() on a CPU
> that is going offline.
>
> - soft_nmi_interrupt() calls wd_smp_lock().
>
> With clang, a ppc64le_defconfig build has out-of-line copies of many of
> these helpers, called from the functions above. The copies are
> untraced only because inline implies notrace.
>
> Mark them notrace explicitly, like the irq_soft_mask_*() helpers in
> <asm/hw_irq.h> already are. On x86, arm64 and riscv, the atomic, bitops
> and irqflags helpers are __always_inline. No functional change.
>
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Song Liu <song@kernel.org>
> ---
> arch/powerpc/include/asm/atomic.h | 38 ++++++-------
> arch/powerpc/include/asm/bitops.h | 29 +++++-----
> arch/powerpc/include/asm/cmpxchg.h | 2 +-
> arch/powerpc/include/asm/entry-common.h | 32 +++++------
> arch/powerpc/include/asm/hw_irq.h | 68 +++++++++++------------
> arch/powerpc/include/asm/interrupt.h | 2 +-
> arch/powerpc/include/asm/io.h | 16 +++---
> arch/powerpc/include/asm/plpar_wrappers.h | 4 +-
> arch/powerpc/include/asm/ptrace.h | 14 ++---
> arch/powerpc/include/asm/rtas.h | 10 ++--
> arch/powerpc/include/asm/synch.h | 6 +-
> arch/powerpc/include/asm/thread_info.h | 4 +-
> arch/powerpc/kernel/watchdog.c | 4 +-
> 13 files changed, 115 insertions(+), 114 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
> index d1ea554c33ed..60af4f955d99 100644
> --- a/arch/powerpc/include/asm/atomic.h
> +++ b/arch/powerpc/include/asm/atomic.h
> @@ -24,7 +24,7 @@
> #define __atomic_release_fence() \
> __asm__ __volatile__(PPC_RELEASE_BARRIER "" : : : "memory")
>
> -static __inline__ int arch_atomic_read(const atomic_t *v)
> +static __inline__ notrace int arch_atomic_read(const atomic_t *v)
Comment in include/linux/compiler_types.h tells "New kernel code should
only use the inline spelling". Could you change __inline__ to inline on
all the lines you modify.
> {
> int t;
>
> @@ -37,7 +37,7 @@ static __inline__ int arch_atomic_read(const atomic_t *v)
> return t;
> }
>
> -static __inline__ void arch_atomic_set(atomic_t *v, int i)
> +static __inline__ notrace void arch_atomic_set(atomic_t *v, int i)
> {
> /* -mprefixed can generate offsets beyond range, fall back hack */
> if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
> @@ -47,7 +47,7 @@ static __inline__ void arch_atomic_set(atomic_t *v, int i)
> }
>
> #define ATOMIC_OP(op, asm_op, suffix, sign, ...) \
> -static __inline__ void arch_atomic_##op(int a, atomic_t *v) \
> +static __inline__ notrace void arch_atomic_##op(int a, atomic_t *v) \
> { \
> int t; \
> \
> @@ -62,7 +62,7 @@ static __inline__ void arch_atomic_##op(int a, atomic_t *v) \
> } \
>
> #define ATOMIC_OP_RETURN_RELAXED(op, asm_op, suffix, sign, ...) \
> -static inline int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \
> +static inline notrace int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \
> { \
> int t; \
> \
> @@ -79,7 +79,7 @@ static inline int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \
> }
>
> #define ATOMIC_FETCH_OP_RELAXED(op, asm_op, suffix, sign, ...) \
> -static inline int arch_atomic_fetch_##op##_relaxed(int a, atomic_t *v) \
> +static inline notrace int arch_atomic_fetch_##op##_relaxed(int a, atomic_t *v) \
> { \
> int res, t; \
> \
> @@ -136,7 +136,7 @@ ATOMIC_OPS(xor, xor, "", K)
> * Atomically adds @a to @v, so long as it was not @u.
> * Returns the old value of @v.
> */
> -static __inline__ int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
> +static __inline__ notrace int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
> {
> int t;
>
> @@ -164,7 +164,7 @@ static __inline__ int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
> * The function returns the old value of *v minus 1, even if
> * the atomic variable, v, was not decremented.
> */
> -static __inline__ int arch_atomic_dec_if_positive(atomic_t *v)
> +static __inline__ notrace int arch_atomic_dec_if_positive(atomic_t *v)
> {
> int t;
>
> @@ -190,7 +190,7 @@ static __inline__ int arch_atomic_dec_if_positive(atomic_t *v)
>
> #define ATOMIC64_INIT(i) { (i) }
>
> -static __inline__ s64 arch_atomic64_read(const atomic64_t *v)
> +static __inline__ notrace s64 arch_atomic64_read(const atomic64_t *v)
> {
> s64 t;
>
> @@ -203,7 +203,7 @@ static __inline__ s64 arch_atomic64_read(const atomic64_t *v)
> return t;
> }
>
> -static __inline__ void arch_atomic64_set(atomic64_t *v, s64 i)
> +static __inline__ notrace void arch_atomic64_set(atomic64_t *v, s64 i)
> {
> /* -mprefixed can generate offsets beyond range, fall back hack */
> if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
> @@ -213,7 +213,7 @@ static __inline__ void arch_atomic64_set(atomic64_t *v, s64 i)
> }
>
> #define ATOMIC64_OP(op, asm_op) \
> -static __inline__ void arch_atomic64_##op(s64 a, atomic64_t *v) \
> +static __inline__ notrace void arch_atomic64_##op(s64 a, atomic64_t *v) \
> { \
> s64 t; \
> \
> @@ -228,7 +228,7 @@ static __inline__ void arch_atomic64_##op(s64 a, atomic64_t *v) \
> }
>
> #define ATOMIC64_OP_RETURN_RELAXED(op, asm_op) \
> -static inline s64 \
> +static inline notrace s64 \
> arch_atomic64_##op##_return_relaxed(s64 a, atomic64_t *v) \
> { \
> s64 t; \
> @@ -246,7 +246,7 @@ arch_atomic64_##op##_return_relaxed(s64 a, atomic64_t *v) \
> }
>
> #define ATOMIC64_FETCH_OP_RELAXED(op, asm_op) \
> -static inline s64 \
> +static inline notrace s64 \
> arch_atomic64_fetch_##op##_relaxed(s64 a, atomic64_t *v) \
> { \
> s64 res, t; \
> @@ -295,7 +295,7 @@ ATOMIC64_OPS(xor, xor)
> #undef ATOMIC64_OP_RETURN_RELAXED
> #undef ATOMIC64_OP
>
> -static __inline__ void arch_atomic64_inc(atomic64_t *v)
> +static __inline__ notrace void arch_atomic64_inc(atomic64_t *v)
> {
> s64 t;
>
> @@ -310,7 +310,7 @@ static __inline__ void arch_atomic64_inc(atomic64_t *v)
> }
> #define arch_atomic64_inc arch_atomic64_inc
>
> -static __inline__ s64 arch_atomic64_inc_return_relaxed(atomic64_t *v)
> +static __inline__ notrace s64 arch_atomic64_inc_return_relaxed(atomic64_t *v)
> {
> s64 t;
>
> @@ -326,7 +326,7 @@ static __inline__ s64 arch_atomic64_inc_return_relaxed(atomic64_t *v)
> return t;
> }
>
> -static __inline__ void arch_atomic64_dec(atomic64_t *v)
> +static __inline__ notrace void arch_atomic64_dec(atomic64_t *v)
> {
> s64 t;
>
> @@ -341,7 +341,7 @@ static __inline__ void arch_atomic64_dec(atomic64_t *v)
> }
> #define arch_atomic64_dec arch_atomic64_dec
>
> -static __inline__ s64 arch_atomic64_dec_return_relaxed(atomic64_t *v)
> +static __inline__ notrace s64 arch_atomic64_dec_return_relaxed(atomic64_t *v)
> {
> s64 t;
>
> @@ -364,7 +364,7 @@ static __inline__ s64 arch_atomic64_dec_return_relaxed(atomic64_t *v)
> * Atomically test *v and decrement if it is greater than 0.
> * The function returns the old value of *v minus 1.
> */
> -static __inline__ s64 arch_atomic64_dec_if_positive(atomic64_t *v)
> +static __inline__ notrace s64 arch_atomic64_dec_if_positive(atomic64_t *v)
> {
> s64 t;
>
> @@ -394,7 +394,7 @@ static __inline__ s64 arch_atomic64_dec_if_positive(atomic64_t *v)
> * Atomically adds @a to @v, so long as it was not @u.
> * Returns the old value of @v.
> */
> -static __inline__ s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u)
> +static __inline__ notrace s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u)
> {
> s64 t;
>
> @@ -424,7 +424,7 @@ static __inline__ s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u
> * Atomically increments @v by 1, so long as @v is non-zero.
> * Returns non-zero if @v was non-zero, and zero otherwise.
> */
> -static __inline__ int arch_atomic64_inc_not_zero(atomic64_t *v)
> +static __inline__ notrace int arch_atomic64_inc_not_zero(atomic64_t *v)
> {
> s64 t1, t2;
>
> diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
> index 0d0470cd5ac3..f2123a148dbb 100644
> --- a/arch/powerpc/include/asm/bitops.h
> +++ b/arch/powerpc/include/asm/bitops.h
> @@ -63,7 +63,7 @@
>
> /* Macro for generating the ***_bits() functions */
> #define DEFINE_BITOP(fn, op, prefix) \
> -static inline void fn(unsigned long mask, \
> +static inline notrace void fn(unsigned long mask, \
> volatile unsigned long *_p) \
> { \
> unsigned long old; \
> @@ -94,7 +94,7 @@ static __always_inline bool is_rlwinm_mask_valid(unsigned long x)
> }
>
> #define DEFINE_CLROP(fn, prefix) \
> -static inline void fn(unsigned long mask, volatile unsigned long *_p) \
> +static inline notrace void fn(unsigned long mask, volatile unsigned long *_p) \
> { \
> unsigned long old; \
> unsigned long *p = (unsigned long *)_p; \
> @@ -126,22 +126,22 @@ static inline void fn(unsigned long mask, volatile unsigned long *_p) \
> DEFINE_CLROP(clear_bits, "")
> DEFINE_CLROP(clear_bits_unlock, PPC_RELEASE_BARRIER)
>
> -static inline void arch_set_bit(int nr, volatile unsigned long *addr)
> +static inline notrace void arch_set_bit(int nr, volatile unsigned long *addr)
> {
> set_bits(BIT_MASK(nr), addr + BIT_WORD(nr));
> }
>
> -static inline void arch_clear_bit(int nr, volatile unsigned long *addr)
> +static inline notrace void arch_clear_bit(int nr, volatile unsigned long *addr)
> {
> clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr));
> }
>
> -static inline void arch_clear_bit_unlock(int nr, volatile unsigned long *addr)
> +static inline notrace void arch_clear_bit_unlock(int nr, volatile unsigned long *addr)
> {
> clear_bits_unlock(BIT_MASK(nr), addr + BIT_WORD(nr));
> }
>
> -static inline void arch_change_bit(int nr, volatile unsigned long *addr)
> +static inline notrace void arch_change_bit(int nr, volatile unsigned long *addr)
> {
> change_bits(BIT_MASK(nr), addr + BIT_WORD(nr));
> }
> @@ -149,7 +149,7 @@ static inline void arch_change_bit(int nr, volatile unsigned long *addr)
> /* Like DEFINE_BITOP(), with changes to the arguments to 'op' and the output
> * operands. */
> #define DEFINE_TESTOP(fn, op, prefix, postfix, eh) \
> -static inline unsigned long fn( \
> +static inline notrace unsigned long fn( \
> unsigned long mask, \
> volatile unsigned long *_p) \
> { \
> @@ -175,7 +175,8 @@ DEFINE_TESTOP(test_and_set_bits_lock, or, "",
> DEFINE_TESTOP(test_and_change_bits, xor, PPC_ATOMIC_ENTRY_BARRIER,
> PPC_ATOMIC_EXIT_BARRIER, 0)
>
> -static inline unsigned long test_and_clear_bits(unsigned long mask, volatile unsigned long *_p)
> +static inline notrace unsigned long
> +test_and_clear_bits(unsigned long mask, volatile unsigned long *_p)
> {
> unsigned long old, t;
> unsigned long *p = (unsigned long *)_p;
> @@ -208,32 +209,32 @@ static inline unsigned long test_and_clear_bits(unsigned long mask, volatile uns
> return (old & mask);
> }
>
> -static inline int arch_test_and_set_bit(unsigned long nr,
> +static inline notrace int arch_test_and_set_bit(unsigned long nr,
> volatile unsigned long *addr)
> {
> return test_and_set_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0;
> }
>
> -static inline int arch_test_and_set_bit_lock(unsigned long nr,
> +static inline notrace int arch_test_and_set_bit_lock(unsigned long nr,
> volatile unsigned long *addr)
> {
> return test_and_set_bits_lock(BIT_MASK(nr),
> addr + BIT_WORD(nr)) != 0;
> }
>
> -static inline int arch_test_and_clear_bit(unsigned long nr,
> +static inline notrace int arch_test_and_clear_bit(unsigned long nr,
> volatile unsigned long *addr)
> {
> return test_and_clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0;
> }
>
> -static inline int arch_test_and_change_bit(unsigned long nr,
> +static inline notrace int arch_test_and_change_bit(unsigned long nr,
> volatile unsigned long *addr)
> {
> return test_and_change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0;
> }
>
> -static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask,
> +static inline notrace bool arch_xor_unlock_is_negative_byte(unsigned long mask,
> volatile unsigned long *p)
> {
> unsigned long old, t;
> @@ -254,7 +255,7 @@ static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask,
>
> #include <asm-generic/bitops/non-atomic.h>
>
> -static inline void arch___clear_bit_unlock(int nr, volatile unsigned long *addr)
> +static inline notrace void arch___clear_bit_unlock(int nr, volatile unsigned long *addr)
> {
> __asm__ __volatile__(PPC_RELEASE_BARRIER "" ::: "memory");
> __clear_bit(nr, addr);
> diff --git a/arch/powerpc/include/asm/cmpxchg.h b/arch/powerpc/include/asm/cmpxchg.h
> index dbb50c06f0bf..fe298147f024 100644
> --- a/arch/powerpc/include/asm/cmpxchg.h
> +++ b/arch/powerpc/include/asm/cmpxchg.h
> @@ -14,7 +14,7 @@
> #endif
>
> #define XCHG_GEN(type, sfx, cl) \
> -static inline u32 __xchg_##type##sfx(volatile void *p, u32 val) \
> +static inline notrace u32 __xchg_##type##sfx(volatile void *p, u32 val) \
> { \
> unsigned int prev, prev_mask, tmp, bitoff, off; \
> \
> diff --git a/arch/powerpc/include/asm/entry-common.h b/arch/powerpc/include/asm/entry-common.h
> index 8e91489fdf2b..c487636dba78 100644
> --- a/arch/powerpc/include/asm/entry-common.h
> +++ b/arch/powerpc/include/asm/entry-common.h
> @@ -31,7 +31,7 @@ unsigned long search_kernel_restart_table(unsigned long addr);
>
> DECLARE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
>
> -static inline bool is_implicit_soft_masked(struct pt_regs *regs)
> +static inline notrace bool is_implicit_soft_masked(struct pt_regs *regs)
> {
> if (user_mode(regs))
> return false;
> @@ -42,28 +42,28 @@ static inline bool is_implicit_soft_masked(struct pt_regs *regs)
> return search_kernel_soft_mask_table(regs->nip);
> }
>
> -static inline void srr_regs_clobbered(void)
> +static inline notrace void srr_regs_clobbered(void)
> {
> local_paca->srr_valid = 0;
> local_paca->hsrr_valid = 0;
> }
> #else
> -static inline unsigned long search_kernel_restart_table(unsigned long addr)
> +static inline notrace unsigned long search_kernel_restart_table(unsigned long addr)
> {
> return 0;
> }
>
> -static inline bool is_implicit_soft_masked(struct pt_regs *regs)
> +static inline notrace bool is_implicit_soft_masked(struct pt_regs *regs)
> {
> return false;
> }
>
> -static inline void srr_regs_clobbered(void)
> +static inline notrace void srr_regs_clobbered(void)
> {
> }
> #endif
>
> -static inline void nap_adjust_return(struct pt_regs *regs)
> +static inline notrace void nap_adjust_return(struct pt_regs *regs)
> {
> #ifdef CONFIG_PPC_970_NAP
> /*
> @@ -103,7 +103,7 @@ static __always_inline void booke_load_dbcr0(void)
> #endif
> }
>
> -static inline void booke_restore_dbcr0(void)
> +static inline notrace void booke_restore_dbcr0(void)
> {
> #ifdef CONFIG_PPC_ADV_DEBUG_REGS
> unsigned long dbcr0 = current->thread.debug.dbcr0;
> @@ -115,7 +115,7 @@ static inline void booke_restore_dbcr0(void)
> #endif
> }
>
> -static inline void check_return_regs_valid(struct pt_regs *regs)
> +static inline notrace void check_return_regs_valid(struct pt_regs *regs)
> {
> #ifdef CONFIG_PPC_BOOK3S_64
> unsigned long trap, srr0, srr1;
> @@ -195,7 +195,7 @@ static inline void check_return_regs_valid(struct pt_regs *regs)
> #endif
> }
>
> -static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
> +static inline notrace void arch_interrupt_enter_prepare(struct pt_regs *regs)
> {
> #ifdef CONFIG_PPC64
> irq_soft_mask_set(IRQS_ALL_DISABLED);
> @@ -255,7 +255,7 @@ static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
> * However arch_interrupt_nmi_exit_prepare does return directly to regs, because
> * NMIs do not do "exit work" or replay soft-masked interrupts.
> */
> -static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)
> +static inline notrace void arch_interrupt_exit_prepare(struct pt_regs *regs)
> {
> if (user_mode(regs)) {
> BUG_ON(regs_is_unrecoverable(regs));
> @@ -271,7 +271,7 @@ static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)
> hard_irq_disable();
> }
>
> -static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
> +static inline notrace void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
> {
> #ifdef CONFIG_PPC64
> /* Ensure arch_interrupt_enter_prepare does not enable MSR[EE] */
> @@ -289,7 +289,7 @@ static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
> #endif
> }
>
> -static inline void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
> +static inline notrace void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
> {
> arch_interrupt_exit_prepare(regs);
> }
> @@ -303,7 +303,7 @@ struct interrupt_nmi_state {
> #endif
> };
>
> -static inline bool nmi_disables_ftrace(struct pt_regs *regs)
> +static inline notrace bool nmi_disables_ftrace(struct pt_regs *regs)
> {
> /* Allow DEC and PMI to be traced when they are soft-NMI */
> if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) {
> @@ -320,7 +320,7 @@ static inline bool nmi_disables_ftrace(struct pt_regs *regs)
> return true;
> }
>
> -static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
> +static inline notrace void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
> struct interrupt_nmi_state *state)
> {
> #ifdef CONFIG_PPC64
> @@ -358,7 +358,7 @@ static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
> #endif
> }
>
> -static inline void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
> +static inline notrace void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
> struct interrupt_nmi_state *state)
> {
> /*
> @@ -480,7 +480,7 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
>
> #define arch_enter_from_user_mode arch_enter_from_user_mode
>
> -static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
> +static inline notrace void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
> unsigned long ti_work)
> {
> unsigned long mathflags;
> diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
> index ddb850e62abd..3d076f5de73e 100644
> --- a/arch/powerpc/include/asm/hw_irq.h
> +++ b/arch/powerpc/include/asm/hw_irq.h
> @@ -61,7 +61,7 @@
>
> #ifndef __ASSEMBLER__
>
> -static inline void __hard_irq_enable(void)
> +static inline notrace void __hard_irq_enable(void)
> {
> if (IS_ENABLED(CONFIG_BOOKE))
> wrtee(MSR_EE);
> @@ -73,7 +73,7 @@ static inline void __hard_irq_enable(void)
> mtmsr(mfmsr() | MSR_EE);
> }
>
> -static inline void __hard_irq_disable(void)
> +static inline notrace void __hard_irq_disable(void)
> {
> if (IS_ENABLED(CONFIG_BOOKE))
> wrtee(0);
> @@ -85,7 +85,7 @@ static inline void __hard_irq_disable(void)
> mtmsr(mfmsr() & ~MSR_EE);
> }
>
> -static inline void __hard_EE_RI_disable(void)
> +static inline notrace void __hard_EE_RI_disable(void)
> {
> if (IS_ENABLED(CONFIG_BOOKE))
> wrtee(0);
> @@ -97,7 +97,7 @@ static inline void __hard_EE_RI_disable(void)
> mtmsr(mfmsr() & ~(MSR_EE | MSR_RI));
> }
>
> -static inline void __hard_RI_enable(void)
> +static inline notrace void __hard_RI_enable(void)
> {
> if (IS_ENABLED(CONFIG_BOOKE))
> return;
> @@ -184,39 +184,39 @@ static inline notrace unsigned long irq_soft_mask_andc_return(unsigned long mask
> return flags;
> }
>
> -static inline unsigned long arch_local_save_flags(void)
> +static inline notrace unsigned long arch_local_save_flags(void)
> {
> return irq_soft_mask_return();
> }
>
> -static inline void arch_local_irq_disable(void)
> +static inline notrace void arch_local_irq_disable(void)
> {
> irq_soft_mask_set(IRQS_DISABLED);
> }
>
> extern void arch_local_irq_restore(unsigned long);
>
> -static inline void arch_local_irq_enable(void)
> +static inline notrace void arch_local_irq_enable(void)
> {
> arch_local_irq_restore(IRQS_ENABLED);
> }
>
> -static inline unsigned long arch_local_irq_save(void)
> +static inline notrace unsigned long arch_local_irq_save(void)
> {
> return irq_soft_mask_or_return(IRQS_DISABLED);
> }
>
> -static inline bool arch_irqs_disabled_flags(unsigned long flags)
> +static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
> {
> return flags & IRQS_DISABLED;
> }
>
> -static inline bool arch_irqs_disabled(void)
> +static inline notrace bool arch_irqs_disabled(void)
> {
> return arch_irqs_disabled_flags(arch_local_save_flags());
> }
>
> -static inline void set_pmi_irq_pending(void)
> +static inline notrace void set_pmi_irq_pending(void)
> {
> /*
> * Invoked from PMU callback functions to set PMI bit in the paca.
> @@ -228,7 +228,7 @@ static inline void set_pmi_irq_pending(void)
> get_paca()->irq_happened |= PACA_IRQ_PMI;
> }
>
> -static inline void clear_pmi_irq_pending(void)
> +static inline notrace void clear_pmi_irq_pending(void)
> {
> /*
> * Invoked from PMU callback functions to clear the pending PMI bit
> @@ -240,7 +240,7 @@ static inline void clear_pmi_irq_pending(void)
> get_paca()->irq_happened &= ~PACA_IRQ_PMI;
> }
>
> -static inline bool pmi_irq_pending(void)
> +static inline notrace bool pmi_irq_pending(void)
> {
> /*
> * Invoked from PMU callback functions to check if there is a pending
> @@ -310,7 +310,7 @@ static inline bool pmi_irq_pending(void)
> } \
> } while(0)
>
> -static inline bool __lazy_irq_pending(u8 irq_happened)
> +static inline notrace bool __lazy_irq_pending(u8 irq_happened)
> {
> return !!(irq_happened & ~PACA_IRQ_HARD_DIS);
> }
> @@ -318,7 +318,7 @@ static inline bool __lazy_irq_pending(u8 irq_happened)
> /*
> * Check if a lazy IRQ is pending. Should be called with IRQs hard disabled.
> */
> -static inline bool lazy_irq_pending(void)
> +static inline notrace bool lazy_irq_pending(void)
> {
> return __lazy_irq_pending(get_paca()->irq_happened);
> }
> @@ -328,7 +328,7 @@ static inline bool lazy_irq_pending(void)
> * Should be called with IRQs hard disabled.
> * For use in RI disabled code or other constrained situations.
> */
> -static inline bool lazy_irq_pending_nocheck(void)
> +static inline notrace bool lazy_irq_pending_nocheck(void)
> {
> return __lazy_irq_pending(local_paca->irq_happened);
> }
> @@ -342,7 +342,7 @@ bool power_pmu_wants_prompt_pmi(void);
> * is a different soft-masked interrupt pending that requires hard
> * masking.
> */
> -static inline bool should_hard_irq_enable(struct pt_regs *regs)
> +static inline notrace bool should_hard_irq_enable(struct pt_regs *regs)
> {
> if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG)) {
> WARN_ON(irq_soft_mask_return() != IRQS_ALL_DISABLED);
> @@ -381,7 +381,7 @@ static inline bool should_hard_irq_enable(struct pt_regs *regs)
> * Do the hard enabling, only call this if should_hard_irq_enable is true.
> * This allows PMI interrupts to profile irq handlers.
> */
> -static inline void do_hard_irq_enable(void)
> +static inline notrace void do_hard_irq_enable(void)
> {
> /*
> * Asynch interrupts come in with IRQS_ALL_DISABLED,
> @@ -393,7 +393,7 @@ static inline void do_hard_irq_enable(void)
> __hard_irq_enable();
> }
>
> -static inline bool regs_irqs_disabled(struct pt_regs *regs)
> +static inline notrace bool regs_irqs_disabled(struct pt_regs *regs)
> {
> return (regs->softe & IRQS_DISABLED);
> }
> @@ -406,7 +406,7 @@ extern void irq_set_pending_from_srr1(unsigned long srr1);
>
> extern void force_external_irq_replay(void);
>
> -static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
> +static inline notrace void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
> {
> regs->softe = val;
> }
> @@ -417,12 +417,12 @@ static inline notrace unsigned long irq_soft_mask_return(void)
> return 0;
> }
>
> -static inline unsigned long arch_local_save_flags(void)
> +static inline notrace unsigned long arch_local_save_flags(void)
> {
> return mfmsr();
> }
>
> -static inline void arch_local_irq_restore(unsigned long flags)
> +static inline notrace void arch_local_irq_restore(unsigned long flags)
> {
> if (IS_ENABLED(CONFIG_BOOKE))
> wrtee(flags);
> @@ -430,7 +430,7 @@ static inline void arch_local_irq_restore(unsigned long flags)
> mtmsr(flags);
> }
>
> -static inline unsigned long arch_local_irq_save(void)
> +static inline notrace unsigned long arch_local_irq_save(void)
> {
> unsigned long flags = arch_local_save_flags();
>
> @@ -444,29 +444,29 @@ static inline unsigned long arch_local_irq_save(void)
> return flags;
> }
>
> -static inline void arch_local_irq_disable(void)
> +static inline notrace void arch_local_irq_disable(void)
> {
> __hard_irq_disable();
> }
>
> -static inline void arch_local_irq_enable(void)
> +static inline notrace void arch_local_irq_enable(void)
> {
> __hard_irq_enable();
> }
>
> -static inline bool arch_irqs_disabled_flags(unsigned long flags)
> +static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
> {
> return (flags & MSR_EE) == 0;
> }
>
> -static inline bool arch_irqs_disabled(void)
> +static inline notrace bool arch_irqs_disabled(void)
> {
> return arch_irqs_disabled_flags(arch_local_save_flags());
> }
>
> #define hard_irq_disable() local_irq_disable()
>
> -static inline bool regs_irqs_disabled(struct pt_regs *regs)
> +static inline notrace bool regs_irqs_disabled(struct pt_regs *regs)
> {
> return !(regs->msr & MSR_EE);
> }
> @@ -476,21 +476,21 @@ static __always_inline bool should_hard_irq_enable(struct pt_regs *regs)
> return false;
> }
>
> -static inline void do_hard_irq_enable(void)
> +static inline notrace void do_hard_irq_enable(void)
> {
> BUILD_BUG();
> }
>
> -static inline void clear_pmi_irq_pending(void) { }
> -static inline void set_pmi_irq_pending(void) { }
> -static inline bool pmi_irq_pending(void) { return false; }
> +static inline notrace void clear_pmi_irq_pending(void) { }
> +static inline notrace void set_pmi_irq_pending(void) { }
> +static inline notrace bool pmi_irq_pending(void) { return false; }
>
> -static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
> +static inline notrace void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
> {
> }
> #endif /* CONFIG_PPC64 */
>
> -static inline unsigned long mtmsr_isync_irqsafe(unsigned long msr)
> +static inline notrace unsigned long mtmsr_isync_irqsafe(unsigned long msr)
> {
> #ifdef CONFIG_PPC64
> if (arch_irqs_disabled()) {
> diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h
> index c7d0e71eac83..f358ea26e57b 100644
> --- a/arch/powerpc/include/asm/interrupt.h
> +++ b/arch/powerpc/include/asm/interrupt.h
> @@ -397,7 +397,7 @@ void __noreturn unrecoverable_exception(struct pt_regs *regs);
> void replay_system_reset(void);
> void replay_soft_interrupts(void);
>
> -static inline void interrupt_cond_local_irq_enable(struct pt_regs *regs)
> +static inline notrace void interrupt_cond_local_irq_enable(struct pt_regs *regs)
> {
> if (!regs_irqs_disabled(regs))
> local_irq_enable();
> diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
> index 7a89754842d6..3295964f7bce 100644
> --- a/arch/powerpc/include/asm/io.h
> +++ b/arch/powerpc/include/asm/io.h
> @@ -91,7 +91,7 @@ extern bool isa_io_special;
> /* -mprefixed can generate offsets beyond range, fall back hack */
> #ifdef CONFIG_PPC_KERNEL_PREFIXED
> #define DEF_MMIO_IN_X(name, size, insn) \
> -static inline u##size name(const volatile u##size __iomem *addr) \
> +static inline notrace u##size name(const volatile u##size __iomem *addr) \
> { \
> u##size ret; \
> __asm__ __volatile__("sync;"#insn" %0,0,%1;twi 0,%0,0;isync" \
> @@ -100,7 +100,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
> }
>
> #define DEF_MMIO_OUT_X(name, size, insn) \
> -static inline void name(volatile u##size __iomem *addr, u##size val) \
> +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
> { \
> __asm__ __volatile__("sync;"#insn" %1,0,%0" \
> : : "r" (addr), "r" (val) : "memory"); \
> @@ -108,7 +108,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
> }
>
> #define DEF_MMIO_IN_D(name, size, insn) \
> -static inline u##size name(const volatile u##size __iomem *addr) \
> +static inline notrace u##size name(const volatile u##size __iomem *addr) \
> { \
> u##size ret; \
> __asm__ __volatile__("sync;"#insn" %0,0(%1);twi 0,%0,0;isync"\
> @@ -117,7 +117,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
> }
>
> #define DEF_MMIO_OUT_D(name, size, insn) \
> -static inline void name(volatile u##size __iomem *addr, u##size val) \
> +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
> { \
> __asm__ __volatile__("sync;"#insn" %1,0(%0)" \
> : : "b" (addr), "r" (val) : "memory"); \
> @@ -125,7 +125,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
> }
> #else
> #define DEF_MMIO_IN_X(name, size, insn) \
> -static inline u##size name(const volatile u##size __iomem *addr) \
> +static inline notrace u##size name(const volatile u##size __iomem *addr) \
> { \
> u##size ret; \
> __asm__ __volatile__("sync;"#insn" %0,%y1;twi 0,%0,0;isync" \
> @@ -134,7 +134,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
> }
>
> #define DEF_MMIO_OUT_X(name, size, insn) \
> -static inline void name(volatile u##size __iomem *addr, u##size val) \
> +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
> { \
> __asm__ __volatile__("sync;"#insn" %1,%y0" \
> : "=Z" (*addr) : "r" (val) : "memory"); \
> @@ -142,7 +142,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
> }
>
> #define DEF_MMIO_IN_D(name, size, insn) \
> -static inline u##size name(const volatile u##size __iomem *addr) \
> +static inline notrace u##size name(const volatile u##size __iomem *addr) \
> { \
> u##size ret; \
> __asm__ __volatile__("sync;"#insn"%U1%X1 %0,%1;twi 0,%0,0;isync"\
> @@ -151,7 +151,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
> }
>
> #define DEF_MMIO_OUT_D(name, size, insn) \
> -static inline void name(volatile u##size __iomem *addr, u##size val) \
> +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \
> { \
> __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \
> : "=m<>" (*addr) : "r" (val) : "memory"); \
> diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
> index f2b6cc4341bb..dd45f632272d 100644
> --- a/arch/powerpc/include/asm/plpar_wrappers.h
> +++ b/arch/powerpc/include/asm/plpar_wrappers.h
> @@ -13,12 +13,12 @@
> #include <asm/lppaca.h>
> #include <asm/page.h>
>
> -static inline long poll_pending(void)
> +static inline notrace long poll_pending(void)
> {
> return plpar_hcall_norets(H_POLL_PENDING);
> }
>
> -static inline long cede_processor(void)
> +static inline notrace long cede_processor(void)
> {
> /*
> * We cannot call tracepoints inside RCU idle regions which
> diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
> index d53c4dd4d8b6..7e8f89d4b8f4 100644
> --- a/arch/powerpc/include/asm/ptrace.h
> +++ b/arch/powerpc/include/asm/ptrace.h
> @@ -255,17 +255,17 @@ static __always_inline void set_trap(struct pt_regs *regs, unsigned long val)
> regs->trap = (regs->trap & TRAP_FLAGS_MASK) | (val & ~TRAP_FLAGS_MASK);
> }
>
> -static inline bool trap_is_scv(struct pt_regs *regs)
> +static inline notrace bool trap_is_scv(struct pt_regs *regs)
> {
> return (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) == 0x3000);
> }
>
> -static inline bool trap_is_unsupported_scv(struct pt_regs *regs)
> +static inline notrace bool trap_is_unsupported_scv(struct pt_regs *regs)
> {
> return IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) == 0x7ff0;
> }
>
> -static inline bool trap_is_syscall(struct pt_regs *regs)
> +static inline notrace bool trap_is_syscall(struct pt_regs *regs)
> {
> return (trap_is_scv(regs) || TRAP(regs) == 0xc00);
> }
> @@ -305,23 +305,23 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
> regs->gpr[3] = rc;
> }
>
> -static inline bool cpu_has_msr_ri(void)
> +static inline notrace bool cpu_has_msr_ri(void)
> {
> return !IS_ENABLED(CONFIG_BOOKE);
> }
>
> -static inline bool regs_is_unrecoverable(struct pt_regs *regs)
> +static inline notrace bool regs_is_unrecoverable(struct pt_regs *regs)
> {
> return unlikely(cpu_has_msr_ri() && !(regs->msr & MSR_RI));
> }
>
> -static inline void regs_set_recoverable(struct pt_regs *regs)
> +static inline notrace void regs_set_recoverable(struct pt_regs *regs)
> {
> if (cpu_has_msr_ri())
> regs_set_return_msr(regs, regs->msr | MSR_RI);
> }
>
> -static inline void regs_set_unrecoverable(struct pt_regs *regs)
> +static inline notrace void regs_set_unrecoverable(struct pt_regs *regs)
> {
> if (cpu_has_msr_ri())
> regs_set_return_msr(regs, regs->msr & ~MSR_RI);
> diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
> index d046bbd5017d..7c3431c272e0 100644
> --- a/arch/powerpc/include/asm/rtas.h
> +++ b/arch/powerpc/include/asm/rtas.h
> @@ -343,7 +343,7 @@ static inline uint8_t rtas_error_initiator(const struct rtas_error_log *elog)
>
> #define rtas_error_type(x) ((x)->byte3)
>
> -static inline
> +static inline notrace
> uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog)
> {
> return be32_to_cpu(elog->extended_log_length);
> @@ -354,13 +354,13 @@ uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog)
> #define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8))
>
> static
> -inline uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log)
> +inline notrace uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log)
> {
> return ext_log->byte2 & 0x0F;
> }
>
> static
> -inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
> +inline notrace uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
> {
> return be32_to_cpu(ext_log->company_id);
> }
> @@ -389,13 +389,13 @@ inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
> #define PSERIES_ELOG_SECT_ID_MCE (('M' << 8) | 'C')
>
> static
> -inline uint16_t pseries_errorlog_id(struct pseries_errorlog *sect)
> +inline notrace uint16_t pseries_errorlog_id(struct pseries_errorlog *sect)
> {
> return be16_to_cpu(sect->id);
> }
>
> static
> -inline uint16_t pseries_errorlog_length(struct pseries_errorlog *sect)
> +inline notrace uint16_t pseries_errorlog_length(struct pseries_errorlog *sect)
> {
> return be16_to_cpu(sect->length);
> }
> diff --git a/arch/powerpc/include/asm/synch.h b/arch/powerpc/include/asm/synch.h
> index d0e9765dee28..178fe45c8927 100644
> --- a/arch/powerpc/include/asm/synch.h
> +++ b/arch/powerpc/include/asm/synch.h
> @@ -12,7 +12,7 @@ extern unsigned int __start___lwsync_fixup, __stop___lwsync_fixup;
> extern void do_lwsync_fixups(unsigned long value, void *fixup_start,
> void *fixup_end);
>
> -static inline void eieio(void)
> +static inline notrace void eieio(void)
> {
> if (IS_ENABLED(CONFIG_BOOKE))
> __asm__ __volatile__ ("mbar" : : : "memory");
> @@ -20,12 +20,12 @@ static inline void eieio(void)
> __asm__ __volatile__ ("eieio" : : : "memory");
> }
>
> -static inline void isync(void)
> +static inline notrace void isync(void)
> {
> __asm__ __volatile__ ("isync" : : : "memory");
> }
>
> -static inline void ppc_after_tlbiel_barrier(void)
> +static inline notrace void ppc_after_tlbiel_barrier(void)
> {
> asm volatile("ptesync": : :"memory");
> /*
> diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> index 1e069a2e7ce8..04147dd91dfd 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -165,13 +165,13 @@ void arch_setup_new_exec(void);
>
> #ifndef __ASSEMBLER__
>
> -static inline void clear_thread_local_flags(unsigned int flags)
> +static inline notrace void clear_thread_local_flags(unsigned int flags)
> {
> struct thread_info *ti = current_thread_info();
> ti->local_flags &= ~flags;
> }
>
> -static inline bool test_thread_local_flags(unsigned int flags)
> +static inline notrace bool test_thread_local_flags(unsigned int flags)
> {
> struct thread_info *ti = current_thread_info();
> return (ti->local_flags & flags) != 0;
> diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
> index 44f178e07531..00f4712290b5 100644
> --- a/arch/powerpc/kernel/watchdog.c
> +++ b/arch/powerpc/kernel/watchdog.c
> @@ -121,7 +121,7 @@ static void wd_end_reporting(void)
> WRITE_ONCE(__wd_reporting, 0);
> }
>
> -static inline void wd_smp_lock(unsigned long *flags)
> +static inline notrace void wd_smp_lock(unsigned long *flags)
> {
> /*
> * Avoid locking layers if possible.
> @@ -138,7 +138,7 @@ static inline void wd_smp_lock(unsigned long *flags)
> }
> }
>
> -static inline void wd_smp_unlock(unsigned long *flags)
> +static inline notrace void wd_smp_unlock(unsigned long *flags)
> {
> clear_bit_unlock(0, &__wd_smp_lock);
> raw_local_irq_restore(*flags);
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v3 21/22] riscv: Mark helpers called from noinstr code notrace
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (19 preceding siblings ...)
2026-12-01 4:21 ` [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace Song Liu
@ 2026-12-01 4:22 ` Song Liu
2026-12-01 4:22 ` [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline Song Liu
2026-12-01 11:13 ` [PATCH v3 00/22] " David Laight
22 siblings, 0 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:22 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
Some noinstr code calls plain inline riscv helpers at points where
tracing is not safe:
- ct_idle_exit() calls raw_local_irq_save() and
raw_local_irq_restore() around ct_kernel_enter(), and cpu_idle_poll()
calls raw_local_irq_enable() and cpu_relax() between
ct_cpuidle_enter() and ct_cpuidle_exit(), while RCU is not watching.
On riscv, the arch_local_irq_*() helpers behind these are plain
inline functions. On x86 and arm64 they are __always_inline.
- arch_cpu_idle() calls cpu_do_idle() while RCU is not watching.
- do_trap_ecall_u() calls riscv_v_vstate_discard() before
syscall_enter_from_user_mode(), while RCU is not watching.
With clang, a riscv defconfig build has out-of-line copies of
cpu_do_idle(), riscv_v_vstate_discard() and several of the irqflags
helpers, called from these functions and from other noinstr code. The
copies are untraced only because inline implies notrace.
Mark these helpers notrace explicitly, together with the rest of the
irqflags helpers and the helpers that riscv_v_vstate_discard() calls.
No functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
arch/riscv/include/asm/cpuidle.h | 2 +-
arch/riscv/include/asm/irqflags.h | 14 +++++++-------
arch/riscv/include/asm/vdso/processor.h | 2 +-
arch/riscv/include/asm/vector.h | 8 ++++----
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/arch/riscv/include/asm/cpuidle.h b/arch/riscv/include/asm/cpuidle.h
index 71fdc607d4bc..20b34b344451 100644
--- a/arch/riscv/include/asm/cpuidle.h
+++ b/arch/riscv/include/asm/cpuidle.h
@@ -10,7 +10,7 @@
#include <asm/barrier.h>
#include <asm/processor.h>
-static inline void cpu_do_idle(void)
+static inline void notrace cpu_do_idle(void)
{
/*
* Add mb() here to ensure that all
diff --git a/arch/riscv/include/asm/irqflags.h b/arch/riscv/include/asm/irqflags.h
index 6fd8cbfcfcc7..905ea914521f 100644
--- a/arch/riscv/include/asm/irqflags.h
+++ b/arch/riscv/include/asm/irqflags.h
@@ -10,43 +10,43 @@
#include <asm/csr.h>
/* read interrupt enabled status */
-static inline unsigned long arch_local_save_flags(void)
+static inline unsigned long notrace arch_local_save_flags(void)
{
return csr_read(CSR_STATUS);
}
/* unconditionally enable interrupts */
-static inline void arch_local_irq_enable(void)
+static inline void notrace arch_local_irq_enable(void)
{
csr_set(CSR_STATUS, SR_IE);
}
/* unconditionally disable interrupts */
-static inline void arch_local_irq_disable(void)
+static inline void notrace arch_local_irq_disable(void)
{
csr_clear(CSR_STATUS, SR_IE);
}
/* get status and disable interrupts */
-static inline unsigned long arch_local_irq_save(void)
+static inline unsigned long notrace arch_local_irq_save(void)
{
return csr_read_clear(CSR_STATUS, SR_IE);
}
/* test flags */
-static inline int arch_irqs_disabled_flags(unsigned long flags)
+static inline int notrace arch_irqs_disabled_flags(unsigned long flags)
{
return !(flags & SR_IE);
}
/* test hardware interrupt enable bit */
-static inline int arch_irqs_disabled(void)
+static inline int notrace arch_irqs_disabled(void)
{
return arch_irqs_disabled_flags(arch_local_save_flags());
}
/* set interrupt enabled status */
-static inline void arch_local_irq_restore(unsigned long flags)
+static inline void notrace arch_local_irq_restore(unsigned long flags)
{
csr_set(CSR_STATUS, flags & SR_IE);
}
diff --git a/arch/riscv/include/asm/vdso/processor.h b/arch/riscv/include/asm/vdso/processor.h
index c42f95dc8811..a0636bbda765 100644
--- a/arch/riscv/include/asm/vdso/processor.h
+++ b/arch/riscv/include/asm/vdso/processor.h
@@ -8,7 +8,7 @@
#include <asm/errata_list.h>
#include <asm/insn-def.h>
-static inline void cpu_relax(void)
+static inline void notrace cpu_relax(void)
{
#ifdef __riscv_muldiv
int dummy;
diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
index 3381a535abb4..735841258fe3 100644
--- a/arch/riscv/include/asm/vector.h
+++ b/arch/riscv/include/asm/vector.h
@@ -90,7 +90,7 @@ static inline void __riscv_v_vstate_clean(struct pt_regs *regs)
regs->status = __riscv_v_vstate_or(regs->status, CLEAN);
}
-static inline void __riscv_v_vstate_dirty(struct pt_regs *regs)
+static inline void notrace __riscv_v_vstate_dirty(struct pt_regs *regs)
{
regs->status = __riscv_v_vstate_or(regs->status, DIRTY);
}
@@ -105,7 +105,7 @@ static inline void riscv_v_vstate_on(struct pt_regs *regs)
regs->status = __riscv_v_vstate_or(regs->status, INITIAL);
}
-static inline bool riscv_v_vstate_query(struct pt_regs *regs)
+static inline bool notrace riscv_v_vstate_query(struct pt_regs *regs)
{
return !__riscv_v_vstate_check(regs->status, OFF);
}
@@ -272,7 +272,7 @@ static inline void __riscv_v_vstate_restore(struct __riscv_v_ext_state *restore_
riscv_v_disable();
}
-static inline void __riscv_v_vstate_discard(void)
+static inline void notrace __riscv_v_vstate_discard(void)
{
unsigned long vl, vtype_inval = 1UL << (BITS_PER_LONG - 1);
@@ -300,7 +300,7 @@ static inline void __riscv_v_vstate_discard(void)
riscv_v_disable();
}
-static inline void riscv_v_vstate_discard(struct pt_regs *regs)
+static inline void notrace riscv_v_vstate_discard(struct pt_regs *regs)
{
if (riscv_v_vstate_query(regs)) {
__riscv_v_vstate_discard();
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (20 preceding siblings ...)
2026-12-01 4:22 ` [PATCH v3 21/22] riscv: " Song Liu
@ 2026-12-01 4:22 ` Song Liu
2026-12-01 5:08 ` bot+bpf-ci
` (2 more replies)
2026-12-01 11:13 ` [PATCH v3 00/22] " David Laight
22 siblings, 3 replies; 39+ messages in thread
From: Song Liu @ 2026-12-01 4:22 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, Song Liu
Commit 45959ee7aa64 ("ftrace: Do not function trace inlined functions")
added notrace to the inline macro. At the time, inline was only a hint
with CONFIG_OPTIMIZE_INLINING, and whether a given inline function got
an mcount call depended on the gcc version. Some functions that must
not be traced, such as the paravirt native_*() helpers, were marked
inline and relied on being inlined, so a different gcc could silently
break the function tracer. Making all inline functions notrace removed
that dependency on the compiler.
That trade-off no longer makes sense. CONFIG_OPTIMIZE_INLINING was made
always on by commit ac7c3e4ff401 ("compiler: enable
CONFIG_OPTIMIZE_INLINING forcibly") and removed by commit 889b3c1245de
("compiler: remove CONFIG_OPTIMIZE_INLINING entirely"). The compiler
also inlines static functions that are not marked inline, and creates
.constprop, .isra and .part clones, so the set of traceable functions
already depends on the compiler. notrace on inline does not make it
consistent. It only hides the inline functions that the compiler chose
not to inline. Hidden functions cannot be traced with ftrace or used
as BPF fentry/fexit targets. They also cannot be livepatched, because
livepatch redirects functions through ftrace, so a fix to one of them
has to be shipped by livepatching its callers instead.
A function that must not be traced should say so. The previous patches
mark notrace the inline helpers that relied on inline implying notrace:
the paravirt native helpers, the helpers used by resume and kexec, the
helpers used by bpf_spin_lock, the BPF trampoline and bpf_mem_alloc,
the helpers used by ftrace recursion protection, tracepoints, SRCU, the
trace clocks, core_kernel_text() and the nofault accessors, and the
helpers that noinstr code calls on arm64, powerpc and riscv, including
the generic exception_enter(), exception_exit() and thread flag
helpers, and the arm64 stack unwinder helpers.
Keep notrace on __always_inline. Such functions are meant to be inlined
into their callers. An out-of-line copy exists only when the address of
the function is taken or when it has external linkage, and those copies
are mostly low-level helpers used by entry, context switch and tracing
code.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@kernel.org>
---
include/linux/compiler_attributes.h | 6 +++++-
include/linux/compiler_types.h | 3 +--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
index 476c4c560d17..5fdc07b3e380 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -49,10 +49,14 @@
* to its docs (and also "warning: always_inline function might not be
* inlinable [-Wattributes]" is emitted).
*
+ * The compiler still emits an out-of-line copy of an __always_inline function
+ * when its address is taken or when it has external linkage. These functions
+ * are often used by code that must not be traced, so mark them notrace.
+ *
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute
* clang: mentioned
*/
-#define __always_inline inline __attribute__((__always_inline__))
+#define __always_inline inline __attribute__((__always_inline__)) notrace
/*
* The second argument is optional (default 0), so we use a variadic macro
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index c5921f139007..ea7f2a928b4d 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -230,9 +230,8 @@ struct ftrace_likely_data {
* externally visible function. This makes extern inline behave as per gnu89
* semantics rather than c99. This prevents multiple symbol definition errors
* of extern inline functions at link time.
- * A lot of inline functions can cause havoc with function tracing.
*/
-#define inline inline __gnu_inline __inline_maybe_unused notrace
+#define inline inline __gnu_inline __inline_maybe_unused
/*
* gcc provides both __inline__ and __inline as alternate spellings of
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline
2026-12-01 4:22 ` [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline Song Liu
@ 2026-12-01 5:08 ` bot+bpf-ci
2026-12-01 5:17 ` sashiko-bot
2026-12-01 11:04 ` Miguel Ojeda
2 siblings, 0 replies; 39+ messages in thread
From: bot+bpf-ci @ 2026-12-01 5:08 UTC (permalink / raw)
To: song, linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team, song, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, mason,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 6576 bytes --]
> compiler_types: Move notrace from inline to __always_inline
TL;DR:
- notrace in compiler_attributes.h may break the powerpc boot wrapper build
(unverified)
- dropping notrace from inline may allow ftrace recursion on microblaze,
x86-32 and other architectures (unlikely)
> diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
> --- a/include/linux/compiler_attributes.h
> +++ b/include/linux/compiler_attributes.h
[ ... ]
> -#define __always_inline inline __attribute__((__always_inline__))
> +#define __always_inline inline __attribute__((__always_inline__)) notrace
Is notrace defined everywhere compiler_attributes.h is used?
notrace is defined in compiler_types.h, and its definition depends on
CC_USING_HOTPATCH / CC_USING_PATCHABLE_FUNCTION_ENTRY. The powerpc boot
wrapper only gets compiler_attributes.h:
arch/powerpc/boot/Makefile:
BOOTCFLAGS += -include $(srctree)/include/linux/compiler_attributes.h
and deliberately does not -include compiler_types.h (see commit
77433830ed16 ("powerpc: boot: include compiler_attributes.h")).
With CONFIG_KERNEL_XZ=y, arch/powerpc/boot/decompress.c includes
lib/decompress_unxz.c, which pulls in lib/xz/xz_dec_lzma2.c:
static __always_inline void rc_normalize(struct rc_dec *rc)
This now preprocesses to:
static inline __attribute__((__always_inline__)) notrace void rc_normalize(...)
Nothing under arch/powerpc/boot/, lib/xz/ or lib/decompress_unxz.c defines
notrace, so should decompress.o fail to compile? skiroot_defconfig sets
CONFIG_KERNEL_XZ=y. I could not compile this to confirm.
The comment at the top of compiler_attributes.h also says that attributes
which depend on a configuration option or on other attributes should be
defined elsewhere, e.g. compiler_types.h.
Would it work to leave this definition alone and add notrace to
__always_inline in compiler_types.h after notrace is defined?
Alternatively, the powerpc boot wrapper could get its own empty notrace
definition.
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
[ ... ]
> -#define inline inline __gnu_inline __inline_maybe_unused notrace
> +#define inline inline __gnu_inline __inline_maybe_unused
Can the removal of notrace here cause recursion on microblaze?
ftrace_test_recursion_trylock() also reads preempt_count():
ftrace_test_recursion_trylock()
trace_test_and_set_recursion()
trace_get_context_bit()
interrupt_context_level()
preempt_count()
On microblaze, preempt_count() reads current_thread_info()->preempt_count,
and current_thread_info() is still a plain inline:
arch/microblaze/include/asm/thread_info.h:
static inline struct thread_info *current_thread_info(void)
fs/pstore/ftrace.c is built with CC_FLAGS_FTRACE, and pstore_ftrace_call()
calls ftrace_test_recursion_trylock() on an ops without
FTRACE_OPS_FL_RECURSION. If the compiler emits an out-of-line copy of
current_thread_info() in that object, the copy now has an mcount call:
mcount -> pstore_ftrace_call() -> ftrace_test_recursion_trylock()
-> current_thread_info() -> mcount
and the recursion is unbounded because protection is not yet held.
The neighbouring microblaze irqflags helpers are already 'static inline
notrace'. The trigger needs the compiler to keep a one-instruction helper
out of line, which is unlikely, but the series applied the same standard to
the equivalent helpers on csky, mips and sh. Should current_thread_info()
on microblaze be marked notrace too?
Similarly, the riscv patch in this series marks the arch_local_irq_*()
helpers notrace because ct_idle_exit() and cpu_idle_poll() call
raw_local_irq_save()/raw_local_irq_restore()/raw_local_irq_enable() while
RCU is not watching. Both are generic code in traced files
(kernel/context_tracking.c and kernel/sched/idle.c).
Several other architectures that select HAVE_FUNCTION_TRACER still define
these helpers as plain inline, so their out-of-line copies become
traceable:
arch/arm/include/asm/irqflags.h: arch_local_irq_save/enable/disable
arch/loongarch/include/asm/irqflags.h
arch/mips/include/asm/irqflags.h
arch/csky/include/asm/irqflags.h
arch/parisc/include/asm/irqflags.h
arch/xtensa/include/asm/irqflags.h
For example:
arch/loongarch/include/asm/irqflags.h:
static inline void arch_local_irq_enable(void)
s390 noinstr entry code has a similar gap: __do_pgm_check() calls the
plain-inline set_pt_regs_flag() before irqentry_enter().
The commit message says the previous patches mark notrace "the inline
helpers that relied on inline implying notrace", but the noinstr audit
covered only arm64, powerpc and riscv. Only x86_64 has objtool noinstr
validation.
Were arm, loongarch, mips, csky, parisc, xtensa and s390 checked, for
example with a clang build as was done for arm64 and riscv? If not, should
their irqflags helpers get the same notrace treatment?
A subsystem pattern also flags the following as potentially concerning. On
x86-32, HAVE_DYNAMIC_FTRACE_WITH_ARGS is only selected for X86_64, so
ftrace_get_regs() ends up calling the generic plain-inline helper:
include/linux/ftrace.h:
static inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
{
return &arch_ftrace_regs(fregs)->regs;
}
The x86 kprobe_ftrace_handler() calls it before taking recursion
protection:
arch/x86/kernel/kprobes/ftrace.c:kprobe_ftrace_handler() {
struct pt_regs *regs = ftrace_get_regs(fregs);
...
bit = ftrace_test_recursion_trylock(ip, parent_ip);
arch/x86/kernel/kprobes/ftrace.o is built with ftrace flags, and
kprobe_ftrace_ops and kprobe_ipmodify_ops set only FTRACE_OPS_FL_SAVE_REGS
(and IPMODIFY), not FTRACE_OPS_FL_RECURSION. Once inline no longer implies
notrace, an out-of-line copy of arch_ftrace_get_regs() in that object is a
traceable function called from an ftrace callback before recursion
protection.
The helper is a single address computation and is almost certainly inlined,
and recursion would also need a kprobe placed on the out-of-line copy
itself, so this seems very unlikely in practice. Would making the generic
arch_ftrace_get_regs() __always_inline, as the arch-specific versions
already are, remove the question?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline
2026-12-01 4:22 ` [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline Song Liu
2026-12-01 5:08 ` bot+bpf-ci
@ 2026-12-01 5:17 ` sashiko-bot
2026-12-01 11:04 ` Miguel Ojeda
2 siblings, 0 replies; 39+ messages in thread
From: sashiko-bot @ 2026-12-01 5:17 UTC (permalink / raw)
To: Song Liu, linux-trace-kernel, live-patching, bpf
Cc: rostedt, mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] compiler_attributes: undefined notrace in __always_inline
breaks powerpc build
- [Medium] microblaze: missing notrace on current_thread_info() after
inline change
- [Medium] compiler_types: missing notrace on powerpc/loongarch local_t
and seqlock helpers
- [Medium] srcu: tiny SRCU helpers called by notrace paths lack notrace
after inline change
- [Medium] context_tracking: missing notrace on
!CONFIG_CONTEXT_TRACKING_USER stubs
--
commit 5cd366f4e5c4bf3ecfbc5c1521c4971b8756f081
Author: Song Liu <song@kernel.org>
compiler_types: Move notrace from inline to __always_inline
This commit removes notrace from the inline macro in
include/linux/compiler_types.h and adds it to __always_inline in
include/linux/compiler_attributes.h so that out-of-line copies of plain
inline functions can be traced and livepatched.
> diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
> index 476c4c560d174..5fdc07b3e380d 100644
> --- a/include/linux/compiler_attributes.h
> +++ b/include/linux/compiler_attributes.h
> @@ -49,10 +49,14 @@
> * to its docs (and also "warning: always_inline function might not be
> * inlinable [-Wattributes]" is emitted).
> *
> + * The compiler still emits an out-of-line copy of an __always_inline function
> + * when its address is taken or when it has external linkage. These functions
> + * are often used by code that must not be traced, so mark them notrace.
> + *
> * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute
> * clang: mentioned
> */
> -#define __always_inline inline __attribute__((__always_inline__))
> +#define __always_inline inline __attribute__((__always_inline__)) notrace
[Severity: High]
Does adding notrace to __always_inline in compiler_attributes.h break
translation units that include compiler_attributes.h without
compiler_types.h?
notrace is only defined in include/linux/compiler_types.h under
__KERNEL__. In arch/powerpc/boot/Makefile, the pre-boot wrapper is built
with -include include/linux/compiler_attributes.h and without
compiler_types.h or -D__KERNEL__. When CONFIG_KERNEL_XZ=y,
arch/powerpc/boot/decompress.c includes lib/decompress_unxz.c and
lib/xz/xz_dec_lzma2.c, where static __always_inline helpers such as
rc_normalize() expand with an undeclared notrace token and fail to
compile.
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index c5921f1390079..ea7f2a928b4da 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -230,9 +230,8 @@ struct ftrace_likely_data {
> * externally visible function. This makes extern inline behave as per gnu89
> * semantics rather than c99. This prevents multiple symbol definition errors
> * of extern inline functions at link time.
> - * A lot of inline functions can cause havoc with function tracing.
> */
> -#define inline inline __gnu_inline __inline_maybe_unused notrace
> +#define inline inline __gnu_inline __inline_maybe_unused
[Severity: Medium]
Can removing notrace from inline cause infinite ftrace recursion via
current_thread_info() on MicroBlaze?
MicroBlaze selects HAVE_FUNCTION_TRACER and uses generic preempt_count()
and preempt_count_ptr() from include/asm-generic/preempt.h, which both
call current_thread_info(). In include/linux/trace_recursion.h,
trace_test_and_set_recursion() calls trace_get_context_bit() ->
interrupt_context_level() -> preempt_count() before setting
current->trace_recursion. Because current_thread_info() in
arch/microblaze/include/asm/thread_info.h is a plain static inline
function without notrace or __always_inline, any out-of-line copy emitted
by the compiler will be instrumented by ftrace and recurse indefinitely.
[Severity: Medium]
Does dropping notrace from inline leave the PowerPC and LoongArch local_t
helpers and the 32-bit seqlock helpers traceable from notrace BPF paths?
The notrace BPF trampoline helpers (__bpf_prog_enter_recur() ->
bpf_prog_inc_misses_counter() and __bpf_prog_exit_recur() ->
__update_prog_stats()) and bpf_mem_alloc helpers (unit_alloc(),
unit_free(), unit_free_rcu()) call local_inc(), local_dec(), local_add(),
local_inc_return() and __u64_stats_update_begin() /
__u64_stats_update_end(). Both 64-bit PowerPC and LoongArch implement
BPF trampolines, but local_add(), local_add_return() and
local_sub_return() in arch/powerpc/include/asm/local.h,
local_add_return() in arch/loongarch/include/asm/local.h, and
arch_atomic64_add() / arch_atomic64_sub() in
arch/loongarch/include/asm/atomic-amo.h remain plain static inline
functions without notrace. On 32-bit builds, __u64_stats_update_begin()
and __u64_stats_update_end() also call write_seqcount_begin() and
write_seqcount_end(), whose underlying helpers in include/linux/seqlock.h
(such as do_raw_write_seqcount_begin()) are plain static inline. If the
compiler emits an out-of-line copy of any of these helpers, attaching a
BPF fentry/fexit program to it can trigger infinite trampoline recursion
or re-enter bpf_mem_alloc around c->active updates.
[Severity: Medium]
Should __srcu_read_lock(), __srcu_ptr_to_ctr() and __srcu_ctr_to_ptr() in
include/linux/srcutiny.h also be marked notrace?
With CONFIG_TINY_SRCU=y, the notrace helpers __srcu_read_lock_fast(),
__srcu_read_unlock_fast() and srcu_read_lock_notrace() call those three
functions directly:
include/linux/srcutiny.h:__srcu_read_lock_fast() {
return __srcu_ctr_to_ptr(ssp, __srcu_read_lock(ssp));
}
Because __srcu_read_lock(), __srcu_ptr_to_ctr() and __srcu_ctr_to_ptr()
are still plain static inline without notrace, any out-of-line copy
emitted by the compiler will be instrumented by ftrace when called from
tracepoints or other notrace SRCU paths.
[Severity: Medium]
Can the !CONFIG_CONTEXT_TRACKING_USER stubs in
include/linux/context_tracking.h be traced when inline loses notrace?
When CONFIG_CONTEXT_TRACKING_USER is disabled, user_enter_irqoff(),
user_exit_irqoff(), exception_enter() and exception_exit() in
include/linux/context_tracking.h are defined as plain static inline
functions without __always_inline or notrace:
include/linux/context_tracking.h:
static inline void user_enter_irqoff(void) { }
static inline void user_exit_irqoff(void) { }
static inline int exception_enter(void) { return 0; }
static inline void exception_exit(enum ctx_state prev_ctx) { }
user_exit_irqoff() and user_enter_irqoff() are called from noinstr entry
and exit paths (enter_from_user_mode() and exit_to_user_mode() in
include/linux/irq-entry-common.h) and from notrace exit paths in
arch/powerpc/kernel/interrupt.c, while exception_enter() and
exception_exit() are called from preempt_schedule_notrace() in
kernel/sched/core.c. If the compiler emits an out-of-line copy of these
stubs, it will be instrumented by ftrace and cause noinstr violations or
trace within non-traceable entry and preemption paths.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201042201.3199928-1-song@kernel.org?part=22
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline
2026-12-01 4:22 ` [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline Song Liu
2026-12-01 5:08 ` bot+bpf-ci
2026-12-01 5:17 ` sashiko-bot
@ 2026-12-01 11:04 ` Miguel Ojeda
2 siblings, 0 replies; 39+ messages in thread
From: Miguel Ojeda @ 2026-12-01 11:04 UTC (permalink / raw)
To: Song Liu
Cc: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf, rostedt,
mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
On Tue, Dec 1, 2026 at 5:29 AM Song Liu <song@kernel.org> wrote:
>
> -#define __always_inline inline __attribute__((__always_inline__))
> +#define __always_inline inline __attribute__((__always_inline__)) notrace
The LLMs point out that this would break, and yeah: this header is
supposed to stand on its own (please see the comment at the top of the
file), so if this would need to do something else (like moving
`__always_inline` out of the file, like `__preserve_most` which also
uses `notrace`).
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH v3 00/22] Move notrace from inline to __always_inline
2026-12-01 4:21 [PATCH v3 00/22] Move notrace from inline to __always_inline Song Liu
` (21 preceding siblings ...)
2026-12-01 4:22 ` [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline Song Liu
@ 2026-12-01 11:13 ` David Laight
22 siblings, 0 replies; 39+ messages in thread
From: David Laight @ 2026-12-01 11:13 UTC (permalink / raw)
To: Song Liu
Cc: linux-kernel, linux-trace-kernel, live-patching, linux-arch,
linux-arm-kernel, linuxppc-dev, linux-riscv, bpf, rostedt,
mhiramat, mark.rutland, peterz, tglx, frederic, paulmck,
catalin.marinas, will, maddy, mpe, npiggin, chleroy, pjw, palmer,
aou, alex, ast, daniel, andrii, ojeda, kernel-team
On Mon, 30 Nov 2026 20:21:39 -0800
Song Liu <song@kernel.org> wrote:
> Since commit 45959ee7aa64 ("ftrace: Do not function trace inlined
> functions"), every function marked inline is also notrace. When the
> compiler does not inline such a function, the out-of-line copy cannot
> be traced with ftrace, cannot be a BPF fentry/fexit target, and cannot
> be livepatched.
That seems entirely reasonable to me.
Anything marked inline is really expected to be inlined (even if the
compiler decides otherwise).
David
^ permalink raw reply [flat|nested] 39+ messages in thread