locking/rtmutex: Fix incorrect condition in rtmutex_spin_on_owner()
authorZqiang <qiang1.zhang@intel.com>
Fri, 17 Dec 2021 07:42:07 +0000 (15:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Dec 2021 08:32:48 +0000 (09:32 +0100)
commit 8f556a326c93213927e683fc32bbf5be1b62540a upstream.

Optimistic spinning needs to be terminated when the spinning waiter is not
longer the top waiter on the lock, but the condition is negated. It
terminates if the waiter is the top waiter, which is defeating the whole
purpose.

Fixes: c3123c431447 ("locking/rtmutex: Dont dereference waiter lockless")
Signed-off-by: Zqiang <qiang1.zhang@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20211217074207.77425-1-qiang1.zhang@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/locking/rtmutex.c

index 6bb116c559b4a0a1d4052c7feccc88d21eefb556..ea5a701ab240854f28ca3da5244e7aa4aee8c90f 100644 (file)
@@ -1373,7 +1373,7 @@ static bool rtmutex_spin_on_owner(struct rt_mutex_base *lock,
                 *  - the VCPU on which owner runs is preempted
                 */
                if (!owner->on_cpu || need_resched() ||
-                   rt_mutex_waiter_is_top_waiter(lock, waiter) ||
+                   !rt_mutex_waiter_is_top_waiter(lock, waiter) ||
                    vcpu_is_preempted(task_cpu(owner))) {
                        res = false;
                        break;