mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: mingo@redhat.com, peterz@infradead.org, pbonzini@redhat.com
Cc: npiggin@gmail.com, paulmck@linux.vnet.ibm.com, dave@stgolabs.net,
	linux-kernel@vger.kernel.org
Subject: [PATCH 0/6] swait: Introduce and use swq_has_sleepers
Date: Tue,  5 Sep 2017 12:00:16 -0700	[thread overview]
Message-ID: <20170905190022.1474-1-dave@stgolabs.net> (raw)

Hi.

Recently[1] Nick mentioned that a lot of swait_active() callers look fishy.
This is because it inherited bad habits from regular waitqueues. Other than rcu,
kvm is one of the main callers, which I audited.

The following patches fix and/or justify (in baby steps) some of the
callers. Note that s390 and mips are other offenders, but I have no
idea if it can actually occur -- ie:

CPU0					CPU1
kvm_vcpu_block				kvm_mips_comparecount_func

  [S] prepare_to_swait(&vcpu->wq)					
					  [L] swait_active(&vcpu->wq)
					  [S] queue_timer_int(vcpu)

  [L] if (!kvm_vcpu_has_pending_timer(vcpu))
         schedule()


[1] swait: add missing barrier to swake_up:  https://lkml.org/lkml/2017/9/1/165

Thanks!

Davidlohr Bueso (6):
  sched/wait: Add swq_has_sleepers()
  kvm,async_pf: Use swq_has_sleepers()
  kvm,lapic: Justify use of swait_activate()
  x86,kvm: Fix apf_task_wake_one() serialization
  kvm: Serialize wq active checks in kvm_vcpu_wake_up()
  kvm,powerpc: Serialize wq active checks in ops->vcpu_kick

 arch/powerpc/kvm/book3s_hv.c |  2 +-
 arch/x86/kernel/kvm.c        |  2 +-
 arch/x86/kvm/lapic.c         |  6 +++++
 include/linux/swait.h        | 57 ++++++++++++++++++++++++++++++++++++++++++--
 virt/kvm/async_pf.c          |  6 +----
 virt/kvm/kvm_main.c          |  2 +-
 6 files changed, 65 insertions(+), 10 deletions(-)

-- 
2.12.0

             reply	other threads:[~2017-09-05 19:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05 19:00 Davidlohr Bueso [this message]
2017-09-05 19:00 ` [PATCH 1/6] sched/wait: Add swq_has_sleepers() Davidlohr Bueso
2017-10-11  8:27   ` Peter Zijlstra
2017-10-11 11:21     ` Paolo Bonzini
2017-10-11 11:29       ` Peter Zijlstra
2017-09-05 19:00 ` [PATCH 2/6] kvm,async_pf: Use swq_has_sleepers() Davidlohr Bueso
2017-09-05 19:00 ` [PATCH 3/6] kvm,lapic: Justify use of swait_activate() Davidlohr Bueso
2017-09-05 19:00 ` [PATCH 4/6] x86,kvm: Fix apf_task_wake_one() serialization Davidlohr Bueso
2017-09-10  9:20   ` Paolo Bonzini
2017-09-10  9:24     ` Paolo Bonzini
2017-10-12  8:23       ` Peter Zijlstra
2017-09-05 19:00 ` [PATCH 5/6] kvm: Serialize wq active checks in kvm_vcpu_wake_up() Davidlohr Bueso
2017-09-05 19:00 ` [PATCH 6/6] kvm,powerpc: Serialize wq active checks in ops->vcpu_kick Davidlohr Bueso

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=20170905190022.1474-1-dave@stgolabs.net \
    --to=dave@stgolabs.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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®