[PATCH 05/13] rtmutex/rwlock: preserve state like a sleeping lock

From: Tom Zanussi
Date: Mon Apr 08 2019 - 15:15:33 EST


4.14.109-rt58-rc1 stable review patch.
If anyone has any objections, please let me know.

------------------

From: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>

[ Upstream commit 4a1bf9e54a013d55ab156cb462c68054cb52ee2d ]

The rwlock is spinning while acquiring a lock. Therefore it must become
a sleeping lock on RT and preserve its task state while sleeping and
waiting for the lock to become available.

Reported-by: Joe Korty <Joe.Korty@xxxxxxxxxxxxxxxxx>
Cc: stable-rt@xxxxxxxxxxxxxxx
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Signed-off-by: Tom Zanussi <tom.zanussi@xxxxxxxxxxxxxxx>
---
kernel/locking/rwlock-rt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/rwlock-rt.c b/kernel/locking/rwlock-rt.c
index f2e155b2c4a8..c3b91205161c 100644
--- a/kernel/locking/rwlock-rt.c
+++ b/kernel/locking/rwlock-rt.c
@@ -128,7 +128,7 @@ void __sched __read_rt_lock(struct rt_rw_lock *lock)
* That would put Reader1 behind the writer waiting on
* Reader2 to call read_unlock() which might be unbound.
*/
- rt_mutex_init_waiter(&waiter, false);
+ rt_mutex_init_waiter(&waiter, true);
rt_spin_lock_slowlock_locked(m, &waiter, flags);
/*
* The slowlock() above is guaranteed to return with the rtmutex is
--
2.14.1