blob: 4786df44e9fc00d725c080d93ece3d78d6b77794 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
From 798399a61f1200c1fc8bd90626fa50bceea494d5 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 2 Dec 2015 11:34:07 +0100
Subject: [PATCH 171/323] locking/rtmutex: Allow rt_mutex_trylock() on
PREEMPT_RT
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.10/older/patches-5.10.215-rt107.tar.xz
Non PREEMPT_RT kernel can deadlock on rt_mutex_trylock() in softirq
context.
On PREEMPT_RT the softirq context is handled in thread context. This
avoids the deadlock in the slow path and PI-boosting will be done on the
correct thread.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
kernel/locking/rtmutex.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 35cdbbb5daa93..1bf7a04688c54 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1884,7 +1884,11 @@ int __sched __rt_mutex_futex_trylock(struct rt_mutex *lock)
int __sched __rt_mutex_trylock(struct rt_mutex *lock)
{
+#ifdef CONFIG_PREEMPT_RT
+ if (WARN_ON_ONCE(in_irq() || in_nmi()))
+#else
if (WARN_ON_ONCE(in_irq() || in_nmi() || in_serving_softirq()))
+#endif
return 0;
return rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock);
--
2.44.0
|