From: Khaled Saleh <khaled.saleh.req@gmail.com>
To: rostedt@goodmis.org
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
linux-kernel@vger.kernel.org,
Khaled Saleh <khaled.saleh.req@gmail.com>
Subject: [PATCH] trace: make ftrace likely counters atomic
Date: Tue, 23 Dec 2025 22:37:14 +0200 [thread overview]
Message-ID: <20251223203715.10954-1-khaled.saleh.req@gmail.com> (raw)
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
next reply other threads:[~2025-12-23 20:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 20:37 Khaled Saleh [this message]
2025-12-23 21:56 ` Steven Rostedt
2025-12-24 12:30 ` kernel test robot
2025-12-24 13:44 ` 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=20251223203715.10954-1-khaled.saleh.req@gmail.com \
--to=khaled.saleh.req@gmail.com \
--cc=linux-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®