From: Paolo Bonzini <pbonzini@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>,
Denis Plotnikov <dplotnikov@virtuozzo.com>,
Radim Krcmar <rkrcmar@redhat.com>, kvm list <kvm@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
lkml <linux-kernel@vger.kernel.org>,
x86@kernel.org, rkagan@virtuozzo.com, den@virtuozzo.com,
Marcelo Tosatti <mtosatti@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v4 00/10] make L2's kvm-clock stable, get rid of pvclock_gtod_copy in KVM
Date: Wed, 23 Aug 2017 18:02:03 +0200 [thread overview]
Message-ID: <ea24b142-21b2-4462-b2be-7716933f1745@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1708230908330.1821@nanos>
On 23/08/2017 14:45, Thomas Gleixner wrote:
> So the real question is how to ensure that:
>
> 1) None of the update functions is in progress
>
> 2) The update is propagated via the existing mechanisms
>
> The whole live migration magic is orchestrated by qemu and the kernel. So
> it's reasonably simple to ensure that.
There is no orchestration whatsoever between QEMU and the host kernel,
much less between anything and the guest. QEMU just sends ioctls. The
complex part is above QEMU, just because you have to make sure that the
destination sets up networking and everything else just like the source,
but as far as QEMU is concerned live migration is as simple as
stop_guest()
get_guest_state()
write_data_to_socket()
read_data_from_socket()
set_guest_state()
resume_guest()
and as far as KVM is concerned, it's as simple as
get a signal, KVM_RUN exits
KVM_GET_REGS and a bunch more ioctls
KVM_SET_REGS and a bunch more ioctls
KVM_SET_KVMCLOCK triggers kvmclock update
ioctl(KVM_RUN)
process KVM_REQ_CLOCK_UPDATE
enter the guest
Adding interrupts and all that is much, much more complicated than just
reusing code that runs all the time (albeit only on hosts with impaired
TSC) and needs no special case at all.
> The reason why you do that is to support live migration of VMs to hosts
> with a different TSC frequency. And for exactly that particular corner case
> the whole conversion magic is implemented and now you need even more duct
> tape to make it work with nested VMs.
The point of the first part of this series is to _remove_ the duct tape
and actually make KVM use generic timekeeper services, namely
ktime_get_snapshot. If you look at patches 1-2-3-4-5-7 the delta is
-120 lines of code, without any nested virtualization stuff.
More duct tape would have been just:
- if (pvclock_gtod_data.clock.vclock_mode != VCLOCK_TSC)
+ mode = READ_ONCE(pvclock_gtod_data.clock.vclock_mode);
+ if (mode != VCLOCK_TSC &&
+ (mode != VCLOCK_PVCLOCK || !pvclock_nested_virt_magic())
return false;
- return do_realtime(ts, cycle_now) == VCLOCK_TSC;
+ switch (mode) {
+ case VCLOCK_TSC:
+ return do_realtime_tsc(ts, cycle_now);
+ case VCLOCK_PVCLOCK:
+ return do_realtime_pvclock(ts, cycle_now);
+ }
Nested virtualization does need a clocksource change notifier on top,
but we can cross that bridge later. Maybe Denis can post just those
patches to begin with.
Paolo
> So now for the nested KVM case. If you follow the above scheme then this
> becomes really simple:
>
> 1) The TSC frequency is merily propagated to the L2 guest. It's the
> same as the L1 guest TSC frequency. No magic voodoo required.
>
> 2) Migration of a L2 guest to a different L1 guest follows the
> same scheme as above
>
> 3) Migration of a L2 guest to a physcial host follows the same scheme as
> above - no idea whether that's supported at all
>
> 4) Migration of a L1 guest with a embedded L2 guest is not rocket science
> either. The above needs some extra code which propagates the time
> keeper freeze to L2 and then when L1 resumes, the updated frequency
> data is propagated to L2 and L2 resumed along with it.
>
> You don't need any timestamp snapshot magic and voodoo callbacks. All you
> need is a proper mechanism to update the timekeeper.
>
> I might be missing something really important as usual. If so, I'm happy to
> be educated.
next prev parent reply other threads:[~2017-08-23 16:02 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 14:38 Denis Plotnikov
2017-08-02 14:38 ` [PATCH v4 01/10] timekeeper: introduce extended clocksource reading callback Denis Plotnikov
2017-08-02 17:08 ` John Stultz
2017-08-02 17:21 ` Paolo Bonzini
2017-08-02 14:38 ` [PATCH v4 02/10] timekeeper: introduce boot field in system_time_snapshot Denis Plotnikov
2017-08-02 14:38 ` [PATCH v4 03/10] timekeeper: use the extended reading function on snapshot acquiring Denis Plotnikov
2017-08-02 14:38 ` [PATCH v4 04/10] tsc: implement the extended tsc reading function Denis Plotnikov
2017-08-02 14:38 ` [PATCH v4 05/10] KVM: x86: switch to masterclock update using timekeeper functionality Denis Plotnikov
2017-08-02 14:38 ` [PATCH v4 06/10] timekeeper: add clocksource change notifier Denis Plotnikov
2017-08-02 14:38 ` [PATCH v4 07/10] KVM: x86: remove not used pvclock_gtod_copy Denis Plotnikov
2017-08-02 23:21 ` Marcelo Tosatti
2017-08-03 12:35 ` Paolo Bonzini
2017-08-11 22:59 ` Marcelo Tosatti
2017-08-02 14:38 ` [PATCH v4 08/10] pvclock: add parameters to store stamp data in pvclock reading function Denis Plotnikov
2017-08-02 14:38 ` [PATCH v4 09/10] pvclock: add clocksource change notification on changing of tsc stable bit Denis Plotnikov
2017-08-02 23:36 ` Marcelo Tosatti
2017-08-02 14:38 ` [PATCH v4 10/10] kvmclock: implement the extended reading function Denis Plotnikov
2017-08-02 16:10 ` [PATCH v4 00/10] make L2's kvm-clock stable, get rid of pvclock_gtod_copy in KVM Paolo Bonzini
2017-08-02 16:49 ` John Stultz
2017-08-02 17:11 ` Paolo Bonzini
2017-08-21 8:40 ` Denis Plotnikov
2017-08-22 19:50 ` John Stultz
2017-08-22 21:00 ` Paolo Bonzini
2017-08-23 12:45 ` Thomas Gleixner
2017-08-23 16:02 ` Paolo Bonzini [this message]
2017-08-24 8:00 ` Paolo Bonzini
2017-08-28 7:28 ` Denis Plotnikov
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=ea24b142-21b2-4462-b2be-7716933f1745@redhat.com \
--to=pbonzini@redhat.com \
--cc=den@virtuozzo.com \
--cc=dplotnikov@virtuozzo.com \
--cc=hpa@zytor.com \
--cc=john.stultz@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mtosatti@redhat.com \
--cc=peterz@infradead.org \
--cc=rkagan@virtuozzo.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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®