From: sashiko-bot@kernel.org
To: "Crystal Wood" <crwood@redhat.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v4 7/9] tracing/osnoise: Split out per-cpu variable resets
Date: Wed, 14 Oct 2026 22:21:44 +0000 [thread overview]
Message-ID: <sashiko-outbox-171968@kernel.org> (raw)
In-Reply-To: <20261014220759.908839-8-crwood@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tracing: Data race between osn_reset_cpu memset and NMI handler
--
commit 01cd6ef0e171fa1526bc0f401fc2072fe284c438
Author: Crystal Wood <crwood@redhat.com>
tracing/osnoise: Split out per-cpu variable resets
This commit splits out per-cpu variable resets by resetting the per-cpu
state every time a kthread is stopped or an fd is detached. It uses a bulk
memset to clear the zero struct_group in osn_reset_cpu() to avoid zeroing
individual fields explicitly.
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
[ ... ]
> @@ -409,6 +379,36 @@ static struct osnoise_data {
> #endif
> };
>
> +static inline void osn_reset_cpu(int cpu)
> +{
> + struct osnoise_variables *osn = cpu_osn_var(cpu);
> +
> + WARN_ON(osn->kthread);
> + WARN_ON(osn->fdd);
> + memset(&osn->zero, 0, sizeof(osn->zero));
[Severity: High]
Does this non-atomic memset race with the NMI handler
trace_osnoise_callback()?
If osn_reset_cpu() is invoked from a remote CPU while the osnoise tracer is
still globally active (for example, via timerlat_fd_release() or
stop_kthread()), it will concurrently overwrite osn->zero on the target CPU.
The target CPU's NMI handler could be running concurrently and might bypass
the sampling check if it reads it before or during the zeroing. This would
lead to it executing operations like:
kernel/trace/trace_osnoise.c:trace_osnoise_callback() {
...
local_inc(&osn_var->int_counter);
...
}
A concurrent memset from another CPU destroys the target CPU's local_t
guarantees and atomic operations, corrupting per-CPU state via torn reads
and writes. This replaces what was previously a safe single-byte
osn_var->sampling = false assignment with a bulk memset over the entire
state.
> + tlat_reset_cpu(cpu);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014220759.908839-1-crwood@redhat.com?part=7
next prev parent reply other threads:[~2026-10-14 22:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 22:07 [PATCH v4 0/9] tracing/osnoise: Synchronization fixes Crystal Wood
2026-10-14 22:07 ` [PATCH v4 1/9] tracing/osnoise: Variable cleanup Crystal Wood
2026-10-14 22:07 ` [PATCH v4 2/9] tracing/osnoise: Hold a ref on osn->kthread Crystal Wood
2026-10-14 22:07 ` [PATCH v4 3/9] tracing/osnoise: Per-cpu mutexes and fd detachment Crystal Wood
2026-10-14 22:07 ` [PATCH v4 4/9] tracing/osnoise: kthreads: Verify CPU after migrate_disable() Crystal Wood
2026-10-14 22:07 ` [PATCH v4 5/9] tracing/osnoise: start_kthread: Always check OSN_WORKLOAD Crystal Wood
2026-10-14 22:07 ` [PATCH v4 6/9] tracing/osnoise: Take trace_types_lock in timerlat_fd_open Crystal Wood
2026-10-14 22:07 ` [PATCH v4 7/9] tracing/osnoise: Split out per-cpu variable resets Crystal Wood
2026-10-14 22:21 ` sashiko-bot [this message]
2026-10-14 22:07 ` [PATCH v4 8/9] tracing/osnoise: Print taint message for timerlat Crystal Wood
2026-10-14 22:07 ` [PATCH v4 9/9] tracing/osnoise: Refuse timerlat fd open if tracer inactive Crystal Wood
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=sashiko-outbox-171968@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=crwood@redhat.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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