From: Steven Rostedt <rostedt@goodmis.org>
To: nanshuaibo <nanshuaibo811@163.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Chris Li <sparse@chrisli.org>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-sparse@vger.kernel.org
Subject: Re: [PATCH] tracing: Make branch profiler counters atomic
Date: Wed, 30 Sep 2026 15:59:01 -0400 [thread overview]
Message-ID: <20260930155901.6cb8f18f@fedora> (raw)
In-Reply-To: <20260930030728.1144418-1-nanshuaibo811@163.com>
On Wed, 30 Sep 2026 11:07:28 +0800
nanshuaibo <nanshuaibo811@163.com> wrote:
> The branch profiler updates its static counters from arbitrary contexts. Concurrent updates can race and lose counts. KCSAN reports a data race between ftrace_likely_update() invocations.
>
> Use relaxed compiler atomic operations for the counters. The profiler metadata is defined in compiler_types.h, before the kernel atomic API is available. The counters do not order accesses to other data.
>
> Also use atomic loads when reading the counters for tracefs output and sorting, so readers do not race with atomic writers.
>
> Tested on x86_64 QEMU/KVM with KCSAN and CONFIG_PROFILE_ANNOTATED_BRANCHES=y. The baseline reports the race in ftrace_likely_update(); it is not reported after this change.
FYI, Change log lines should be capped at 76 characters except for cut
and pasted output.
That said, NAK to the patch. The branch profile is a best effort and
known to be racy. It's to find where branches are most traveled, Their
exact numbers are not meaningful. No need for atomic operations.
-- Steve
prev parent reply other threads:[~2026-09-30 19:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 3:07 nanshuaibo
2026-09-30 19:59 ` Steven Rostedt [this message]
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=20260930155901.6cb8f18f@fedora \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=nanshuaibo811@163.com \
--cc=sparse@chrisli.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®