mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	vkuznets@redhat.com, dwmw@amazon.co.uk
Subject: Re: [PATCH 1/2] KVM: x86: reduce pvclock_gtod_sync_lock critical sections
Date: Thu, 8 Apr 2021 14:25:41 +0200	[thread overview]
Message-ID: <2abe4b19-e41e-34f9-0a3c-30812c7b719e@redhat.com> (raw)
In-Reply-To: <20210408120021.GA65315@fuller.cnet>

On 08/04/21 14:00, Marcelo Tosatti wrote:
>>
>> KVM_REQ_MCLOCK_INPROGRESS is only needed to kick running vCPUs out of the
>> execution loop;
> We do not want vcpus with different system_timestamp/tsc_timestamp
> pair:
> 
>   * To avoid that problem, do not allow visibility of distinct
>   * system_timestamp/tsc_timestamp values simultaneously: use a master
>   * copy of host monotonic time values. Update that master copy
>   * in lockstep.
> 
> So KVM_REQ_MCLOCK_INPROGRESS also ensures that no vcpu enters
> guest mode (via vcpu->requests check before VM-entry) with a
> different system_timestamp/tsc_timestamp pair.

Yes this is what KVM_REQ_MCLOCK_INPROGRESS does, but it does not have to 
be done that way.  All you really need is the IPI with KVM_REQUEST_WAIT, 
which ensures that updates happen after the vCPUs have exited guest 
mode.  You don't need to loop on vcpu->requests for example, because 
kvm_guest_time_update could just spin on pvclock_gtod_sync_lock until 
pvclock_update_vm_gtod_copy is done.

So this morning I tried protecting the kvm->arch fields for kvmclock 
using a seqcount, which is nice also because get_kvmclock_ns() does not 
have to bounce the cacheline of pvclock_gtod_sync_lock anymore.  I'll 
post it tomorrow or next week.

Paolo


  reply	other threads:[~2021-04-08 12:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 16:59 [PATCH 0/2] KVM: x86: fix lockdep splat due to Xen runstate update Paolo Bonzini
2021-03-30 16:59 ` [PATCH 1/2] KVM: x86: reduce pvclock_gtod_sync_lock critical sections Paolo Bonzini
2021-03-31  1:41   ` Wanpeng Li
2021-04-07 17:40   ` Marcelo Tosatti
2021-04-08  8:15     ` Paolo Bonzini
2021-04-08 12:00       ` Marcelo Tosatti
2021-04-08 12:25         ` Paolo Bonzini [this message]
2021-03-30 16:59 ` [PATCH 2/2] KVM: x86: disable interrupts while pvclock_gtod_sync_lock is taken Paolo Bonzini
2021-03-31  1:41   ` Wanpeng Li
2021-04-01 15:27   ` [EXTERNAL] " David Woodhouse
2021-04-01 16:36     ` Paolo Bonzini
2021-10-23 19:33   ` David Woodhouse
2021-10-23 20:29     ` [PATCH] KVM: x86: switch pvclock_gtod_sync_lock to a raw spinlock David Woodhouse
2021-10-25 12:15       ` Paolo Bonzini

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=2abe4b19-e41e-34f9-0a3c-30812c7b719e@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dwmw@amazon.co.uk \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=vkuznets@redhat.com \
    /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®