Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Martin Weiss <martin.githubacc@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Martin Weiss <Martin.weiss2410@gmail.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
Date: Mon, 29 Jun 2026 06:47:21 -0400	[thread overview]
Message-ID: <20260629064721.1ffd75fb@gandalf.local.home> (raw)
In-Reply-To: <20260629095838.601926-1-Martin.weiss2410@gmail.com>

On Mon, 29 Jun 2026 16:58:38 +0700
Martin Weiss <martin.githubacc@gmail.com> wrote:

> 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);

I don't think this does what you think it does.

Did you even test this? I'm guessing it would blow up in some fantastic
ways.

NAK.

-- Steve


>  
>  	user_access_restore(flags);
>  }


      reply	other threads:[~2026-06-29 10:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 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=20260629064721.1ffd75fb@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=Martin.weiss2410@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=martin.githubacc@gmail.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.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