Patch "coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier" has been added to the 5.10-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

    coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier

to the 5.10-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:
     coresight-cpu-debug-replace-mutex-with-mutex_trylock.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 737a464239c0510c865d0941fbaaf0af8f02a901
Author: Guilherme G. Piccoli <gpiccoli@xxxxxxxxxx>
Date:   Wed Apr 27 19:49:03 2022 -0300

    coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier
    
    [ Upstream commit 1adff542d67a2ed1120955cb219bfff8a9c53f59 ]
    
    The panic notifier infrastructure executes registered callbacks when
    a panic event happens - such callbacks are executed in atomic context,
    with interrupts and preemption disabled in the running CPU and all other
    CPUs disabled. That said, mutexes in such context are not a good idea.
    
    This patch replaces a regular mutex with a mutex_trylock safer approach;
    given the nature of the mutex used in the driver, it should be pretty
    uncommon being unable to acquire such mutex in the panic path, hence
    no functional change should be observed (and if it is, that would be
    likely a deadlock with the regular mutex).
    
    Fixes: 2227b7c74634 ("coresight: add support for CPU debug module")
    Cc: Leo Yan <leo.yan@xxxxxxxxxx>
    Cc: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
    Cc: Mike Leach <mike.leach@xxxxxxxxxx>
    Cc: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
    Signed-off-by: Guilherme G. Piccoli <gpiccoli@xxxxxxxxxx>
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
    Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
    Link: https://lore.kernel.org/r/20220427224924.592546-10-gpiccoli@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 2dcf13de751f..1e98562f4287 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -379,9 +379,10 @@ static int debug_notifier_call(struct notifier_block *self,
 	int cpu;
 	struct debug_drvdata *drvdata;
 
-	mutex_lock(&debug_lock);
+	/* Bail out if we can't acquire the mutex or the functionality is off */
+	if (!mutex_trylock(&debug_lock))
+		return NOTIFY_DONE;
 
-	/* Bail out if the functionality is disabled */
 	if (!debug_enable)
 		goto skip_dump;
 
@@ -400,7 +401,7 @@ static int debug_notifier_call(struct notifier_block *self,
 
 skip_dump:
 	mutex_unlock(&debug_lock);
-	return 0;
+	return NOTIFY_DONE;
 }
 
 static struct notifier_block debug_notifier = {



[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