From: sashiko-bot@kernel.org
To: "Crystal Wood" <crwood@redhat.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/8] tracing/osnoise: Start all eligible cpus from hotplug workfn
Date: Sat, 24 Oct 2026 02:03:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-183507@kernel.org> (raw)
In-Reply-To: <20261024015614.3095251-3-crwood@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tracing/osnoise: osnoise_hotplug_workfn() skips sampling when !OSN_WORKLOAD
--
commit 4bedb2088cbb62deefeaad638901751b0c1e9f6d
Author: Crystal Wood <crwood@redhat.com>
tracing/osnoise: Start all eligible cpus from hotplug workfn
This commit updates osnoise_hotplug_workfn() to iterate over all online CPUs
in osnoise_cpumask and start their kthreads when scheduled from
osnoise_cpu_init(), avoiding lost starts if multiple CPUs come online before
the work item runs.
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index aa764ae13047e..29fa4150b26c0 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -2123,7 +2123,7 @@ static int start_per_cpu_kthreads(void)
> #ifdef CONFIG_HOTPLUG_CPU
> static void osnoise_hotplug_workfn(struct work_struct *dummy)
> {
> - unsigned int cpu = smp_processor_id();
> + unsigned int cpu;
>
> guard(mutex)(&trace_types_lock);
>
> @@ -2133,13 +2133,13 @@ static void osnoise_hotplug_workfn(struct work_struct *dummy)
> guard(cpus_read_lock)();
> guard(mutex)(&interface_lock);
>
> - if (!cpu_online(cpu))
> + if (!test_bit(OSN_WORKLOAD, &osnoise_options))
> return;
>
> - if (!cpumask_test_cpu(cpu, &osnoise_cpumask))
> - return;
> -
> - start_kthread(cpu);
> + for_each_online_cpu(cpu) {
> + if (cpumask_test_cpu(cpu, &osnoise_cpumask))
> + start_kthread(cpu);
> + }
> }
[Severity: Medium]
Does returning early in osnoise_hotplug_workfn() whenever OSN_WORKLOAD is
clear leave per-CPU sampling disabled on newly onlined CPUs when running the
osnoise tracer with NO_OSNOISE_WORKLOAD?
When timerlat is disabled (i.e. the osnoise tracer is active) and
OSN_WORKLOAD is clear, start_kthread() is responsible for enabling sampling
on the CPU without spawning a kthread:
kernel/trace/trace_osnoise.c:start_kthread() {
...
if (timerlat_enabled()) {
snprintf(comm, 24, "timerlat/%d", cpu);
main = timerlat_main;
} else {
/* if no workload, just return */
if (!test_bit(OSN_WORKLOAD, &osnoise_options)) {
cpu_osn_var(cpu)->sampling = true;
barrier();
return 0;
}
snprintf(comm, 24, "osnoise/%d", cpu);
}
...
}
And when a CPU goes offline via osnoise_cpu_die() -> stop_kthread(),
sampling is cleared on that CPU:
kernel/trace/trace_osnoise.c:stop_kthread() {
...
} else {
/* if no workload, just return */
if (!test_bit(OSN_WORKLOAD, &osnoise_options)) {
/*
* This is set in the osnoise tracer case.
*/
cpu_osn_var(cpu)->sampling = false;
barrier();
}
}
}
In start_per_cpu_kthreads(), the early return for !OSN_WORKLOAD is gated on
timerlat_enabled():
kernel/trace/trace_osnoise.c:start_per_cpu_kthreads() {
...
if (!test_bit(OSN_WORKLOAD, &osnoise_options)) {
if (timerlat_enabled())
return 0;
}
...
}
Should osnoise_hotplug_workfn() likewise check timerlat_enabled() before
returning early on !test_bit(OSN_WORKLOAD, &osnoise_options) (or let
start_kthread() handle the !OSN_WORKLOAD case) so that
cpu_osn_var(cpu)->sampling is set to true when a CPU in osnoise_cpumask comes
online?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261024015614.3095251-2-crwood@redhat.com?part=2
next prev parent reply other threads:[~2026-10-24 2:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 1:56 [PATCH v5 0/9] tracing/osnoise: Synchronization fixes Crystal Wood
2026-10-24 1:56 ` [PATCH v5 1/8] tracing/osnoise: Variable cleanup Crystal Wood
2026-10-24 1:56 ` [PATCH v5 2/8] tracing/osnoise: Start all eligible cpus from hotplug workfn Crystal Wood
2026-10-24 2:03 ` sashiko-bot [this message]
2026-10-24 1:56 ` [PATCH v5 3/8] tracing/osnoise: Hold a ref on osn->kthread Crystal Wood
2026-10-24 1:56 ` [PATCH v5 4/8] tracing/osnoise: Per-cpu mutexes and fd detachment Crystal Wood
2026-10-24 2:17 ` sashiko-bot
2026-10-24 1:56 ` [PATCH v5 5/8] tracing/osnoise: kthreads: Verify CPU after migrate_disable() Crystal Wood
2026-10-24 1:56 ` [PATCH v5 6/8] tracing/osnoise: Take trace_types_lock in timerlat_fd_open Crystal Wood
2026-10-24 1:56 ` [PATCH v5 7/8] tracing/osnoise: Print taint message for timerlat Crystal Wood
2026-10-24 1:56 ` [PATCH v5 8/8] 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-183507@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