* [v1] trace/osnoise: prevent osnoise hotplog worker running in UNBOUND workqueue
@ 2024-02-01 6:18 Andy Chiu
2024-02-01 14:36 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Andy Chiu @ 2024-02-01 6:18 UTC (permalink / raw)
To: rostedt, linux-trace-kernel
Cc: bristot, mhiramat, mathieu.desnoyers, Andy Chiu
smp_processor_id() should be called with migration disabled. This mean
we may safely call smp_processor_id() in percpu thread. However, this is
not the case if the work is (re-)queued into unbound workqueue, during
cpu-hotplog. So, detect and return early if this work happens to run on
an unbound wq.
Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
---
kernel/trace/trace_osnoise.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index bd0d01d00fb9..cf7f716d3f35 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2068,7 +2068,12 @@ 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;
+
+ if (!is_percpu_thread())
+ return;
+
+ cpu = smp_processor_id();
mutex_lock(&trace_types_lock);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [v1] trace/osnoise: prevent osnoise hotplog worker running in UNBOUND workqueue
2024-02-01 6:18 [v1] trace/osnoise: prevent osnoise hotplog worker running in UNBOUND workqueue Andy Chiu
@ 2024-02-01 14:36 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2024-02-01 14:36 UTC (permalink / raw)
To: Andy Chiu, bristot; +Cc: linux-trace-kernel, mhiramat, mathieu.desnoyers
On Thu, 1 Feb 2024 14:18:45 +0800
Andy Chiu <andy.chiu@sifive.com> wrote:
> smp_processor_id() should be called with migration disabled. This mean
> we may safely call smp_processor_id() in percpu thread. However, this is
> not the case if the work is (re-)queued into unbound workqueue, during
> cpu-hotplog. So, detect and return early if this work happens to run on
> an unbound wq.
>
Yeah I triggered this too, but never made it a priority to fix.
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> ---
> kernel/trace/trace_osnoise.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index bd0d01d00fb9..cf7f716d3f35 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -2068,7 +2068,12 @@ 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;
> +
> + if (!is_percpu_thread())
> + return;
But doesn't this then fail to register the CPU thread?
I wonder if this has some race with schedule_work_on() and hotplug?
-- Steve
> +
> + cpu = smp_processor_id();
>
> mutex_lock(&trace_types_lock);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-01 14:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 6:18 [v1] trace/osnoise: prevent osnoise hotplog worker running in UNBOUND workqueue Andy Chiu
2024-02-01 14:36 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox