Patch "tracing/osnoise: Fix possible recursive locking in stop_per_cpu_kthreads" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tracing/osnoise: Fix possible recursive locking in stop_per_cpu_kthreads

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tracing-osnoise-fix-possible-recursive-locking-in-st.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 69f960a07f241c8011631b171b1b484cbc8a75ea
Author: Nico Pache <npache@xxxxxxxxxx>
Date:   Mon Sep 19 08:49:32 2022 -0600

    tracing/osnoise: Fix possible recursive locking in stop_per_cpu_kthreads
    
    [ Upstream commit 99ee9317a1305cd5626736785c8cb38b0e47686c ]
    
    There is a recursive lock on the cpu_hotplug_lock.
    
    In kernel/trace/trace_osnoise.c:<start/stop>_per_cpu_kthreads:
        - start_per_cpu_kthreads calls cpus_read_lock() and if
            start_kthreads returns a error it will call stop_per_cpu_kthreads.
        - stop_per_cpu_kthreads then calls cpus_read_lock() again causing
          deadlock.
    
    Fix this by calling cpus_read_unlock() before calling
    stop_per_cpu_kthreads. This behavior can also be seen in commit
    f46b16520a08 ("trace/hwlat: Implement the per-cpu mode").
    
    This error was noticed during the LTP ftrace-stress-test:
    
    WARNING: possible recursive locking detected
    --------------------------------------------
    sh/275006 is trying to acquire lock:
    ffffffffb02f5400 (cpu_hotplug_lock){++++}-{0:0}, at: stop_per_cpu_kthreads
    
    but task is already holding lock:
    ffffffffb02f5400 (cpu_hotplug_lock){++++}-{0:0}, at: start_per_cpu_kthreads
    
    other info that might help us debug this:
     Possible unsafe locking scenario:
    
          CPU0
          ----
     lock(cpu_hotplug_lock);
     lock(cpu_hotplug_lock);
    
     *** DEADLOCK ***
    
    May be due to missing lock nesting notation
    
    3 locks held by sh/275006:
     #0: ffff8881023f0470 (sb_writers#24){.+.+}-{0:0}, at: ksys_write
     #1: ffffffffb084f430 (trace_types_lock){+.+.}-{3:3}, at: rb_simple_write
     #2: ffffffffb02f5400 (cpu_hotplug_lock){++++}-{0:0}, at: start_per_cpu_kthreads
    
    Link: https://lkml.kernel.org/r/20220919144932.3064014-1-npache@xxxxxxxxxx
    
    Fixes: c8895e271f79 ("trace/osnoise: Support hotplug operations")
    Signed-off-by: Nico Pache <npache@xxxxxxxxxx>
    Acked-by: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 93de784ee681..6ef1164c0440 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1598,8 +1598,9 @@ static int start_per_cpu_kthreads(struct trace_array *tr)
 	for_each_cpu(cpu, current_mask) {
 		retval = start_kthread(cpu);
 		if (retval) {
+			cpus_read_unlock();
 			stop_per_cpu_kthreads();
-			break;
+			return retval;
 		}
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux