From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Denis Plotnikov <dplotnikov@virtuozzo.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, den@virtuozzo.com,
rkagan@virtuozzo.com
Subject: Re: [RFC PATCH 1/2] timekeeper: change interface of clocksource reding functions
Date: Mon, 10 Jul 2017 15:00:53 +0200 [thread overview]
Message-ID: <20170710130050.GD30880@potion> (raw)
In-Reply-To: <1498647301-130851-2-git-send-email-dplotnikov@virtuozzo.com>
2017-06-28 13:55+0300, Denis Plotnikov:
> When using timekeepeing API in some cases it is useful to return
> timestamp value used along with the time calculated to use that
> timestamp value for other purpuses (e.g. in KVM master clock timestamp)
Makes sense. What I don't like about this interface is the TSC centric
approach in a code that isn't even x86 specific -- other architectures
might have a similar counter they'd like to use.
Could we get it a bit more generic?
At least returning the type of the clock and its counter value.
(kvmclock is a bit problematic for the generic solution, because it is
TSC based, but should pass through the kvmclock value if we were going
to make it clean ...)
---
Actually, we might be overengineering it. With the master clock we have
now, I'm thinking that the gtod is not crucial and we could as well be
using something like:
static bool kvm_get_time_and_clockread(s64 *kernel_ns, u64 *cycle_now)
{
local_irq_save(flags);
*cycle_now = rdtsc();
*kernel_ns = ktime_get_boot_ns();
local_irq_restore(flags);
return todo_tsc_hardware_is_good_enough();
}
because kvmclock is shifted when master clock is recomputed or disabled,
so it should never happen. (And if it happens, then this bit of
imprecision doesn't matter much.)
The host doesn't need to use TSC either, because master clock uses TSC
frequency that differs from boot_ns -- we only need to be sure that the
TSC hardware doesn't change its frequency.
The small delta introduced with this (rdtsc <-> ktime_get_boot_ns) is
the same that the guest would see if we didn't enable master clock.
kvmclock updates are then normally using the same cycle_now/kernel_ns
pair to remain stable.
next prev parent reply other threads:[~2017-07-10 13:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-28 10:54 [RFC PATCH 0/2] make L2 kvm-clock stable Denis Plotnikov
2017-06-28 10:55 ` [RFC PATCH 1/2] timekeeper: change interface of clocksource reding functions Denis Plotnikov
2017-07-10 13:00 ` Radim Krčmář [this message]
2017-07-21 14:00 ` Denis Plotnikov
2017-06-28 10:55 ` [RFC PATCH 2/2] KVM: x86: add support of kvm-clock stablity in L2 Denis Plotnikov
2017-07-10 13:25 ` Radim Krčmář
2017-07-10 13:32 ` Radim Krčmář
2017-07-21 14:01 ` Denis Plotnikov
2017-07-03 16:12 ` [RFC PATCH 0/2] make L2 kvm-clock stable Denis Plotnikov
2017-07-03 16:27 ` Paolo Bonzini
2017-07-10 7:56 ` 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=20170710130050.GD30880@potion \
--to=rkrcmar@redhat.com \
--cc=den@virtuozzo.com \
--cc=dplotnikov@virtuozzo.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkagan@virtuozzo.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