Skip to content

Commit 85f03ca

Browse files
mu001999gregkh
authored andcommitted
rtmutex: Drop rt_mutex::wait_lock before scheduling
commit d33d260 upstream. rt_mutex_handle_deadlock() is called with rt_mutex::wait_lock held. In the good case it returns with the lock held and in the deadlock case it emits a warning and goes into an endless scheduling loop with the lock held, which triggers the 'scheduling in atomic' warning. Unlock rt_mutex::wait_lock in the dead lock case before issuing the warning and dropping into the schedule for ever loop. [ tglx: Moved unlock before the WARN(), removed the pointless comment, massaged changelog, added Fixes tag ] Fixes: 3d5c934 ("rtmutex: Handle deadlock detection smarter") Signed-off-by: Roland Xu <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/ME0P300MB063599BEF0743B8FA339C2CECC802@ME0P300MB0635.AUSP300.PROD.OUTLOOK.COM Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0b46b4a commit 85f03ca

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kernel/locking/rtmutex.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,7 @@ static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock,
16241624
}
16251625

16261626
static void __sched rt_mutex_handle_deadlock(int res, int detect_deadlock,
1627+
struct rt_mutex_base *lock,
16271628
struct rt_mutex_waiter *w)
16281629
{
16291630
/*
@@ -1636,10 +1637,10 @@ static void __sched rt_mutex_handle_deadlock(int res, int detect_deadlock,
16361637
if (build_ww_mutex() && w->ww_ctx)
16371638
return;
16381639

1639-
/*
1640-
* Yell loudly and stop the task right here.
1641-
*/
1640+
raw_spin_unlock_irq(&lock->wait_lock);
1641+
16421642
WARN(1, "rtmutex deadlock detected\n");
1643+
16431644
while (1) {
16441645
set_current_state(TASK_INTERRUPTIBLE);
16451646
schedule();
@@ -1693,7 +1694,7 @@ static int __sched __rt_mutex_slowlock(struct rt_mutex_base *lock,
16931694
} else {
16941695
__set_current_state(TASK_RUNNING);
16951696
remove_waiter(lock, waiter);
1696-
rt_mutex_handle_deadlock(ret, chwalk, waiter);
1697+
rt_mutex_handle_deadlock(ret, chwalk, lock, waiter);
16971698
}
16981699

16991700
/*

0 commit comments

Comments
 (0)