Re: [PATCH 1/1] staging: hv: Add Time Sync feature to hv_utils module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2010-05-05 at 19:23 +0000, Haiyang Zhang wrote:
> From: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
> 
> 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);
	}
}



_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux