From: Crystal Wood <crwood@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
linux-trace-kernel@vger.kernel.org,
Crystal Wood <crwood@redhat.com>
Subject: [PATCH v7 03/10] tracing/osnoise: Start all eligible cpus from hotplug workfn
Date: Fri, 13 Nov 2026 00:40:56 -0600 [thread overview]
Message-ID: <20261113064103.3041704-4-crwood@redhat.com> (raw)
In-Reply-To: <20261113064103.3041704-1-crwood@redhat.com>
Previously, a start could be lost if multiple cpus get onlined
before the workqueue has a chance to run.
Signed-off-by: Crystal Wood <crwood@redhat.com>
---
v5: new patch
I have this in my notes as being a Sashiko comment, though I can't
find the source now. I wasn't able to reproduce the race given how
slow and serialized cpu hotplug operations are, but it's possible.
On the other hand, user threads detach on cpu offline with no mechanism
for reattaching (other than userspace figuring it out and reopening the
fd), and you really probably shouldn't be offlining cpus that you're
measuring with tools like this, so you could make an argument for removing
the restart mechanism entirely... it'd certainly shrink the potential bug
surface.
This also eliminates the need for the "Always check OSN_WORKLOAD" patch.
v6:
Removed the OSN_WORKLOAD check from this function, and revived the
"Always check OSN_WORKLOAD", so that start_kthread() can set osn->sampling
in the NO_OSN_WORKLOAD osnoise case
---
kernel/trace/trace_osnoise.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index b812a73fa5da..1ddeffbf437d 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2125,7 +2125,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);
@@ -2135,13 +2135,10 @@ static void osnoise_hotplug_workfn(struct work_struct *dummy)
guard(cpus_read_lock)();
guard(mutex)(&interface_lock);
- if (!cpu_online(cpu))
- 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);
+ }
}
static DECLARE_WORK(osnoise_hotplug_work, osnoise_hotplug_workfn);
@@ -2151,7 +2148,7 @@ static DECLARE_WORK(osnoise_hotplug_work, osnoise_hotplug_workfn);
*/
static int osnoise_cpu_init(unsigned int cpu)
{
- schedule_work_on(cpu, &osnoise_hotplug_work);
+ schedule_work(&osnoise_hotplug_work);
return 0;
}
--
2.56.0
next prev parent reply other threads:[~2026-11-13 6:41 UTC|newest]
Thread overview: 13+ 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 ` Crystal Wood [this message]
2026-11-13 6:51 ` [PATCH v7 03/10] tracing/osnoise: Start all eligible cpus from hotplug workfn 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 6:40 ` [PATCH v7 06/10] tracing/osnoise: Reset cleanup Crystal Wood
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=20261113064103.3041704-4-crwood@redhat.com \
--to=crwood@redhat.com \
--cc=jkacur@redhat.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.com \
/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