* [PATCH 1/1] staging: hv: Optimize adj_guesttime function and add more detailed comments
@ 2010-05-10 18:12 Haiyang Zhang
2010-05-11 0:02 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Haiyang Zhang @ 2010-05-10 18:12 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de'
Cc: Hank Janssen
[-- Attachment #1: Type: text/plain, Size: 2276 bytes --]
From: Haiyang Zhang <haiyangz@microsoft.com>
Subject: Optimize adj_guesttime function and add more detailed comments
Credits go to Joe Perches [joe@perches.com] for suggesting the changes.
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.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
[-- Attachment #2: 0507-timesync-optimize.patch --]
[-- Type: application/octet-stream, Size: 2202 bytes --]
From: Haiyang Zhang <haiyangz@microsoft.com>
Subject: Optimize adj_guesttime function and add more detailed comments
Credits go to Joe Perches [joe@perches.com] for suggesting the changes.
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] staging: hv: Optimize adj_guesttime function and add more detailed comments
2010-05-10 18:12 [PATCH 1/1] staging: hv: Optimize adj_guesttime function and add more detailed comments Haiyang Zhang
@ 2010-05-11 0:02 ` Joe Perches
2010-05-11 14:44 ` Haiyang Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2010-05-11 0:02 UTC (permalink / raw)
To: Haiyang Zhang
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de'
On Mon, 2010-05-10 at 18:12 +0000, Haiyang Zhang wrote:
> 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;
> +}
Just a couple of style nits.
return at the end of a void function() is unnecessary.
> +
> +/*
> + * 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;
here too
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH 1/1] staging: hv: Optimize adj_guesttime function and add more detailed comments
2010-05-11 0:02 ` Joe Perches
@ 2010-05-11 14:44 ` Haiyang Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Haiyang Zhang @ 2010-05-11 14:44 UTC (permalink / raw)
To: Joe Perches
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 323 bytes --]
> Just a couple of style nits.
>
> return at the end of a void function() is unnecessary.
Thank you for pointing this out.
I'll update the patch soon.
- Haiyang
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-11 14:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-10 18:12 [PATCH 1/1] staging: hv: Optimize adj_guesttime function and add more detailed comments Haiyang Zhang
2010-05-11 0:02 ` Joe Perches
2010-05-11 14:44 ` Haiyang Zhang
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®