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


Groups > linux.kernel > #1734732

Re: [PATCH v2 0/7] swait: Introduce and use swq_has_sleeper()

From Christian Borntraeger <borntraeger@de.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 0/7] swait: Introduce and use swq_has_sleeper()
Date 2017-09-19 10:30 +0200
Message-ID <urm4N-1KA-7@gated-at.bofh.it> (permalink)
References <upm8V-3w4-9@gated-at.bofh.it> <upXrP-2iY-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



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?

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


Thread

[PATCH v2 0/7] swait: Introduce and use swq_has_sleeper() Davidlohr Bueso <dave@stgolabs.net> - 2017-09-13 22:10 +0200
  [PATCH 7/7] kvm,mips: Fix potential swait_active() races Davidlohr Bueso <dave@stgolabs.net> - 2017-09-13 22:10 +0200
    Re: [PATCH 7/7] kvm,mips: Fix potential swait_active() races Paolo Bonzini <pbonzini@redhat.com> - 2017-09-13 22:40 +0200
      Re: [PATCH 7/7] kvm,mips: Fix potential swait_active() races Davidlohr Bueso <dave@stgolabs.net> - 2017-09-14 00:30 +0200
        Re: [PATCH 7/7] kvm,mips: Fix potential swait_active() races Paolo Bonzini <pbonzini@redhat.com> - 2017-09-15 13:40 +0200
  [PATCH 6/7] kvm,powerpc: Serialize wq active checks in ops->vcpu_kick Davidlohr Bueso <dave@stgolabs.net> - 2017-09-13 22:10 +0200
  [PATCH 4/7] kvm,x86: Fix apf_task_wake_one() wq serialization Davidlohr Bueso <dave@stgolabs.net> - 2017-09-13 22:20 +0200
  [PATCH 3/7] kvm,lapic: Justify use of swait_activate() Davidlohr Bueso <dave@stgolabs.net> - 2017-09-13 22:20 +0200
    Re: [PATCH 3/7] kvm,lapic: Justify use of swait_activate() Paolo Bonzini <pbonzini@redhat.com> - 2017-09-15 13:50 +0200
  [PATCH 2/7] kvm,async_pf: Use swq_has_sleepers() Davidlohr Bueso <dave@stgolabs.net> - 2017-09-13 22:20 +0200
  Re: [PATCH v2 0/7] swait: Introduce and use swq_has_sleeper() Paolo Bonzini <pbonzini@redhat.com> - 2017-09-15 14:00 +0200
    Re: [PATCH v2 0/7] swait: Introduce and use swq_has_sleeper() Christian Borntraeger <borntraeger@de.ibm.com> - 2017-09-19 10:30 +0200

csiph-web