From: David Vrabel <david.vrabel@citrix.com>
To: <xen-devel@lists.xen.org>
Cc: David Vrabel <david.vrabel@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
<linux-kernel@vger.kernel.org>,
John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 4/4] x86/xen: sync the CMOS RTC as well as the Xen wallclock
Date: Wed, 19 Jun 2013 16:25:23 +0100 [thread overview]
Message-ID: <1371655523-15609-5-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1371655523-15609-1-git-send-email-david.vrabel@citrix.com>
From: David Vrabel <david.vrabel@citrix.com>
Adjustments to Xen's persistent clock via update_persistent_clock()
don't actually persist, as the Xen wallclock is a software only clock
and modifications to it do not modify the underlying CMOS RTC.
The x86_platform.set_wallclock hook can be used to keep the hardware
RTC synchronized (as on bare metal). Because the Xen wallclock is now
kept synchronized by the clock_was_set notifier and a new timer,
xen_set_wallclock() need not do this and dom0 can simply use the
native implementation.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
arch/x86/xen/time.c | 49 +++++++++++++++++++++++++++++++------------------
1 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index c4bb255..18a3db6 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -198,39 +198,50 @@ static void xen_get_wallclock(struct timespec *now)
static int xen_set_wallclock(const struct timespec *now)
{
+ return -1;
+}
+
+static void xen_wallclock_timer_func(unsigned long d);
+static DEFINE_TIMER(xen_wallclock_timer, xen_wallclock_timer_func, 0, 0);
+
+static void xen_sync_wallclock(void)
+{
+ struct timespec now;
struct xen_platform_op op;
- /* do nothing for domU */
- if (!xen_initial_domain())
- return -1;
+ now = current_kernel_time();
op.cmd = XENPF_settime;
- op.u.settime.secs = now->tv_sec;
- op.u.settime.nsecs = now->tv_nsec;
+ op.u.settime.secs = now.tv_sec;
+ op.u.settime.nsecs = now.tv_nsec;
op.u.settime.system_time = xen_clocksource_read();
- return HYPERVISOR_dom0_op(&op);
+ (void)HYPERVISOR_dom0_op(&op);
+
+ /*
+ * Use a timer to correct for any drift in the Xen
+ * wallclock.
+ *
+ * 11 minutes is the same period as sync_cmos_clock().
+ */
+ mod_timer(&xen_wallclock_timer, round_jiffies(jiffies + 11*60*HZ));
}
-
+
static int xen_clock_was_set_notify(struct notifier_block *nb, unsigned long unused,
void *priv)
{
- struct timespec now;
- int ret;
-
- /*
- * Set the Xen wallclock from Linux system time.
- */
- now = current_kernel_time();
- xen_set_wallclock(&now);
-
- return NOTIFY_OK;
+ xen_sync_wallclock();
+ return NOTIFY_OK;
}
static struct notifier_block xen_clock_was_set_notifier = {
.notifier_call = xen_clock_was_set_notify,
};
+static void xen_wallclock_timer_func(unsigned long d)
+{
+ xen_sync_wallclock();
+}
static struct clocksource xen_clocksource __read_mostly = {
.name = "xen",
@@ -509,7 +520,9 @@ void __init xen_init_time_ops(void)
x86_platform.calibrate_tsc = xen_tsc_khz;
x86_platform.get_wallclock = xen_get_wallclock;
- x86_platform.set_wallclock = xen_set_wallclock;
+ /* Dom0 uses the native method to set the hardware RTC. */
+ if (!xen_initial_domain())
+ x86_platform.set_wallclock = xen_set_wallclock;
}
#ifdef CONFIG_XEN_PVHVM
--
1.7.2.5
next prev parent reply other threads:[~2013-06-19 15:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 15:25 [PATCHv4 0/4] xen: maintain an accurate persistent clock in more cases David Vrabel
2013-06-19 15:25 ` [PATCH 1/4] xen: disable non-boot VCPUs during suspend David Vrabel
2013-06-19 17:11 ` Konrad Rzeszutek Wilk
2013-06-20 10:01 ` David Vrabel
2013-06-20 10:38 ` [Xen-devel] " Jan Beulich
2013-06-20 11:46 ` David Vrabel
2013-06-19 15:25 ` [PATCH 2/4] time: add a notifier chain for when the system time is stepped David Vrabel
2013-06-19 16:52 ` John Stultz
2013-06-19 17:13 ` Konrad Rzeszutek Wilk
2013-06-19 17:38 ` John Stultz
2013-06-20 10:50 ` David Vrabel
2013-06-19 15:25 ` [PATCH 3/4] x86/xen: sync the wallclock " David Vrabel
2013-06-20 10:43 ` [Xen-devel] " Jan Beulich
2013-06-19 15:25 ` David Vrabel [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-06-20 19:16 [PATCHv5 0/4] xen: maintain an accurate persistent clock in more cases David Vrabel
2013-06-20 19:16 ` [PATCH 4/4] x86/xen: sync the CMOS RTC as well as the Xen wallclock David Vrabel
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=1371655523-15609-5-git-send-email-david.vrabel@citrix.com \
--to=david.vrabel@citrix.com \
--cc=john.stultz@linaro.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).