Re: [Xen-devel] Re: [RFC PATCH 25/35] Add Xen time abstractions

Dan Hecht
2006-03-22T22:27:07Z

Chris Wright wrote:
> * Arjan van de Ven (arjan@infradead.org) wrote:
>> Duplication like this is evil because it means too many places need
>> duplicated bugfixes and rework (and such rework is underway)
>
> Yes, that one is already on the todo list. Will work on consolidation
> there.
>
> thanks,
> -chris
>

These patches from the VMI patch series sent out last week could be
easily used to abstract time when running on Xen to accomplish the
consolidation and transparency with native goals:

http://lkml.org/lkml/2006/3/13/172
http://lkml.org/lkml/2006/3/13/173

Unlike this Xen specific patch, the VMI time patches already provide
transparency with native -- the timer_vmi.c device is used when booting
on a hypervisor that provides this functionality, otherwise one of the
traditional time sources is fallen back to.

Also, they remove much of the code duplication by taking advantage of
the the i386 time interface mechanisms (and can be easily updated for
the time rework that is underway).

Finally, the vmi nicely abstracts the details of the formula that is
used to compute system_time from the HYPERVISOR_shared_info time
parameters by hiding the computation underneath the kernel <->
hypervisor interface. Note that efficiency is not lost since the code
to compute system_time, etc would execute in the "ROM" (a.k.a. hypercall
page) without needing to call all the way down into the hypervisor.
Hiding these details from the Linux code would be nice since it leads to
easier to understand linux code (it doesn't have to deal with the
details of how time is interpolated from hardware rdtsc), and allows the
calculation for "system_time", etc to change without breaking the
kernel<->hypervisor interface. It also allows for more freedom as to
how the time interface is implemented; hypervisors aren't forced to
implement system_time using a particular algorithm. The Xen interface
needlessly imposes one particular algorithm to compute system_time from
rdtsc.

See this post for a description of how the Xen time interface could be
mapped to the timer_vmi.c patches I linked above:

http://lists.xensource.com/archives/html/xen-devel/2006-02/msg00876.html

Dan