Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Crystal Wood" <crwood@redhat.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v7 06/10] tracing/osnoise: Reset cleanup
Date: Fri, 13 Nov 2026 07:20:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-212339@kernel.org> (raw)
In-Reply-To: <20261113064103.3041704-7-crwood@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] tracing/osnoise: CPU hotplug race in timerlat_fd_open() leaves
  stale fdd
--

commit 25ee38a6983ff50cb9227e203eed4ba8758cefa4
Author: Crystal Wood <crwood@redhat.com>

tracing/osnoise: Reset cleanup

This commit reorganizes per-CPU and global state resets in the osnoise and
timerlat tracers when stopping kthreads, detaching file descriptors, or
restarting the tracer.

> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index e61f57230eefb..8db0697b69e4a 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
[ ... ]
> @@ -408,6 +380,39 @@ static struct osnoise_data {
>  #endif
>  };
>  
> +static inline void osn_reset_cpu(int cpu)
> +{
> +	struct osnoise_variables *osn = cpu_osn_var(cpu);
> +
> +	WARN_ON_ONCE(osn->kthread);
> +	WARN_ON_ONCE(osn->fdd);
> +
> +	osn->sampling = false;
> +	osn->pid = 0;
> +	tlat_reset_cpu(cpu);
> +}
> +
> +/*
> + * osn_var_reset - Reset non-per-cpu state, and check for stale data
> + */
> +static inline void osn_var_reset(void)
> +{
> +	struct osnoise_variables *osn;
> +	int cpu;
> +
> +	for_each_possible_cpu(cpu) {
> +		osn = cpu_osn_var(cpu);
> +
> +		WARN_ON_ONCE(osn->kthread);
> +		WARN_ON_ONCE(osn->fdd);
> +		WARN_ON_ONCE(osn->sampling);
> +		memset(&osn->zero, 0, sizeof(osn->zero));
> +	}
> +
> +	tlat_var_reset();
> +	osnoise_data.tainted = false;
> +}

[Severity: Low]
Can osn_var_reset() hit WARN_ON_ONCE(osn->fdd) if timerlat_fd_open() races
with CPU hotplug takedown?

timerlat_fd_open() disables migration without holding cpus_read_lock() or
checking whether the CPU is still active under osn_var->lock.  If a task
pinned to CPU0 enters timerlat_fd_open() just as CPU0 is being offlined,
balance_push() skips the task while migration is disabled, allowing
osnoise_cpu_die() to run before timerlat_fd_open() attaches osn_var->fdd:

CPU0 (user task)                  CPU0 (cpuhp/0)
timerlat_fd_open()
  migrate_disable()
                                  sched_cpu_deactivate()
                                  ...
                                  osnoise_cpu_die()
                                    stop_kthread(0)
                                  sched_cpu_wait_empty()
                                    balance_hotplug_wait()
  mutex_lock(&osn_var->lock)
  osn_var->fdd = fdd
  tlat->thread = current
  mutex_unlock(&osn_var->lock)
  migrate_enable()
                                  <takedown completes>

When the tracer is later stopped and restarted, stop_per_cpu_kthreads()
only iterates over online CPUs and misses offline CPU0, so osn_var_reset()
iterating over for_each_possible_cpu() will trigger WARN_ON_ONCE(osn->fdd)
with stale fdd and tlat->thread state left attached on the offline CPU.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113064103.3041704-1-crwood@redhat.com?part=6

  reply	other threads:[~2026-11-13  7:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  6:40 [PATCH v7 00/10] tracing/osnoise: Synchronization fixes Crystal Wood
2026-11-13  6:40 ` [PATCH v7 01/10] tracing/osnoise: Variable cleanup Crystal Wood
2026-11-13  6:40 ` [PATCH v7 02/10] tracing/osnoise: start_kthread: Always check OSN_WORKLOAD Crystal Wood
2026-11-13  6:40 ` [PATCH v7 03/10] tracing/osnoise: Start all eligible cpus from hotplug workfn Crystal Wood
2026-11-13  6:51   ` sashiko-bot
2026-11-13  6:40 ` [PATCH v7 04/10] tracing/osnoise: Hold a ref on osn->kthread Crystal Wood
2026-11-13  6:40 ` [PATCH v7 05/10] tracing/osnoise: Per-cpu mutexes and fd detachment Crystal Wood
2026-11-13  7:14   ` sashiko-bot
2026-11-13  6:40 ` [PATCH v7 06/10] tracing/osnoise: Reset cleanup Crystal Wood
2026-11-13  7:20   ` sashiko-bot [this message]
2026-11-13  6:41 ` [PATCH v7 07/10] tracing/osnoise: kthreads: Verify CPU after migrate_disable() Crystal Wood
2026-11-13  6:41 ` [PATCH v7 08/10] tracing/osnoise: Take trace_types_lock in timerlat_fd_open Crystal Wood
2026-11-13  6:41 ` [PATCH v7 09/10] tracing/osnoise: Print taint message for timerlat Crystal Wood
2026-11-13  6:41 ` [PATCH v7 10/10] tracing/osnoise: Refuse timerlat fd open if tracer inactive Crystal Wood
2026-11-13  6:55   ` sashiko-bot

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-212339@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