mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
tracing/timerlat: Fix duplicated kthread creation due to CPU online/offline
commit0bb0a5c12eupstream. osnoise_hotplug_workfn() is the asynchronous online callback for "trace/osnoise:online". It may be congested when a CPU goes online and offline repeatedly and is invoked for multiple times after a certain online. This will lead to kthread leak and timer corruption. Add a check in start_kthread() to prevent this situation. Cc: stable@vger.kernel.org Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20240924094515.3561410-2-liwei391@huawei.com Fixes:c8895e271f("trace/osnoise: Support hotplug operations") Signed-off-by: Wei Li <liwei391@huawei.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a0d9c0cd58
commit
3670051acb
@@ -2006,6 +2006,10 @@ static int start_kthread(unsigned int cpu)
|
|||||||
void *main = osnoise_main;
|
void *main = osnoise_main;
|
||||||
char comm[24];
|
char comm[24];
|
||||||
|
|
||||||
|
/* Do not start a new thread if it is already running */
|
||||||
|
if (per_cpu(per_cpu_osnoise_var, cpu).kthread)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (timerlat_enabled()) {
|
if (timerlat_enabled()) {
|
||||||
snprintf(comm, 24, "timerlat/%d", cpu);
|
snprintf(comm, 24, "timerlat/%d", cpu);
|
||||||
main = timerlat_main;
|
main = timerlat_main;
|
||||||
@@ -2060,11 +2064,10 @@ static int start_per_cpu_kthreads(void)
|
|||||||
if (cpumask_test_and_clear_cpu(cpu, &kthread_cpumask)) {
|
if (cpumask_test_and_clear_cpu(cpu, &kthread_cpumask)) {
|
||||||
struct task_struct *kthread;
|
struct task_struct *kthread;
|
||||||
|
|
||||||
kthread = per_cpu(per_cpu_osnoise_var, cpu).kthread;
|
kthread = xchg_relaxed(&(per_cpu(per_cpu_osnoise_var, cpu).kthread), NULL);
|
||||||
if (!WARN_ON(!kthread))
|
if (!WARN_ON(!kthread))
|
||||||
kthread_stop(kthread);
|
kthread_stop(kthread);
|
||||||
}
|
}
|
||||||
per_cpu(per_cpu_osnoise_var, cpu).kthread = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_cpu(cpu, current_mask) {
|
for_each_cpu(cpu, current_mask) {
|
||||||
|
|||||||
Reference in New Issue
Block a user