Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1554898 > unrolled thread

[PATCH v2] locking/pvqspinlock: Wait early if vCPU is preempted

Started byPan Xinhui <xinhui.pan@linux.vnet.ibm.com>
First post2017-01-10 04:10 +0100
Last post2017-01-12 11:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] locking/pvqspinlock: Wait early if vCPU is preempted Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2017-01-10 04:10 +0100
    [tip:locking/core] locking/pvqspinlock: Don't wait if vCPU is  preempted tip-bot for Pan Xinhui <tipbot@zytor.com> - 2017-01-12 11:10 +0100

#1554898 — [PATCH v2] locking/pvqspinlock: Wait early if vCPU is preempted

FromPan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Date2017-01-10 04:10 +0100
Subject[PATCH v2] locking/pvqspinlock: Wait early if vCPU is preempted
Message-ID<sXUYV-4ej-11@gated-at.bofh.it>
If prev node is not in runnig state or its vCPU is preempted, we can give
up our vCPU slices ASAP in pv_wait_node. After commit d9345c65eb79
("sched/core: Introduce the vcpu_is_preempted(cpu) interface") kernel
has knowledge of one vCPU is running or not.

Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
---
v2:
  rewrite the commit message as Ingo pointed out the mistake.
---
 kernel/locking/qspinlock_paravirt.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h
index e3b5520..48648dc 100644
--- a/kernel/locking/qspinlock_paravirt.h
+++ b/kernel/locking/qspinlock_paravirt.h
@@ -263,7 +263,8 @@ 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);
 }
 
 /*
-- 
2.4.11

[toc] | [next] | [standalone]


#1557269 — [tip:locking/core] locking/pvqspinlock: Don't wait if vCPU is preempted

Fromtip-bot for Pan Xinhui <tipbot@zytor.com>
Date2017-01-12 11:10 +0100
Subject[tip:locking/core] locking/pvqspinlock: Don't wait if vCPU is preempted
Message-ID<sYKuu-2GC-17@gated-at.bofh.it>
In reply to#1554898
Commit-ID:  75437bb304b20a2b350b9a8e9f9238d5e24e12ba
Gitweb:     http://git.kernel.org/tip/75437bb304b20a2b350b9a8e9f9238d5e24e12ba
Author:     Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
AuthorDate: Tue, 10 Jan 2017 02:56:46 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 12 Jan 2017 09:35:57 +0100

locking/pvqspinlock: Don't wait if vCPU is preempted

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h
index e3b5520..e6b2f7a 100644
--- a/kernel/locking/qspinlock_paravirt.h
+++ b/kernel/locking/qspinlock_paravirt.h
@@ -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);
 }
 
 /*

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web