diff options
author | Peter Zijlstra <peterz@infradead.org> | 2018-03-27 08:14:38 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2018-03-28 17:01:30 -0400 |
commit | c28d62cf52d791ba5f6db7ce525ed06b86291c82 (patch) | |
tree | 683f0b9f5b8faa613a46da023b1b7a4bd204c33e /kernel/locking/rtmutex.c | |
parent | ac605bee0bfab40fd5d11964705e907d2d5a32de (diff) |
locking/rtmutex: Handle non enqueued waiters gracefully in remove_waiter()
In -RT task_blocks_on_rt_mutex() may return with -EAGAIN due to
(->pi_blocked_on == PI_WAKEUP_INPROGRESS) before it added itself as a
waiter. In such a case remove_waiter() must not be called because without a
waiter it will trigger the BUG_ON() statement.
This was initially reported by Yimin Deng. Thomas Gleixner fixed it then
with an explicit check for waiters before calling remove_waiter().
Instead of an explicit NULL check before calling rt_mutex_top_waiter() make
the function return NULL if there are no waiters. With that fixed the now
pointless NULL check is removed from rt_mutex_slowlock().
Reported-and-debugged-by: Yimin Deng <yimin11.deng@gmail.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/CAAh1qt=DCL9aUXNxanP5BKtiPp3m+qj4yB+gDohhXPVFCxWwzg@mail.gmail.com
Link: https://lkml.kernel.org/r/20180327121438.sss7hxg3crqy4ecd@linutronix.de
Diffstat (limited to 'kernel/locking/rtmutex.c')
-rw-r--r-- | kernel/locking/rtmutex.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 940633c63254..4f014be7a4b8 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c | |||
@@ -1268,8 +1268,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, | |||
1268 | 1268 | ||
1269 | if (unlikely(ret)) { | 1269 | if (unlikely(ret)) { |
1270 | __set_current_state(TASK_RUNNING); | 1270 | __set_current_state(TASK_RUNNING); |
1271 | if (rt_mutex_has_waiters(lock)) | 1271 | remove_waiter(lock, &waiter); |
1272 | remove_waiter(lock, &waiter); | ||
1273 | rt_mutex_handle_deadlock(ret, chwalk, &waiter); | 1272 | rt_mutex_handle_deadlock(ret, chwalk, &waiter); |
1274 | } | 1273 | } |
1275 | 1274 | ||