Linux SPARSE checker discussions
 help / color / mirror / Atom feed
* [PATCH] tracing: make ftrace_branch_data counters atomic
@ 2026-05-05 13:25 Khaled Saleh
  0 siblings, 0 replies; only message in thread
From: Khaled Saleh @ 2026-05-05 13:25 UTC (permalink / raw)
  To: Chris Li; +Cc: linux-sparse, linux-kernel, khaled.saleh.req

Replace unsigned long counters with local_t and update all
increments and reads to use local_inc() and local_read().

This fixes potential race conditions in branch statistics
updates across CPUs.

Signed-off-by: Khaled Saleh <khaled.saleh.req@gmail.com>
---
 include/linux/compiler.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 1a506c54c060..39b89544adc7 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -66,8 +66,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 			.line = __LINE__,		\
 		};					\
 	(cond) ?					\
-		(local_inc(&__if_trace.miss_hit[1]),1) :\
-		(local_inc(&__if_trace.miss_hit[0]),0);	\
+		(local_inc(&__if_trace.miss_hit[1]), 1) :\
+		(local_inc(&__if_trace.miss_hit[0]), 0);	\
 })
 
 #endif /* CONFIG_PROFILE_ALL_BRANCHES */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-05 13:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 13:25 [PATCH] tracing: make ftrace_branch_data counters atomic Khaled Saleh

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