From: Davidlohr Bueso <dave@stgolabs.net>
To: mingo@kernel.org, peterz@infradead.org, pbonzini@redhat.com
Cc: npiggin@gmail.com, paulmck@linux.vnet.ibm.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
dave@stgolabs.net, Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH 4/7] kvm,x86: Fix apf_task_wake_one() wq serialization
Date: Wed, 13 Sep 2017 13:08:21 -0700 [thread overview]
Message-ID: <20170913200824.28067-5-dave@stgolabs.net> (raw)
In-Reply-To: <20170913200824.28067-1-dave@stgolabs.net>
During code inspection, the following potential race was seen:
CPU0 CPU1
kvm_async_pf_task_wait apf_task_wake_one
[L] swait_active(&n->wq)
[S] prepare_to_swait(&n.wq)
[L] if (!hlist_unhahed(&n.link))
schedule() [S] hlist_del_init(&n->link);
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
next prev parent reply other threads:[~2017-09-13 20:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-13 20:08 [PATCH v2 0/7] swait: Introduce and use swq_has_sleeper() Davidlohr Bueso
2017-09-13 20:08 ` [PATCH 1/7] sched/wait: Add swq_has_sleepers() Davidlohr Bueso
2017-09-13 20:08 ` [PATCH 2/7] kvm,async_pf: Use swq_has_sleepers() Davidlohr Bueso
2017-09-13 20:08 ` [PATCH 3/7] kvm,lapic: Justify use of swait_activate() Davidlohr Bueso
2017-09-15 11:47 ` Paolo Bonzini
2017-09-13 20:08 ` Davidlohr Bueso [this message]
2017-09-13 20:08 ` [PATCH 5/7] kvm: Serialize wq active checks in kvm_vcpu_wake_up() Davidlohr Bueso
2017-09-13 20:08 ` [PATCH 6/7] kvm,powerpc: Serialize wq active checks in ops->vcpu_kick Davidlohr Bueso
2017-09-13 20:08 ` [PATCH 7/7] kvm,mips: Fix potential swait_active() races Davidlohr Bueso
2017-09-13 20:35 ` Paolo Bonzini
2017-09-13 22:22 ` Davidlohr Bueso
2017-09-15 11:33 ` Paolo Bonzini
2017-09-15 11:53 ` [PATCH v2 0/7] swait: Introduce and use swq_has_sleeper() Paolo Bonzini
2017-09-19 8:25 ` Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170913200824.28067-5-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=npiggin@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome