Re: [PATCH 1/4] Add helper functions for paravirtual clocksources.

Glauber Costa
2008-04-24T13:11:05Z

> +void pvclock_read_wallclock(struct kvm_wall_clock *wall_clock,
> + struct kvm_vcpu_time_info *vcpu_time,
> + struct timespec *ts)
> +{
> + u32 version;
> + u64 delta;
> + struct timespec now;
> +
> + /* get wallclock at system boot */
> + do {
> + version = wall_clock->wc_version;
> + rmb(); /* fetch version before time */
> + now.tv_sec = wall_clock->wc_sec;
> + now.tv_nsec = wall_clock->wc_nsec;
> + rmb(); /* fetch time before checking version */
> + } while ((wall_clock->wc_version & 1) || (version != wall_clock->wc_version));
> +
> + delta = pvclock_clocksource_read(vcpu_time); /* time since system boot */
> + delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
> +
> + now.tv_nsec = do_div(delta, NSEC_PER_SEC);
> + now.tv_sec = delta;
> +
> + set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
> +}

This is not exactly what kvm does. For us, wallclock read and system
time reads are decoupled operations, controlled by different msrs.
This function might exist, but in this case, it have to be wrapped
around a kvm_read_wallclock(), that does the msr read. (I'm not sure
whether or not you do it in your later patches, doing sequential reads
:-) )

> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

ads! ads!

--
Glauber Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."