locking/pvqspinlock: Don't wait if vCPU is preempted
authorPan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Tue, 10 Jan 2017 07:56:46 +0000 (02:56 -0500)
committerIngo Molnar <mingo@kernel.org>
Thu, 12 Jan 2017 08:35:57 +0000 (09:35 +0100)
If prev node is not in running state or its vCPU is preempted, we can give
up our vCPU slices in pv_wait_node() ASAP.

Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: longman@redhat.com
Link: http://lkml.kernel.org/r/1484035006-6787-1-git-send-email-xinhui.pan@linux.vnet.ibm.com
[ Fixed typos in the changelog, removed ugly linebreak from the code. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/locking/qspinlock_paravirt.h

index e3b5520005db7fa5521510687b432f727c6715c3..e6b2f7ad3e51d4fb901be3e1d02dcea84aca0b2a 100644 (file)
@@ -263,7 +263,7 @@ pv_wait_early(struct pv_node *prev, int loop)
        if ((loop & PV_PREV_CHECK_MASK) != 0)
                return false;
 
-       return READ_ONCE(prev->state) != vcpu_running;
+       return READ_ONCE(prev->state) != vcpu_running || vcpu_is_preempted(prev->cpu);
 }
 
 /*