[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1FB5E1D5CA062146B38059374562DF72662AA29C@TK5EX14MBXC130.redmond.corp.microsoft.com>
Date: Mon, 10 May 2010 18:12:02 +0000
From: Haiyang Zhang <haiyangz@...rosoft.com>
To: "'linux-kernel@...r.kernel.org'" <linux-kernel@...r.kernel.org>,
"'devel@...verdev.osuosl.org'" <devel@...verdev.osuosl.org>,
"'virtualization@...ts.osdl.org'" <virtualization@...ts.osdl.org>,
"'gregkh@...e.de'" <gregkh@...e.de>
CC: Hank Janssen <hjanssen@...rosoft.com>
Subject: [PATCH 1/1] staging: hv: Optimize adj_guesttime function and add
more detailed comments
From: Haiyang Zhang <haiyangz@...rosoft.com>
Subject: Optimize adj_guesttime function and add more detailed comments
Credits go to Joe Perches [joe@...ches.com] for suggesting the changes.
Cc: Greg Kroah-Hartman <gregkh@...e.de>
Signed-off-by: Hank Janssen <hjanssen@...rosoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@...rosoft.com>
---
drivers/staging/hv/hv_utils.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c
index 8f1d3ba..c0f57a1 100644
--- a/drivers/staging/hv/hv_utils.c
+++ b/drivers/staging/hv/hv_utils.c
@@ -106,28 +106,45 @@ static void shutdown_onchannelcallback(void *context)
orderly_poweroff(false);
}
-
/*
- * Synchronize time with host after reboot, restore, etc.
+ * Set guest time to host UTC time.
*/
-static void adj_guesttime(u64 hosttime, u8 flags)
+static inline void do_adj_guesttime(u64 hosttime)
{
s64 host_tns;
struct timespec host_ts;
- static s32 scnt = 50;
host_tns = (hosttime - WLTIMEDELTA) * 100;
host_ts = ns_to_timespec(host_tns);
+ do_settimeofday(&host_ts);
+
+ return;
+}
+
+/*
+ * Synchronize time with host after reboot, restore, etc.
+ *
+ * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
+ * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time
+ * message after the timesync channel is opened. Since the hv_utils module is
+ * loaded after hv_vmbus, the first message is usually missed. The other
+ * thing is, systime is automatically set to emulated hardware clock which may
+ * not be UTC time or in the same time zone. So, to override these effects, we
+ * use the first 50 time samples for initial system time setting.
+ */
+static inline void adj_guesttime(u64 hosttime, u8 flags)
+{
+ static s32 scnt = 50;
+
if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
- do_settimeofday(&host_ts);
+ do_adj_guesttime(hosttime);
return;
}
- if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 &&
- scnt > 0) {
+ if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
scnt--;
- do_settimeofday(&host_ts);
+ do_adj_guesttime(hosttime);
}
return;
--
1.6.3.2
Download attachment "0507-timesync-optimize.patch" of type "application/octet-stream" (2202 bytes)
Powered by blists - more mailing lists