Re: [PATCH 4/4] kvm/guest: fix paravirt clocksource to be compartible with xen.

Glauber Costa
2008-04-24T13:16:40Z

> -
> - delta = kvm_clock_read();
> -
> native_write_msr(MSR_KVM_WALL_CLOCK, low, high);
> - do {
> - version = wall_clock.wc_version;
> - rmb();
> - wc_sec = wall_clock.wc_sec;
> - wc_nsec = wall_clock.wc_nsec;
> - rmb();
> - } while ((wall_clock.wc_version != version) || (version & 1));
> -
> - delta = kvm_clock_read() - delta;
> - delta += wc_nsec;
> - nsec = do_div(delta, NSEC_PER_SEC);
> - set_normalized_timespec(&ts, wc_sec + delta, nsec);
> - /*
> - * Of all mechanisms of time adjustment I've tested, this one
> - * was the champion!
> - */
> - return ts.tv_sec + 1;
> +
> + vcpu_time = &get_cpu_var(hv_clock);
> + pvclock_read_wallclock(&wall_clock, vcpu_time, &ts);
> + put_cpu_var(hv_clock);
> +
> + return ts.tv_sec;
> }

Here it is. Despite some needed cleanups, patches look beautiful to me.

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

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