login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
August
»
25
Re: [KVM timekeeping 25/35] Add clock catchup mode
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Glauber Costa
Subject:
Re: [KVM timekeeping 25/35] Add clock catchup mode
Date: Wednesday, August 25, 2010 - 4:38 pm
On Wed, Aug 25, 2010 at 07:01:34PM -0300, Marcelo Tosatti wrote:
quoted text
> On Wed, Aug 25, 2010 at 10:48:20AM -1000, Zachary Amsden wrote: > > On 08/25/2010 07:27 AM, Marcelo Tosatti wrote: > > >On Thu, Aug 19, 2010 at 10:07:39PM -1000, Zachary Amsden wrote: > > >>Make the clock update handler handle generic clock synchronization, > > >>not just KVM clock. We add a catchup mode which keeps passthrough > > >>TSC in line with absolute guest TSC. > > >> > > >>Signed-off-by: Zachary Amsden<zamsden@redhat.com> > > >>--- > > >> arch/x86/include/asm/kvm_host.h | 1 + > > >> arch/x86/kvm/x86.c | 55 ++++++++++++++++++++++++++------------ > > >> 2 files changed, 38 insertions(+), 18 deletions(-) > > >> > > >> kvm_x86_ops->vcpu_load(vcpu, cpu); > > >>- if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) { > > >>+ if (unlikely(vcpu->cpu != cpu) || vcpu->arch.tsc_rebase) { > > >> /* Make sure TSC doesn't go backwards */ > > >> s64 tsc_delta = !vcpu->arch.last_host_tsc ? 0 : > > >> native_read_tsc() - vcpu->arch.last_host_tsc; > > >> if (tsc_delta< 0) > > >> mark_tsc_unstable("KVM discovered backwards TSC"); > > >>- if (check_tsc_unstable()) > > >>+ if (check_tsc_unstable()) { > > >> kvm_x86_ops->adjust_tsc_offset(vcpu, -tsc_delta); > > >>- kvm_migrate_timers(vcpu); > > >>+ kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); > > >>+ } > > >>+ if (vcpu->cpu != cpu) > > >>+ kvm_migrate_timers(vcpu); > > >> vcpu->cpu = cpu; > > >>+ vcpu->arch.tsc_rebase = 0; > > >> } > > >> } > > >> > > >>@@ -1947,6 +1961,12 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) > > >> kvm_x86_ops->vcpu_put(vcpu); > > >> kvm_put_guest_fpu(vcpu); > > >> vcpu->arch.last_host_tsc = native_read_tsc(); > > >>+ > > >>+ /* For unstable TSC, force compensation and catchup on next CPU */ > > >>+ if (check_tsc_unstable()) { > > >>+ vcpu->arch.tsc_rebase = 1; > > >>+ kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); > > >>+ } > > >The mix between catchup,trap versus stable,unstable TSC is confusing and > > >difficult to grasp. Can you please introduce all the infrastructure > > >first, then control usage of them in centralized places? Examples: > > > > > >+static void kvm_update_tsc_trapping(struct kvm *kvm) > > >+{ > > >+ int trap, i; > > >+ struct kvm_vcpu *vcpu; > > >+ > > >+ trap = check_tsc_unstable()&& atomic_read(&kvm->online_vcpus)> 1; > > >+ kvm_for_each_vcpu(i, vcpu, kvm) > > >+ kvm_x86_ops->set_tsc_trap(vcpu, trap&& !vcpu->arch.time_page); > > >+} > > > > > >+ /* For unstable TSC, force compensation and catchup on next CPU */ > > >+ if (check_tsc_unstable()) { > > >+ vcpu->arch.tsc_rebase = 1; > > >+ kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); > > >+ } > > > > > > > > >kvm_guest_time_update is becoming very confusing too. I understand this > > >is due to the many cases its dealing with, but please make it as simple > > >as possible. > > > > I tried to comment as best as I could. I think the whole > > "kvm_update_tsc_trapping" thing is probably a poor design choice. > > It works, but it's thoroughly unintelligible right now without > > spending some days figuring out why. > > > > I'll rework the tail series of patches to try to make them more clear. > > > > >+ /* > > >+ * If we are trapping and no longer need to, use catchup to > > >+ * ensure passthrough TSC will not be less than trapped TSC > > >+ */ > > >+ if (vcpu->tsc_mode == TSC_MODE_PASSTHROUGH&& vcpu->tsc_trapping&& > > >+ ((this_tsc_khz<= v->kvm->arch.virtual_tsc_khz || kvmclock))) { > > >+ catchup = 1; > > > > > >What, TSC trapping with kvmclock enabled? > > > > Transitioning to use of kvmclock after a cold boot means we may have > > been trapping and now we will not be. > > > > >For both catchup and trapping the resolution of the host clock is > > >important, as Glauber commented for kvmclock. Can you comment on the > > >problems that arrive from a low res clock for both modes? > > > > > >Similarly for catchup mode, the effect of exit frequency. No need for > > >any guarantees? > > > > The scheduler will do something to get an IRQ at whatever resolution > > it uses for it's timeslice. That guarantees an exit per timeslice, > > so we'll never be behind by more than one slice while scheduling. > > While not scheduling, we're dormant anyway, waiting on either an IRQ > > or shared memory variable change. Local timers could end up behind > > when dormant. > > > > We may need a hack to accelerate firing of timers in such a case, or > > perhaps bounds on when to use catchup mode and when to not. > > What about emulating rdtsc with low res clock? > > "The RDTSC instruction reads the time-stamp counter and is guaranteed to > return a monotonically increasing unique value whenever executed, except > for a 64-bit counter wraparound." >
This is bad semantics, IMHO. It is a totally different behaviour than the one guest users would expect. --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[KVM timekeeping 25/35] Add clock catchup mode
, Zachary Amsden
, (Fri Aug 20, 1:07 am)
Re: [KVM timekeeping 25/35] Add clock catchup mode
, Marcelo Tosatti
, (Wed Aug 25, 10:27 am)
Re: [KVM timekeeping 25/35] Add clock catchup mode
, Zachary Amsden
, (Wed Aug 25, 1:48 pm)
Re: [KVM timekeeping 25/35] Add clock catchup mode
, Marcelo Tosatti
, (Wed Aug 25, 3:01 pm)
Re: [KVM timekeeping 25/35] Add clock catchup mode
, Glauber Costa
, (Wed Aug 25, 4:38 pm)
Re: [KVM timekeeping 25/35] Add clock catchup mode
, Zachary Amsden
, (Wed Aug 25, 5:17 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Fortier,Vincent [Montreal]
2.6.21.5 june 30th to july 1st date hang?
Jeff Dike
[ PATCH 2/6 ] UML - Formatting fixes around os_{read_write}_file callers
Liam Girdwood
[PATCH 07/13] regulator: regulator test harness
Oleg Nesterov
Re: Getting the new RxRPC patches upstream
Stefan Seyfried
Re: 2.6.19-rc5: grub is much slower resuming from suspend-to-disk than in 2.6.18
linux-netdev
:
Arnaud Ebalard
Re: [REGRESSION,BISECTED] MIPv6 support broken by f4f914b58019f0
Jan Engelhardt
Re: [PATCH iptables] extension: add xt_cpu match
Jarek Poplawski
Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock().
Sebastian Andrzej Siewior
[PATCH 8/8] net/emergency: remove locking from reycling pool if emergncy pools are...
David Miller
Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2
git
:
Jakub Narebski
Re: git on MacOSX and files with decomposed utf-8 file names
Brandon Casey
Re: Thunderbird and patches (was Re: [PATCH v2] Enable setting attach as the def...
Christian Couder
[PATCH 1/3] rev-parse: add test script for "--verify"
Ramkumar Ramachandra
Re: [GSoC update] git-remote-svn: The final one
Junio C Hamano
Re: git-rm isn't the inverse action of git-add
openbsd-misc
:
Joachim Schipper
Re: UVC Webcams
Florin Andrei
SOLVED [was: firewall is very slow, something's wrong]
Todd Alan Smith
Re: Microsoft gets the Most Secure Operating Systems award
Neal Hogan
Re: Need Advice: Thinkpad T60 or T61?
Sam Fourman Jr.
Re: Real men don't attack straw men
git-commits-head
:
Linux Kernel Mailing List
ACPI: Disable ARB_DISABLE on platforms where it is not needed
Linux Kernel Mailing List
m68knommu: add read_barrier_depends() and irqs_disabled_flags()
Linux Kernel Mailing List
[MTD] Add mtd panic_write function pointer
Linux Kernel Mailing List
[ARM] pxa: remove duplicate select statements from Kconfig
Linux Kernel Mailing List
mlx4_core: Don't read reserved fields in mlx4_QUERY_ADAPTER()
Colocation donated by:
Syndicate