From: Martin Weiss <martin.githubacc@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Martin Weiss <Martin.weiss2410@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org
Subject: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
Date: Mon, 29 Jun 2026 16:58:38 +0700 [thread overview]
Message-ID: <20260629095838.601926-1-Martin.weiss2410@gmail.com> (raw)
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
next reply other threads:[~2026-06-29 9:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 9:58 Martin Weiss [this message]
2026-06-29 10:47 ` [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats Steven Rostedt
2026-08-06 16:53 ` kernel test robot
2026-08-06 19:38 ` kernel test robot
2026-08-06 20:04 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260629095838.601926-1-Martin.weiss2410@gmail.com \
--to=martin.githubacc@gmail.com \
--cc=Martin.weiss2410@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.