[PATCH v2 06/16] u64_stats: Mark the update helpers used by BPF notrace
From: Song Liu
Date: Thu Oct 22 2026 - 21:14:48 EST
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@xxxxxxxxxx>
---
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.0-Meta