Linux Trace Kernel
 help / color / mirror / Atom feed
From: Andy Chiu <andy.chiu@sifive.com>
To: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org
Cc: bristot@kernel.org, mhiramat@kernel.org,
	mathieu.desnoyers@efficios.com, Andy Chiu <andy.chiu@sifive.com>
Subject: [v1] trace/osnoise: prevent osnoise hotplog worker running in UNBOUND workqueue
Date: Thu,  1 Feb 2024 14:18:45 +0800	[thread overview]
Message-ID: <20240201061845.3154289-1-andy.chiu@sifive.com> (raw)

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


             reply	other threads:[~2024-02-01  6:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01  6:18 Andy Chiu [this message]
2024-02-01 14:36 ` [v1] trace/osnoise: prevent osnoise hotplog worker running in UNBOUND workqueue Steven Rostedt

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=20240201061845.3154289-1-andy.chiu@sifive.com \
    --to=andy.chiu@sifive.com \
    --cc=bristot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /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