The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] trace: make ftrace likely counters atomic
@ 2025-12-23 20:37 Khaled Saleh
  2025-12-23 21:56 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Khaled Saleh @ 2025-12-23 20:37 UTC (permalink / raw)
  To: rostedt; +Cc: mhiramat, mathieu.desnoyers, linux-kernel, Khaled Saleh

The correct and incorrect counters in ftrace_likely_update() are
updated without synchronization and may race on SMP systems.

Convert them to atomic counters to address the existing FIXME
without changing behavior.

Signed-off-by: Khaled Saleh <khaled.saleh.req@gmail.com>
---
 kernel/trace/trace_branch.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index 6809b370e991..31a144fa975f 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -215,10 +215,11 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 	trace_likely_condition(f, val, expect);
 
 	/* FIXME: Make this atomic! */
-	if (val == expect)
-		f->data.correct++;
-	else
-		f->data.incorrect++;
+	if (val == expect) {
+		atomic_long_inc(&f->data.correct);
+	} else {
+	atomic_long_inc(&f->data.incorrect);
+	}
 
 	user_access_restore(flags);
 }
-- 
2.43.0


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

end of thread, other threads:[~2025-12-24 13:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 20:37 [PATCH] trace: make ftrace likely counters atomic Khaled Saleh
2025-12-23 21:56 ` Steven Rostedt
2025-12-24 12:30 ` kernel test robot
2025-12-24 13:44 ` kernel test robot

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