x86 hvm: fix missing ticks issue in c/s 20218
PATCH 1/1 x86 hvm: fix missing ticks issue in c/s 20218
Although c/s 20229 fixes missing ticks issue in c/s 20218, it's not enough.
- set a timer to the next period more straightforwardly.
- fix an unexpected behavior of both timer_mode=2 and timer_mode=3. extra interrupts might be delivered to a guest.
xen/arch/x86/hvm/vpt.c +11 -8
@@ -313,20 +313,23 @@ void pt_intr_post(struct vcpu *v, structif (mode_is (v->domain, one_missed_tick_pending) ||mode_is (v->domain, no_missed_ticks_pending) ) { +pt_process_missed_ticks (pt); +set_timer (&pt->timer, pt->scheduled); + pt->last_plt_gtime =hvm_get_guest_time (v); pt->pending_intr_nr =0 ;/* 'collapse' all missed ticks */ }else { +s_time_t now =NOW (); + +if ( pt->scheduled > now ) + { +set_timer (&pt->timer, pt->scheduled); + pt->pending_intr_nr =0 ; + } + pt->last_plt_gtime += pt->period; - pt->pending_intr_nr--; - } - -if ( pt->pending_intr_nr ==0 ) - { -pt_process_missed_ticks (pt); - pt->do_not_freeze =0 ; -set_timer (&pt->timer, pt->scheduled); } }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 8 lines · On Friday 25 September 2009 06:37:41 Kouya Shimura wrote:
Although c/s 20229 fixes missing ticks issue in c/s 20218, it's not enough.
- set a timer to the next period more straightforwardly.
- fix an unexpected behavior of both timer_mode=2 and timer_mode=3. extra interrupts might be delivered to a guest.Signed-off-by Kouya Shimura <[email protected]>
I can confirm, this patch works.
Christoph
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
This patch is very dubious. It appears to break pt_process_missed_ticks() logic for timer modes 0 and 1. When a VCPU gets rescheduled it will have missed ticks folded into ->scheduled and ->pending_intr_nr fields, but since you stomp on the logic for tracking pending_intr_nr, most of those missed ticks will never get delivered.
I think the fix is to move the line 'pt->scheduled += pt->period' out of pt_intr_post() and back into pt_timer_fn(). This is because you have otherwise broken the invariant that pt->scheduled always gets incremented along with pt->pending_intr_nr. All the rest of your 'fixes' are I think merely working around that fundamental brokeness.
Please try moving that one line and see if the bug goes away.
-- Keir
Quoted 9 lines · Kouya Shimura
Although c/s 20229 fixes missing ticks issue in c/s 20218, it's not enough.
- set a timer to the next period more straightforwardly.
- fix an unexpected behavior of both timer_mode=2 and timer_mode=3. extra interrupts might be delivered to a guest.Signed-off-by Kouya Shimura <[email protected]>
Quoted 5 lines · Keir Fraser
This patch is very dubious. It appears to break
pt_process_missed_ticks()logic for timer modes 0 and 1. When a VCPU gets rescheduled it will have missed ticks folded into ->scheduled and ->pending_intr_nr fields, but since you stomp on the logic for trackingpending_intr_nr, most of those missed ticks will never get delivered.
I've forgotten VCPU switch. Indeed, it's pretty fragile. :-) What about modifying pt_restore_timer() not to advance pt->scheduled? For example,
xen/arch/x86/hvm/vpt.c +4 -2
@@ -189,8 +189,10 @@ void pt_restore_timer(struct vcpu *v) {if ( pt->pending_intr_nr ==0 ) { -pt_process_missed_ticks (pt); -set_timer (&pt->timer, pt->scheduled); +if ( pt->scheduled >NOW () ) +set_timer (&pt->timer, pt->scheduled); +else + pt->pending_intr_nr =1 ; } }
We should rename pending_intr_nr to pending_intr(boolean).
Thanks,
Kouya
Quoted 22 lines
I think the fix is to move the line '
pt->scheduled+=pt->period' out ofpt_intr_post()and back intopt_timer_fn(). This is because you have otherwise broken the invariant thatpt->scheduledalways gets incremented along withpt->pending_intr_nr. All the rest of your 'fixes' are I think merely working around that fundamental brokeness.Please try moving that one line and see if the bug goes away.
-- Keir
Quoted 9 lines · Kouya Shimura
Although c/s 20229 fixes missing ticks issue in c/s 20218, it's not enough.
- set a timer to the next period more straightforwardly.
- fix an unexpected behavior of both timer_mode=2 and timer_mode=3. extra interrupts might be delivered to a guest.Signed-off-by Kouya Shimura <[email protected]>
Quoted 3 lines · Kouya Shimura
I've forgotten VCPU switch. Indeed, it's pretty fragile. :-) What about modifying
pt_restore_timer()not to advancept->scheduled? We should renamepending_intr_nrtopending_intr(boolean).
It's not clear to me that the old logic around pt->pending_intr_nr and pt->scheduled really needs to change that drastically. The more we mess with this code the more likely we are to break stuff, as it's hard to get good coverage of the timer_modes and various ways guest Oses may manage their timers.
I would prefer to see whether moving the update of pt->scheduled out of pt_intr_post() and back into the timer_fn() works. That moves us back towards what we had before your patches, and therefore I'm more comfortable with it.
-- Keir
Keir,
Okay, attached is a new patch per your advice.
I tested it carefully. It works for me.
Christoph,
Could you please test it?
Thanks,
Kouya
Quoted 12 lines · Keir Fraser
Quoted 3 lines · Kouya Shimura
I've forgotten VCPU switch. Indeed, it's pretty fragile. :-) What about modifying
pt_restore_timer()not to advancept->scheduled? We should renamepending_intr_nrtopending_intr(boolean).It's not clear to me that the old logic around
pt->pending_intr_nrandpt->scheduledreally needs to change that drastically. The more we mess with this code the more likely we are to break stuff, as it's hard to get good coverage of thetimer_modesand various ways guest Oses may manage their timers.
Quoted 7 lines
I would prefer to see whether moving the update of
pt->scheduledout ofpt_intr_post()and back into thetimer_fn()works. That moves us back towards what we had before your patches, and therefore I'm more comfortable with it.-- Keir
xen/arch/x86/hvm/vpt.c +9 -9
@@ -206,6 +206,7 @@ static void pt_timer_fn(void *data)pt_lock (pt); pt->pending_intr_nr++; + pt->scheduled += pt->period; pt->do_not_freeze =0 ;vcpu_kick (pt->vcpu);
@@ -308,25 +309,24 @@ void pt_intr_post(struct vcpu *v, struct }else { - pt->scheduled += pt->period; -if (mode_is (v->domain, one_missed_tick_pending) ||mode_is (v->domain, no_missed_ticks_pending) ) { pt->last_plt_gtime =hvm_get_guest_time (v); +pt_process_missed_ticks (pt); pt->pending_intr_nr =0 ;/* 'collapse' all missed ticks */ +set_timer (&pt->timer, pt->scheduled); }else { pt->last_plt_gtime += pt->period; pt->pending_intr_nr--; - } - -if ( pt->pending_intr_nr ==0 ) - { -pt_process_missed_ticks (pt); - pt->do_not_freeze =0 ; -set_timer (&pt->timer, pt->scheduled); +if ( pt->pending_intr_nr ==0 ) + { +pt_process_missed_ticks (pt); +if ( pt->pending_intr_nr ==0 ) +set_timer (&pt->timer, pt->scheduled); + } } }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 6 lines · On Friday 25 September 2009 14:25:11 Kouya Shimura wrote:
Keir,
Okay, attached is a new patch per your advice.
I tested it carefully. It works for me.Christoph,
Could you please test it?
Works for me. Thanks for fixing it.
Christoph
Quoted 23 lines
Thanks,
KouyaQuoted 11 lines · Keir Fraser
Quoted 3 lines · Kouya Shimura
I've forgotten VCPU switch. Indeed, it's pretty fragile. :-) What about modifying
pt_restore_timer()not to advancept->scheduled? We should renamepending_intr_nrtopending_intr(boolean).It's not clear to me that the old logic around
pt->pending_intr_nrandpt->scheduledreally needs to change that drastically. The more we mess with this code the more likely we are to break stuff, as it's hard to get good coverage of thetimer_modesand various ways guest Oses may manage their timers.Quoted 6 lines
I would prefer to see whether moving the update of
pt->scheduledout ofpt_intr_post()and back into thetimer_fn()works. That moves us back towards what we had before your patches, and therefore I'm more comfortable with it.-- Keir
Signed-off-by Kouya Shimura <[email protected]>
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Keir Fraser
AppliedApplied as c/s 20255. I messed with it some more, so perhaps worth checking the bug still is gone. ;-)
-- Keir
Quoted 33 lines · Kouya Shimura
Keir,
Okay, attached is a new patch per your advice.
I tested it carefully. It works for me.Christoph,
Could you please test it?Thanks,
KouyaQuoted 12 lines · Keir Fraser
Quoted 3 lines · Kouya Shimura
I've forgotten VCPU switch. Indeed, it's pretty fragile. :-) What about modifying
pt_restore_timer()not to advancept->scheduled? We should renamepending_intr_nrtopending_intr(boolean).It's not clear to me that the old logic around
pt->pending_intr_nrandpt->scheduledreally needs to change that drastically. The more we mess with this code the more likely we are to break stuff, as it's hard to get good coverage of thetimer_modesand various ways guest Oses may manage their timers.Quoted 7 lines
I would prefer to see whether moving the update of
pt->scheduledout ofpt_intr_post()and back into thetimer_fn()works. That moves us back towards what we had before your patches, and therefore I'm more comfortable with it.-- Keir
Signed-off-by Kouya Shimura <[email protected]>
Quoted 2 lines · On Friday 25 September 2009 16:22:39 Keir Fraser wrote:
Applied as c/s 20255. I messed with it some more, so perhaps worth checking the bug still is gone. ;-)
I retested and the bug is still gone.
Christoph
Quoted 33 lines
-- Keir
Quoted 30 lines · Kouya Shimura
Keir,
Okay, attached is a new patch per your advice.
I tested it carefully. It works for me.Christoph,
Could you please test it?Thanks,
KouyaQuoted 11 lines · Keir Fraser
Quoted 3 lines · Kouya Shimura
I've forgotten VCPU switch. Indeed, it's pretty fragile. :-) What about modifying
pt_restore_timer()not to advancept->scheduled? We should renamepending_intr_nrtopending_intr(boolean).It's not clear to me that the old logic around
pt->pending_intr_nrandpt->scheduledreally needs to change that drastically. The more we mess with this code the more likely we are to break stuff, as it's hard to get good coverage of thetimer_modesand various ways guest Oses may manage their timers.Quoted 6 lines
I would prefer to see whether moving the update of
pt->scheduledout ofpt_intr_post()and back into thetimer_fn()works. That moves us back towards what we had before your patches, and therefore I'm more comfortable with it.-- Keir
Signed-off-by Kouya Shimura <[email protected]>
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
c/s 20255 passed my test, too.
Thanks a lot,
Kouya
Quoted 51 lines · Christoph Egger
Quoted 2 lines · On Friday 25 September 2009 16:22:39 Keir Fraser wrote:
Applied as c/s 20255. I messed with it some more, so perhaps worth checking the bug still is gone. ;-)
I retested and the bug is still gone.
Christoph
Quoted 33 lines
-- Keir
Quoted 30 lines · Kouya Shimura
Keir,
Okay, attached is a new patch per your advice.
I tested it carefully. It works for me.Christoph,
Could you please test it?Thanks,
KouyaQuoted 11 lines · Keir Fraser
Quoted 3 lines · Kouya Shimura
I've forgotten VCPU switch. Indeed, it's pretty fragile. :-) What about modifying
pt_restore_timer()not to advancept->scheduled? We should renamepending_intr_nrtopending_intr(boolean).It's not clear to me that the old logic around
pt->pending_intr_nrandpt->scheduledreally needs to change that drastically. The more we mess with this code the more likely we are to break stuff, as it's hard to get good coverage of thetimer_modesand various ways guest Oses may manage their timers.Quoted 6 lines
I would prefer to see whether moving the update of
pt->scheduledout ofpt_intr_post()and back into thetimer_fn()works. That moves us back towards what we had before your patches, and therefore I'm more comfortable with it.-- Keir
Signed-off-by Kouya Shimura <[email protected]>Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632