Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
@ 2026-06-29  9:58 Martin Weiss
  2026-06-29 10:47 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Weiss @ 2026-06-29  9:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Martin Weiss, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	linux-trace-kernel

Replace per-task counters with per-cpu increments to avoid race
conditions in the branch profiler fast path.

Fixes FIXME about atomicity.

Signed-off-by: Martin Weiss <Martin.weiss2410@gmail.com>
---
 kernel/trace/trace_branch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index d8e97ad798f0..960bcb3d7dbf 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -213,11 +213,11 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 	 */
 	trace_likely_condition(f, val, expect);
 
-	/* FIXME: Make this atomic! */
+	/* use per-cpu counters to avoid contention */
 	if (val == expect)
-		f->data.correct++;
+		this_cpu_inc(f->data.correct);
 	else
-		f->data.incorrect++;
+		this_cpu_inc(f->data.incorrect);
 
 	user_access_restore(flags);
 }
-- 
2.54.0


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

end of thread, other threads:[~2026-06-29 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29  9:58 [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats Martin Weiss
2026-06-29 10:47 ` Steven Rostedt

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