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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
From 11e632bdd63b66d70c365424a1ceb502cb0c02ef Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 28 Oct 2020 18:55:27 +0100
Subject: [PATCH 066/323] lib/test_lockup: Minimum fix to get it compiled on
PREEMPT_RT
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.10/older/patches-5.10.204-rt100.tar.xz
On PREEMPT_RT the locks are quite different so they can't be tested as
it is done below. The alternative is test for the waitlock within
rtmutex.
This is the bare minim to get it compiled. Problems which exists on
PREEMP_RT:
- none of the locks (spinlock_t, rwlock_t, mutex_t, rw_semaphore) may be
acquired with disabled preemption or interrupts.
If I read the code correct the it is possible to acquire a mutex with
disabled interrupts.
I don't know how to obtain a lock pointer. Technically they are not
exported to userland.
- memory can not be allocated with disabled premption or interrupts even
with GFP_ATOMIC.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
lib/test_lockup.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/test_lockup.c b/lib/test_lockup.c
index 78a630bbd03d..d27a80502204 100644
--- a/lib/test_lockup.c
+++ b/lib/test_lockup.c
@@ -485,6 +485,21 @@ static int __init test_lockup_init(void)
return -EINVAL;
#ifdef CONFIG_DEBUG_SPINLOCK
+#ifdef CONFIG_PREEMPT_RT
+ if (test_magic(lock_spinlock_ptr,
+ offsetof(spinlock_t, lock.wait_lock.magic),
+ SPINLOCK_MAGIC) ||
+ test_magic(lock_rwlock_ptr,
+ offsetof(rwlock_t, rtmutex.wait_lock.magic),
+ SPINLOCK_MAGIC) ||
+ test_magic(lock_mutex_ptr,
+ offsetof(struct mutex, lock.wait_lock.magic),
+ SPINLOCK_MAGIC) ||
+ test_magic(lock_rwsem_ptr,
+ offsetof(struct rw_semaphore, rtmutex.wait_lock.magic),
+ SPINLOCK_MAGIC))
+ return -EINVAL;
+#else
if (test_magic(lock_spinlock_ptr,
offsetof(spinlock_t, rlock.magic),
SPINLOCK_MAGIC) ||
@@ -498,6 +513,7 @@ static int __init test_lockup_init(void)
offsetof(struct rw_semaphore, wait_lock.magic),
SPINLOCK_MAGIC))
return -EINVAL;
+#endif
#endif
if ((wait_state != TASK_RUNNING ||
--
2.43.0
|