Skip to contentSkip to conversation

Question about hpet calls to set_timer

DISCUSSION Beth Kon 3 participants 3 messages Aug 15, 2008 – Aug 18, 2008

lore
Share & tools
lore

Beth Kon

author
#0 lore raw

Hello. I'm looking over the Xen hpet.c to see what I can steal for the qemu implementation I'm working on. (Thank you kindly :-)

One thing that doesn't make sense to me is why, in hpet_timer_fn, the timer is set with:

set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, period));

rather than calculating the difference between the final value of the comparator (after the time_after loop) and the current time. This is the approach used in hpet_set_timer:

set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, diff));

and would seem to be the best way to get as close to the desired expire time as possible. Can someone explain why the approaches are different in these 2 places?

Signature · 4 lines
Elizabeth Kon (Beth)
IBM Linux Technology Center
Open Hypervisor Team
email: [email protected]
#1 lore raw

I might use 'hg anno' to see if anyone changed it to period for good reason, but it seems to me that your suggested approach would be more accurate, especially in the long run.

-- Keir

Quoted 17 lines · Beth Kon

Hello. I'm looking over the Xen hpet.c to see what I can steal for the qemu implementation I'm working on. (Thank you kindly :-)

One thing that doesn't make sense to me is why, in hpet_timer_fn, the timer is set with:

set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, period));

rather than calculating the difference between the final value of the comparator (after the time_after loop) and the current time. This is the approach used in hpet_set_timer:

set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, diff));

and would seem to be the best way to get as close to the desired expire time as possible. Can someone explain why the approaches are different in these 2 places?

#2 lore raw

On some Linux time algorithms, if hpet ticks are delivered too closely together, time advances too rapidly, whereas if they are late (delivered too far apart), the algorithm makes adjustments and time is kept properly.

Dave Winchell is the expert in this area and had a patch for better hpet vpt handling submitted in early June but Keir requested some rework and it got delayed until after 3.3.0. Hopefully Dave can both comment on your questions and submit the reworked patch soon.

Quoted 48 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Sunday, August 17, 2008 4:25 AM
To: Beth Kon; [email protected]
Subject: Re: [Xen-devel] Question about hpet calls to set_timer

I might use 'hg anno' to see if anyone changed it to period for good reason,
but it seems to me that your suggested approach would be more accurate,
especially in the long run.

-- Keir

Quoted 1 line · Beth Kon

Hello. I'm looking over the Xen hpet.c to see what I can

steal for the

Quoted 3 lines

qemu implementation I'm working on. (Thank you kindly :-)

One thing that doesn't make sense to me is why, in

hpet_timer_fn, the

Quoted 5 lines

timer is set with:

set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, period));

rather than calculating the difference between the final

value of the

Quoted 1 line

comparator (after the time_after loop) and the current

time. This is the

Quoted 5 lines

approach used in hpet_set_timer:

set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, diff));

and would seem to be the best way to get as close to the

desired expire

Quoted 1 line

time as possible. Can someone explain why the approaches

are different

Quoted 1 line

in these 2 places?

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel