From: Dave Winchell <dwinchell@virtualiron.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: "Dong, Eddie" <eddie.dong@intel.com>,
Dave Winchell <dwinchell@virtualiron.com>,
xen-devel@lists.xensource.com, "Shan,
Haitao" <haitao.shan@intel.com>,
"Jiang, Yunhong" <yunhong.jiang@intel.com>
Subject: Re: [PATCH] Add a timer mode that disables pending missed ticks
Date: Wed, 07 Nov 2007 11:23:21 -0500 [thread overview]
Message-ID: <4731E679.9000307@virtualiron.com> (raw)
In-Reply-To: <C3577EB2.180C3%Keir.Fraser@cl.cam.ac.uk>
Hi Keir,
You can help me analyze the Linux code.
Here is the code from sles (linux-2.6.5-7.244) x86_64.
static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs
*regs)
spin_lock(&i8253_lock);
outb_p(0x00, 0x43);
delay = inb_p(0x40);
delay |= inb(0x40) << 8;
spin_unlock(&i8253_lock);
delay = LATCH - 1 - delay;
rdtscll_sync(&tsc);
offset = (((tsc - vxtime.last_tsc) *
vxtime.tsc_quot) >> 32) - (USEC_PER_SEC / HZ);
if (offset < 0)
offset = 0;
if (offset > (USEC_PER_SEC / HZ)) {
lost = offset / (USEC_PER_SEC / HZ);
offset %= (USEC_PER_SEC / HZ);
}
monotonic_base += (tsc - vxtime.last_tsc)*1000000/cpu_khz ;
vxtime.last_tsc = tsc - vxtime.quot * delay / vxtime.tsc_quot;
if ((((tsc - vxtime.last_tsc) *
vxtime.tsc_quot) >> 32) < offset)
vxtime.last_tsc = tsc -
(((long) offset << 32) / vxtime.tsc_quot) - 1;
if (lost > 0) {
if (report_lost_ticks) {
printk(KERN_WARNING "time.c: Lost %ld timer "
"tick(s)! ", lost);
print_symbol("rip %s)\n", regs->rip);
}
jiffies += lost;
}
do_timer(regs);
Now as 'offset' gets modified it represents the remainder in the
lost calculation. Our data indicates that when offset is close to zero,
timekeeping is more accurate. So this leads us to this line of code:
if ((((tsc - vxtime.last_tsc) *
vxtime.tsc_quot) >> 32) < offset)
vxtime.last_tsc = tsc -
(((long) offset << 32) / vxtime.tsc_quot) - 1;
Thus the problem seems to be the way the code switches from adjusting
last_tsc
by the delay which is the normal mode when interrupts are timely or SYNCed
to handling offsets larger than the delay.
I'm concerned about the way delay is blown off in the final calculation
vxtime.last_tsc = tsc -
(((long) offset << 32) / vxtime.tsc_quot) - 1;
If an interrupt is right on time, and the delay is the same as last time,
then the offset should be zero in my mind. In the code above, offset will
equal delay for this example.
What do you think?
thanks,
Dave
Keir Fraser wrote:
>Oh dear, that was a silly typo on my part. Thanks for tracking it down!
>
>Well, I'm surprised that SYNC vs ASYNC differs, if the guest is really
>tracking time via the TSC value. But it sounds like the actual time-tracking
>algorithm in the guest must be a bit more complicated than that? I'd be very
>happy to help with any further analysis.
>
> -- Keir
>
>On 7/11/07 14:39, "Dave Winchell" <dwinchell@virtualiron.com> wrote:
>
>
>
>>Keir,
>>
>>Attached is a fix for pt_process_missed_ticks().
>>Without this fix, systems run very erratically and some
>>guests panic on boot complaining that timer interrupts
>>are not working. As you can imagine.
>>
>>Also, I have some longer term measurements of the
>>accuracy of the sync and async methods.
>>The hardware is an eight cpu AMD box. Two eight
>>vcpu guests, rh4u4-64 and sles9sp3-64.
>>All vcpus running loads.
>>
>>Method Test duration Clock errors
>>
>>SYNC 56000 sec 6.4, 6.7 sec (.012%)
>>ASYNC 52000 sec 13, 19 sec (.036%)
>>
>>More testing should be done to validate the significance
>>of this difference.
>>
>>regards,
>>Dave
>>
>>
>>Dave Winchell wrote:
>>
>>
>>
>>>Keir Fraser wrote:
>>>
>>>
>>>
>>>>On 3/11/07 21:17, "Dave Winchell" <dwinchell@virtualiron.com> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>Thanks for applying the fixes in the last submit.
>>>>>In moving the test for no_missed_tick_accounting into
>>>>>pt_process_missed_ticks()
>>>>>you forgot to add the scheduling part.
>>>>>
>>>>>
>>>>>
>>>>Actually it was deliberate, but clearly it was one code
>>>>simplification too
>>>>far: thanks for spotting it! I'll go the async route, but we do need
>>>>to set
>>>>pending_intr_nr to 1. We can't leave that out -- the point of the async
>>>>route is to send a tick to the vcpu immediately, since it hasn't had
>>>>one for
>>>>more than a tick period. If we wait for the timeout to do that then
>>>>we have
>>>>to wait a whole extra period after the vcpu is re-scheduled.
>>>>
>>>>Attached is my proposed patch. I think it's quite neat. :-)
>>>>
>>>>
>>>>
>>>>
>>>It looks good to me.
>>>
>>>thanks,
>>>Dave
>>>
>>>
>>>
>>>>-- Keir
>>>>
>>>>
>>>>
>>>>
>>>>
>>diff -r dfe9c0c10a2c xen/arch/x86/hvm/vpt.c
>>--- a/xen/arch/x86/hvm/vpt.c Mon Nov 05 13:23:55 2007 +0000
>>+++ b/xen/arch/x86/hvm/vpt.c Wed Nov 07 08:55:45 2007 -0500
>>@@ -59,7 +59,7 @@ static void pt_process_missed_ticks(stru
>> if ( mode_is(pt->vcpu->domain, no_missed_tick_accounting) )
>> {
>> pt->pending_intr_nr = 1;
>>- pt->scheduled = now + pt->scheduled;
>>+ pt->scheduled = now + pt->period;
>> }
>> else
>> {
>>
>>
>
>
>
>
next prev parent reply other threads:[~2007-11-07 16:23 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-30 14:28 [PATCH] Add a timer mode that disables pending missed ticks Shan, Haitao
2007-10-30 16:12 ` Keir Fraser
2007-10-30 21:16 ` Dave Winchell
2007-10-31 7:09 ` Keir Fraser
2007-11-01 21:14 ` Dave Winchell
2007-11-01 21:21 ` Dave Winchell
2007-11-02 9:40 ` Keir Fraser
2007-11-02 15:51 ` Dave Winchell
2007-11-02 16:14 ` Keir Fraser
2007-11-02 16:35 ` Keir Fraser
2007-11-02 18:05 ` Dave Winchell
2007-11-03 21:17 ` Dave Winchell
2007-11-03 22:31 ` Keir Fraser
2007-11-05 14:36 ` Dave Winchell
2007-11-07 14:39 ` Dave Winchell
2007-11-07 14:39 ` Keir Fraser
2007-11-07 16:23 ` Dave Winchell [this message]
2007-11-07 17:10 ` Keir Fraser
2007-11-07 17:29 ` Keir Fraser
2007-11-07 17:47 ` Keir Fraser
2007-11-07 19:38 ` Dave Winchell
2007-11-08 8:07 ` Keir Fraser
2007-11-08 14:43 ` Dave Winchell
2007-11-08 14:53 ` Keir Fraser
2007-11-08 15:08 ` Dave Winchell
2007-11-09 19:22 ` Dave Winchell
2007-11-10 10:55 ` Keir Fraser
2007-11-12 15:37 ` Dave Winchell
2007-11-26 20:57 ` Dave Winchell
2007-12-06 11:57 ` Keir Fraser
2007-12-19 18:57 ` Dan Magenheimer
2007-12-19 19:32 ` Dave Winchell
2008-01-03 22:57 ` Dan Magenheimer
2008-01-03 23:24 ` Dave Winchell
2008-01-04 23:24 ` Dave Winchell
2008-01-08 14:33 ` Keir Fraser
2008-01-09 16:53 ` Dave Winchell
2008-01-09 17:19 ` Dan Magenheimer
2008-01-09 19:14 ` Keir Fraser
2008-01-25 23:50 ` Dan Magenheimer
2008-01-27 21:21 ` Dave Winchell
2008-01-28 0:29 ` Dan Magenheimer
2008-01-28 15:21 ` Dave Winchell
2008-01-29 22:34 ` Dan Magenheimer
2008-01-30 15:25 ` Dave Winchell
2008-01-30 21:04 ` Deepak Patel
2008-01-30 21:44 ` Dave Winchell
2008-02-01 22:31 ` Dan Magenheimer
2008-02-04 20:07 ` Dave Winchell
2008-02-08 21:21 ` Dave Winchell
2008-02-11 16:52 ` Dave Winchell
2008-02-14 15:59 ` Dave Winchell
2008-02-14 16:21 ` Dan Magenheimer
2008-02-14 17:55 ` Dave Winchell
2008-02-15 16:46 ` Dan Magenheimer
2008-02-15 17:28 ` Dave Winchell
2008-02-19 15:26 ` Dave Winchell
2008-02-19 17:55 ` Dan Magenheimer
2008-02-19 19:29 ` Keir Fraser
2008-02-19 20:50 ` Dave Winchell
2008-02-19 23:38 ` Dan Magenheimer
2008-02-20 23:40 ` Dan Magenheimer
2008-02-25 16:42 ` Dan Magenheimer
2008-02-25 20:01 ` (progress on hpet accuracy) and " Dave Winchell
2008-02-26 8:26 ` Keir Fraser
2008-02-26 14:45 ` Dave Winchell
2008-02-26 14:56 ` Keir Fraser
2008-02-26 15:49 ` Dave Winchell
2008-03-05 15:06 ` Dave Winchell
2008-03-05 15:20 ` Keir Fraser
2008-03-05 17:25 ` Dave Winchell
2008-03-05 17:21 ` Keir Fraser
2008-03-05 17:42 ` Dave Winchell
2008-03-05 17:53 ` Dan Magenheimer
2008-03-06 23:36 ` Dan Magenheimer
2007-12-19 19:40 ` Dave Winchell
2007-11-08 14:57 ` Dave Winchell
2007-10-31 3:10 ` Shan, Haitao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4731E679.9000307@virtualiron.com \
--to=dwinchell@virtualiron.com \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=eddie.dong@intel.com \
--cc=haitao.shan@intel.com \
--cc=xen-devel@lists.xensource.com \
--cc=yunhong.jiang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.