From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Davidlohr Bueso <dave@stgolabs.net>,
mingo@kernel.org, peterz@infradead.org
Cc: npiggin@gmail.com, paulmck@linux.vnet.ibm.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Cornelia Huck <cohuck@redhat.com>
Subject: Re: [PATCH v2 0/7] swait: Introduce and use swq_has_sleeper()
Date: Tue, 19 Sep 2017 10:25:11 +0200 [thread overview]
Message-ID: <21d360c5-d98e-896b-ee3d-7fff203f3366@de.ibm.com> (raw)
In-Reply-To: <ddde4bc5-ba8c-b7ec-717e-5655c8cbe15d@redhat.com>
On 09/15/2017 01:53 PM, Paolo Bonzini wrote:
> On 13/09/2017 22:08, Davidlohr Bueso wrote:
>> The following patches fix and/or justify (in baby steps) some of the
>> callers. The main exception is s390, which I didn't follow how ->valid_wakeup
>> can get hoisted as kvm_vcpu_block does not use that in the wait loop.
>
> valid_wakeup is just an optimization, so it's not a problem.
>
> There seems to be always an atomic_or or set_bit before
> kvm_s390_vcpu_wakeup is called (except kvm_s390_idle_wakeup which has no
> store at all and doesn't need any serialization). So my suggestion is
> to add an smp__mb_after_atomic in kvm_s390_vcpu_wakeup; I'll let the
> s390 guys do it.
I will queue something like this
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index a832ad0..44239b5 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -1074,6 +1074,12 @@ void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu)
* in kvm_vcpu_block without having the waitqueue set (polling)
*/
vcpu->valid_wakeup = true;
+ /*
+ * This is mostly to document, that the read in swait_active could
+ * be moved before other stores, leading to subtle races.
+ * All current users do not store or use an atomic like update
+ */
+ __smp_mb__after_atomic();
if (swait_active(&vcpu->wq)) {
/*
* The vcpu gave up the cpu voluntarily, mark it as a good
but I am asking myself if it is "safer" to make this function use swq_has_sleepers
in case we add in a distant future another user to kvm_s390_vcpu_wakeup that does
use a normal store and everybody has already forgotten this?
prev parent reply other threads:[~2017-09-19 8:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-13 20:08 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 ` [PATCH 4/7] kvm,x86: Fix apf_task_wake_one() wq serialization Davidlohr Bueso
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 [this message]
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=21d360c5-d98e-896b-ee3d-7fff203f3366@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=dave@stgolabs.net \
--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
all inboxes | Powered by JetHome®