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


Groups > linux.kernel > #1726945

[PATCH 4/6] x86,kvm: Fix apf_task_wake_one() serialization

From Davidlohr Bueso <dave@stgolabs.net>
Newsgroups linux.kernel
Subject [PATCH 4/6] x86,kvm: Fix apf_task_wake_one() serialization
Date 2017-09-05 21:10 +0200
Message-ID <umrow-6Vh-71@gated-at.bofh.it> (permalink)
References <umrou-6Vh-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


During code inspection, the following potential race was seen:

CPU0   	    		    	     	CPU1
kvm_async_pf_task_wait			apf_task_wake_one
  [S] prepare_to_swait(&n.wq)
					  [L] swait_active(&n->wq)
					  [S] hlist_del_init(&n->link);
  [L] if (!hlist_unhahed(&n.link))
	schedule()

Properly serialize swait_active() checks such that a wakeup is
not missed.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 arch/x86/kernel/kvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 874827b0d7ca..aa60a08b65b1 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -180,7 +180,7 @@ static void apf_task_wake_one(struct kvm_task_sleep_node *n)
 	hlist_del_init(&n->link);
 	if (n->halted)
 		smp_send_reschedule(n->cpu);
-	else if (swait_active(&n->wq))
+	else if (swq_has_sleeper(&n->wq))
 		swake_up(&n->wq);
 }
 
-- 
2.12.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 4/6] x86,kvm: Fix apf_task_wake_one() serialization Davidlohr Bueso <dave@stgolabs.net> - 2017-09-05 21:10 +0200
  Re: [PATCH 4/6] x86,kvm: Fix apf_task_wake_one() serialization Paolo Bonzini <pbonzini@redhat.com> - 2017-09-10 11:30 +0200
  Re: [PATCH 4/6] x86,kvm: Fix apf_task_wake_one() serialization Paolo Bonzini <pbonzini@redhat.com> - 2017-09-10 11:30 +0200

csiph-web