lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1273107494.1735.87.camel@Joe-Laptop.home>
Date:	Wed, 05 May 2010 17:58:14 -0700
From:	Joe Perches <joe@...ches.com>
To:	Haiyang Zhang <haiyangz@...rosoft.com>
Cc:	"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>,
	Hank Janssen <hjanssen@...rosoft.com>
Subject: Re: [PATCH 1/1] staging: hv: Add Time Sync feature to hv_utils
 module

On Wed, 2010-05-05 at 19:23 +0000, Haiyang Zhang wrote:
> From: Haiyang Zhang <haiyangz@...rosoft.com>
> 
> Subject: Add Time Sync feature to hv_utils module.
> The Time Sync feature synchronizes guest time to host UTC time after reboot,
> and restore from saved/paused state.
> +static void adj_guesttime(winfiletime_t hosttime, u8 flags)
> +{
> +	s64 host_tns;
> +	struct timespec host_ts;
> +	static s32 scnt = 50;

Why a maximum of 50 samples?

> +	host_tns = (hosttime - WLTIMEDELTA) * 100;
> +	host_ts = ns_to_timespec(host_tns);
> +
> +	if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
> +		do_settimeofday(&host_ts);
> +		return;
> +	}
> +
> +	if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 &&
> +	    scnt > 0) {
> +		scnt--;
> +		do_settimeofday(&host_ts);
> +	}

It might be better to do something like this
so the ns_to_timespec isn't performe when unnecessary.

static void settimeofday(winfiletime_t hosttime)
{
	s64 host_tns = (hosttime - WLTIMEDELTA) * 100;
	struct timespec host_ts = ns_to_timespec(host_tns);
	do_settimeofday(&host_ts);
}

static void adj_guesttime(winfiletime_t hosttime, u8 flags)
{
	static s32 scnt = 50;

	if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
		settimeofday(hosttime);
		return;
	}

	if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
		scnt--;
		settimeofday(hosttime);
	}
}



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ