dom0 hang
Here are the details on the dom0 hang:
xen: 3.4.0
dom0: 2.6.18-128
dom0.vcpu0: spinning in schedule() on spinlock: spin_lock_irq(&rq->lock); dom0.vcpu1: eip == ret after __HYPERVISOR_event_channel_op hypercall
Just of of curiosity, I set breakpoint at the above ret in kdb, and it never got hit. So I wondered why vcpu1 is not getting scheculed, and noticed that xen.schedule always schedules vcpu0. Two cpus on the box, other one is mostly in idle.
anyways, I've turned lock debugging on in dom0 and reproducing it right now.
thanks,
Mukesh
Quoted 8 lines · Mukesh Rathor
Here are the details on the dom0 hang:
xen: 3.4.0
dom0: 2.6.18-128dom0.vcpu0: spinning in
schedule()on spinlock:spin_lock_irq(&rq->lock); dom0.vcpu1: eip == ret after__HYPERVISOR_event_channel_ophypercall
Quoted 7 lines
Just of of curiosity, I set breakpoint at the above ret in kdb, and it never got hit. So I wondered why vcpu1 is not getting scheculed, and noticed that xen.schedule always schedules vcpu0. Two cpus on the box, other one is mostly in idle.
anyways, I've turned lock debugging on in dom0 and reproducing it right now.
thanks,
Mukesh
Ok, here's what I have found on this:
dom0 hang:
vcpu0 is trying to wakeup a task and in try_to_wake_up() calls task_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it calls resched_task() which results in sending IPI to vcpu1. for that, vcpu0 gets into the HYPERVISOR_event_channel_op HCALL and is waiting to return. Meanwhile, vcpu1 got running, and is spinning on it's runq lock in "schedule():spin_lock_irq(&rq->lock);", that vcpu0 is holding (and is waiting to return from the HCALL).
As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set to CSCHED_PRI_TS_BOOST. As a result, the scheduler always picks vcpu1, and vcpu0 is starved. Also, I see in kdb that the scheduler timer is not set on cpu 0. That would've allowed csched_load_balance() to kick in on cpu0. [Also, on cpu1, the accounting timer, csched_tick, is not set. Altho, csched_tick() is running on cpu0, it only checks runq for cpu0.]
Looks like c/s 19500 changed csched_schedule():
- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE);
+ ret.time = (is_idle_vcpu(snext->vcpu) ?
+ -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE));
The quickest fix for us would be to just back that out.
BTW, just a comment on following (all in sched_credit.c):
if ( svc->pri == CSCHED_PRI_TS_UNDER &&
!(svc->flags & CSCHED_FLAG_VCPU_PARKED) )
{
svc->pri = CSCHED_PRI_TS_BOOST;
} comibined with
if ( snext->pri > CSCHED_PRI_TS_OVER )
__runq_remove(snext);
Setting CSCHED_PRI_TS_BOOST as pri of vcpu seems dangerous. To me, since csched_schedule() never checks for time accumulated by a vcpu at pri CSCHED_PRI_TS_BOOST, that is same as pinning a vcpu to a pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally, csched_schedule() should always check for cpu time accumulated and reduce the priority over time. I can't tell right off if it already does that. or something like that :)... my 2 cents.
thanks,
Mukesh
*** : starting 3 star campaign against overuse of macros!
Review
Quoted 7 lines · Mukesh Rathor
Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out.
The wakeup should come via __runq_tickle(), I think. Anyhow I don't see this can be the main underlying bug. What if you were running on a uniprocessor system - you'd still be boned then, right?
I've added George Dunlap to the Cc list by the way. He's doing a bunch of scheduler work at the moment.
-- Keir
Quoted 41 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending IPI to vcpu1. for that, vcpu0 gets into theHYPERVISOR_event_channel_opHCALL and is waiting to return. Meanwhile, vcpu1 got running, and is spinning on it's runq lock in "schedule():spin_lock_irq(&rq->lock);", that vcpu0 is holding (and is waiting to return from the HCALL).As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As a result, the scheduler always picks vcpu1, and vcpu0 is starved. Also, I see in kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():- ret.time =
MILLISECS(CSCHED_MSECS_PER_TSLICE);
+ ret.time = (is_idle_vcpu(snext->vcpu)?
+ -1 :MILLISECS(CSCHED_MSECS_PER_TSLICE));The quickest fix for us would be to just back that out.
BTW, just a comment on following (all in
sched_credit.c):if (
svc->pri==CSCHED_PRI_TS_UNDER&&
!(svc->flags &CSCHED_FLAG_VCPU_PARKED) )
{
svc->pri=CSCHED_PRI_TS_BOOST;
}
comibined with
if (snext->pri>CSCHED_PRI_TS_OVER)
__runq_remove(snext);
Quoted 8 lines
Setting
CSCHED_PRI_TS_BOOSTas pri of vcpu seems dangerous. To me, sincecsched_schedule()never checks for time accumulated by a vcpu at priCSCHED_PRI_TS_BOOST, that is same as pinning a vcpu to a pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally,csched_schedule()should always check for cpu time accumulated and reduce the priority over time. I can't tell right off if it already does that. or something like that :)... my 2 cents.
Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into OVER (and thus also losing boost).
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
Quoted 58 lines · George Dunlap
Quoted 39 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending IPI to vcpu1. for that, vcpu0 gets into theHYPERVISOR_event_channel_opHCALL and is waiting to return. Meanwhile, vcpu1 got running, and is spinning on it's runq lock in "schedule():spin_lock_irq(&rq->lock);", that vcpu0 is holding (and is waiting to return from the HCALL).As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As a result, the scheduler always picks vcpu1, and vcpu0 is starved. Also, I see in kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out. BTW, just a comment on following (all in sched_credit.c): if ( svc->pri == CSCHED_PRI_TS_UNDER && !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; } comibined with if ( snext->pri > CSCHED_PRI_TS_OVER )Review
Quoted 10 lines
(quoted diff) +0
-0__runq_remove(snext); Setting CSCHED_PRI_TS_BOOST as pri of vcpu seems dangerous. To me, since csched_schedule() never checks for time accumulated by a vcpu at pri CSCHED_PRI_TS_BOOST, that is same as pinning a vcpu to a pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally, csched_schedule() should always check for cpu time accumulated and reduce the priority over time. I can't tell right off if it already does that. or something like that :)... my 2 cents.Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into OVER (and thus also losing boost).
Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in csched_acct()? Looks like that's somehow gotten removed. If true, then may be that's the fundamental problem to chase.
Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tick data:0000000000000000 2: exp=0x00003ee347ece164 fn:time_calibration data:0000000000000000 3: exp=0x00003ee69a28f04b fn:mce_work_fn data:0000000000000000 4: exp=0x00003f055895e25f fn:plt_overflow data:0000000000000000 5: exp=0x00003ee353810216 fn:rtc_update_second data:ffff83007f0226d8
CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fn data:0000000000000000 2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback data:ffff83007f022a68
thanks
Mukesh
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
[Oops, adding back in distro list, also adding Kevin Tian and Yu Ke who wrote cs 19460]
The functionality I was talking about, subtracting credits and clearing BOOST, happens in csched_vcpu_acct() (which is different than csched_acct()). vcpu_acct() is called from csched_tick(), which should still happen every 10ms on every cpu.
The patch I referred to (cs 19460) disables and re-enables tickers in xen/arch/x86/acpi/cpu_idle.c:acpi_processor_idle() every time the processor idles. I can't see anywhere else that tickers are disabled, so it's probably something not properly re-enabling them again.
Try applying the attached patch to see if that changes anything. (I'm on the road, so I can't repro the lockup issue.) If that doesn't work, try disabling c-states and see if that helps. Then at least we'll know where the problem lies.
-George
Quoted 114 lines · Mukesh Rathor
that seems to only suspend csched_pcpu.ticker which is
csched_tickthat is only sorting local runq.again, we are concerned about csched_priv.master_ticker that calls
csched_acct? correct, so i can trace that?thanks,
mukeshQuoted 102 lines · George Dunlap
Ah, I see that there's been some changes to tick stuff with the c-state (e.g., cs 19460). It looks like they're supposed to be going still, but perhaps the
tick_suspend()andtick_resume()aren't being called properly. Let me take a closer look.-George
Quoted 92 lines · Mukesh Rathor
Quoted 62 lines · George Dunlap
Quoted 42 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending IPI to vcpu1. for that, vcpu0 gets into theHYPERVISOR_event_channel_opHCALL and is waiting to return. Meanwhile, vcpu1 got running, and is spinning on it's runq lock in "schedule():spin_lock_irq(&rq->lock);", that vcpu0 is holding (and is waiting to return from the HCALL).As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As a result, the scheduler always picks vcpu1, and vcpu0 is starved. Also, I see in kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():- ret.time =
MILLISECS(CSCHED_MSECS_PER_TSLICE);
+ ret.time = (is_idle_vcpu(snext->vcpu)?
+ -1 :MILLISECS(CSCHED_MSECS_PER_TSLICE));The quickest fix for us would be to just back that out.
BTW, just a comment on following (all in
sched_credit.c):if (
svc->pri==CSCHED_PRI_TS_UNDER&&
!(svc->flags &CSCHED_FLAG_VCPU_PARKED) )
{
svc->pri=CSCHED_PRI_TS_BOOST;
}
comibined with
if (snext->pri>CSCHED_PRI_TS_OVER)
__runq_remove(snext);Quoted 9 lines
Setting
CSCHED_PRI_TS_BOOSTas pri of vcpu seems dangerous. To me, sincecsched_schedule()never checks for time accumulated by a vcpu at priCSCHED_PRI_TS_BOOST, that is same as pinning a vcpu to a pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally,csched_schedule()should always
check for cpu time accumulated and reduce the priority over time. I can't tell right off if it already does that. or something like that :)... my 2 cents.Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into OVER (and thus also losing boost).
Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in
csched_acct()? Looks like that's somehow gotten removed. If true, then may be that's the fundamental problem to chase.Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tick data:0000000000000000 2: exp=0x00003ee347ece164 fn:time_calibration data:0000000000000000 3: exp=0x00003ee69a28f04b fn:mce_work_fn data:0000000000000000 4: exp=0x00003f055895e25f fn:plt_overflow data:0000000000000000 5: exp=0x00003ee353810216 fn:rtc_update_second data:ffff83007f0226d8CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fn data:0000000000000000 2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback data:ffff83007f022a68thanks
Mukesh
xen/common/sched_credit.c +1 -2
@@ -1340,8 +1340,7 @@ spc =CSCHED_PCPU (smp_processor_id ()); -set_timer (&spc->ticker, now +MILLISECS (CSCHED_MSECS_PER_TICK ) - - now %MILLISECS (CSCHED_MSECS_PER_TICK ) ); +set_timer (&spc->ticker, now +MILLISECS (CSCHED_MSECS_PER_TICK )); }struct scheduler sched_credit_def = {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
ah, i totally missed csched_tick():
if ( !is_idle_vcpu(current) )
csched_vcpu_acct(cpu);
yeah, looks like that's what is going on. i'm still waiting to reproduce. at first glance, looking at c/s 19460, seems like suspend/resume, well at least the resume, should happen in csched_schedule().....
thanks,
Mukesh
Quoted 128 lines · George Dunlap
[Oops, adding back in distro list, also adding Kevin Tian and Yu Ke who wrote cs 19460]
The functionality I was talking about, subtracting credits and clearing BOOST, happens in
csched_vcpu_acct()(which is different thancsched_acct()).vcpu_acct()is called fromcsched_tick(), which should still happen every 10ms on every cpu.The patch I referred to (cs 19460) disables and re-enables tickers in xen/arch/x86/acpi/cpu_idle.c:acpi_processor_idle() every time the processor idles. I can't see anywhere else that tickers are disabled, so it's probably something not properly re-enabling them again.
Try applying the attached patch to see if that changes anything. (I'm on the road, so I can't repro the lockup issue.) If that doesn't work, try disabling c-states and see if that helps. Then at least we'll know where the problem lies.
-George
Quoted 107 lines · Mukesh Rathor
that seems to only suspend csched_pcpu.ticker which is
csched_tickthat is only sorting local runq.again, we are concerned about csched_priv.master_ticker that calls
csched_acct? correct, so i can trace that?thanks,
mukeshQuoted 96 lines · George Dunlap
Ah, I see that there's been some changes to tick stuff with the c-state (e.g., cs 19460). It looks like they're supposed to be going still, but perhaps the
tick_suspend()andtick_resume()aren't being called properly. Let me take a closer look.-George
Quoted 87 lines · Mukesh Rathor
Quoted 59 lines · George Dunlap
Quoted 46 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending IPI to vcpu1. for that, vcpu0 gets into theHYPERVISOR_event_channel_opHCALL and is waiting to return. Meanwhile, vcpu1 got running, and is spinning on it's runq lock in "schedule():spin_lock_irq(&rq->lock);", that vcpu0 is holding (and is waiting to return from the HCALL).As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As a result, the scheduler always picks vcpu1, and vcpu0 is starved. Also, I see in kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out. BTW, just a comment on following (all in sched_credit.c): if ( svc->pri == CSCHED_PRI_TS_UNDER && !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; } comibined with if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext); Setting CSCHED_PRI_TS_BOOST as pri of vcpu seems dangerous. To me, since csched_schedule() never checks for time accumulated by a vcpu at pri CSCHED_PRI_TS_BOOST, that is same as pinning a vcpu to a pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally, csched_schedule() shouldQuoted 4 lines
always
check for cpu time accumulated and reduce the priority over time. I can't tell right off if it already does that. or something like that :)... my 2 cents.Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into OVER (and thus also losing boost).
Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in
csched_acct()? Looks like that's somehow gotten removed. If true, then may be that's the fundamental problem to chase.Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tick data:0000000000000000 2: exp=0x00003ee347ece164 fn:time_calibration data:0000000000000000 3: exp=0x00003ee69a28f04b fn:mce_work_fn data:0000000000000000 4: exp=0x00003f055895e25f fn:plt_overflow data:0000000000000000 5: exp=0x00003ee353810216 fn:rtc_update_second data:ffff83007f0226d8CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fn data:0000000000000000 2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback data:ffff83007f022a68thanks
Mukesh
Hi Kevin/Yu:
acpi_processor_idle()
{
sched_tick_suspend();
/*
* sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer,
* which will break the later assumption of no sofirq pending,
* so add do_softirq
*/
if ( softirq_pending(smp_processor_id()) )
do_softirq(); <===============
local_irq_disable();
if ( softirq_pending(smp_processor_id()) )
{
local_irq_enable();
sched_tick_resume();
cpufreq_dbs_timer_resume();
return;
}wouldn't the do_softirq() call scheduler with tick suspended, and the scheduler then context switches to another vcpu0 (with *_BOOST) which would result in the stuck vcpu I described?
thanks
Mukesh
Quoted 150 lines · Mukesh Rathor
ah, i totally missed
csched_tick():
if ( !is_idle_vcpu(current) )
csched_vcpu_acct(cpu);yeah, looks like that's what is going on. i'm still waiting to reproduce. at first glance, looking at c/s 19460, seems like suspend/resume, well at least the resume, should happen in
csched_schedule().....thanks,
MukeshQuoted 13 lines · George Dunlap
[Oops, adding back in distro list, also adding Kevin Tian and Yu Ke who wrote cs 19460]
The functionality I was talking about, subtracting credits and clearing BOOST, happens in
csched_vcpu_acct()(which is different thancsched_acct()).vcpu_acct()is called fromcsched_tick(), which should still happen every 10ms on every cpu.The patch I referred to (cs 19460) disables and re-enables tickers in xen/arch/x86/acpi/cpu_idle.c:acpi_processor_idle() every time the processor idles. I can't see anywhere else that tickers are disabled, so it's probably something not properly re-enabling them again.
Quoted 121 lines
Try applying the attached patch to see if that changes anything. (I'm on the road, so I can't repro the lockup issue.) If that doesn't work, try disabling c-states and see if that helps. Then at least we'll know where the problem lies.
-George
Quoted 113 lines · Mukesh Rathor
that seems to only suspend csched_pcpu.ticker which is
csched_tickthat is only sorting local runq.again, we are concerned about csched_priv.master_ticker that calls
csched_acct? correct, so i can trace that?thanks,
mukeshQuoted 102 lines · George Dunlap
Ah, I see that there's been some changes to tick stuff with the c-state (e.g., cs 19460). It looks like they're supposed to be going still, but perhaps the
tick_suspend()andtick_resume()aren't being called properly. Let me take a closer look.-George
Quoted 93 lines · Mukesh Rathor
Quoted 65 lines · George Dunlap
Quoted 48 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending
IPI
to vcpu1. for that, vcpu0 gets into theHYPERVISOR_event_channel_opHCALL and is waiting to return. Meanwhile, vcpu1 got running,
and is
spinning on it's runq lock in
"schedule():spin_lock_irq(&rq->lock);",
that vcpu0 is holding (and is waiting to return from the HCALL).As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As a result, the scheduler always picks vcpu1, and vcpu0 is starved. Also, I
see in
kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out. BTW, just a comment on following (all in sched_credit.c): if ( svc->pri == CSCHED_PRI_TS_UNDER && !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; } comibined with if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext); Setting CSCHED_PRI_TS_BOOST as pri of vcpu seems dangerous. Tome,
sincecsched_schedule()never checks for time accumulated by aQuoted 8 lines
vcpu at pri
CSCHED_PRI_TS_BOOST, that is same as pinning a
vcpu to a
pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally,csched_schedule()should
always
check for cpu time accumulated and reduce the priority over time. I can't tell right off if it already does that. or something like that :)... my 2 cents.Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into OVER (and thus also losing boost).
Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in
csched_acct()? Looks like that's somehow gotten removed. If true, then may be that's the fundamental problem to chase.Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tick data:0000000000000000 2: exp=0x00003ee347ece164 fn:time_calibration data:0000000000000000 3: exp=0x00003ee69a28f04b fn:mce_work_fn data:0000000000000000 4: exp=0x00003f055895e25f fn:plt_overflow data:0000000000000000 5: exp=0x00003ee353810216 fn:rtc_update_second data:ffff83007f0226d8CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fn data:0000000000000000 2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback data:ffff83007f022a68thanks
Mukesh_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Oh, yes, do_softirq is over killing here, we actually only want to handle the TIMER_SOFTIRQ, for other SOFTIRQ, it should simply return.
I will cook a patch for this. thanks for identifying this issue.
Best Regards
Ke
Quoted 210 lines
-----Original Message-----
From: Mukesh Rathor [mailto:[email protected]]
Sent: Friday, July 03, 2009 9:19 AM
To: [email protected]
Cc: George Dunlap; Tian, Kevin; [email protected]; Yu, Ke; Kurt C. Hackel
Subject: Re: [Xen-devel] dom0 hangHi Kevin/Yu:
acpi_processor_idle(){ sched_tick_suspend(); /* * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer, * which will break the later assumption of no sofirq pending, * so add do_softirq */ if ( softirq_pending(smp_processor_id()) ) do_softirq(); <=============== local_irq_disable(); if ( softirq_pending(smp_processor_id()) ) { local_irq_enable(); sched_tick_resume(); cpufreq_dbs_timer_resume(); return; }wouldn't the
do_softirq()call scheduler with tick suspended, and the scheduler then context switches to another vcpu0 (with*_BOOST) which would result in the stuck vcpu I described?thanks
MukeshQuoted 9 lines · Mukesh Rathor
ah, i totally missed
csched_tick():
if ( !is_idle_vcpu(current) )
csched_vcpu_acct(cpu);yeah, looks like that's what is going on. i'm still waiting to reproduce. at first glance, looking at c/s 19460, seems like suspend/resume, well at least the resume, should happen in
csched_schedule().....Quoted 47 lines
thanks,
MukeshQuoted 42 lines · George Dunlap
[Oops, adding back in distro list, also adding Kevin Tian and Yu Ke who wrote cs 19460]
The functionality I was talking about, subtracting credits and clearing BOOST, happens in
csched_vcpu_acct()(which is different thancsched_acct()).vcpu_acct()is called fromcsched_tick(), which should still happen every 10ms on every cpu.The patch I referred to (cs 19460) disables and re-enables tickers in xen/arch/x86/acpi/cpu_idle.c:acpi_processor_idle() every time the processor idles. I can't see anywhere else that tickers are disabled, so it's probably something not properly re-enabling them again.
Try applying the attached patch to see if that changes anything. (I'm on the road, so I can't repro the lockup issue.) If that doesn't work, try disabling c-states and see if that helps. Then at least we'll know where the problem lies.
-George
Quoted 20 lines · Mukesh Rathor
that seems to only suspend csched_pcpu.ticker which is
csched_tickthat is
only sorting local runq.again, we are concerned about csched_priv.master_ticker that calls
csched_acct? correct, so i can trace that?thanks,
mukeshQuoted 8 lines · George Dunlap
Ah, I see that there's been some changes to tick stuff with the c-state (e.g., cs 19460). It looks like they're supposed to be going still, but perhaps the
tick_suspend()andtick_resume()aren't being called properly. Let me take a closer look.-George
On Thu, Jul 2, 2009 at 8:14 PM, Mukesh
Rathor<[email protected]>
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines · wrote:
Quoted 9 lines · George Dunlap
Quoted 6 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending
IPI
to vcpu1. for that, vcpu0 gets into the
HYPERVISOR_event_channel_opQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
HCALL and is waiting to return. Meanwhile, vcpu1 got running,
and is
spinning on it's runq lock in
"schedule():spin_lock_irq(&rq->lock);",
that vcpu0 is holding (and is waiting to return from the HCALL).Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As aresult,
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
the scheduler always picks vcpu1, and vcpu0 is starved. Also, I
see in
kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out. BTW, just a comment on following (all in sched_credit.c): if ( svc->pri == CSCHED_PRI_TS_UNDER && !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; } comibined with if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext);Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Setting
CSCHED_PRI_TS_BOOSTas pri of vcpu seems dangerous.To
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
me,
sincecsched_schedule()never checks for time accumulated by a vcpu at priCSCHED_PRI_TS_BOOST, that is same as pinning a
vcpu to a
pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally,csched_schedule()should
always
check for cpu time accumulated and reduce the priority overtime.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
Quoted 2 lines
I can't tell right off if it already does that. or something like that :)... my 2 cents.
Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into
OVER (and thus also losing boost).Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in
csched_acct()? Looks like that's somehow gotten removed. If true, then may be that's the fundamental problem to chase.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tickdata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003ee347ece164 fn:time_calibration
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
3: exp=0x00003ee69a28f04b fn:mce_work_fn
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
4: exp=0x00003f055895e25f fn:plt_overflow
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
5: exp=0x00003ee353810216 fn:rtc_update_second
data:ffff83007f0226d8
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fndata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback
data:ffff83007f022a68
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
thanks
Mukesh_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi Mukesh,
Could you please try the following patch, to see if it can resolve the issue you observed? Thanks.
Best Regards
Ke
xen/arch/x86/acpi/cpu_idle.c +3 -3
@@ -228,10 +228,10 @@ static void acpi_processor_idle(void)/* * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer, * which will break the later assumption of no sofirq pending, -* so add do_softirq +* so process the pending timers */ -if (softirq_pending (smp_processor_id ()) ) -do_softirq (); + +process_pending_timers ();/* * Interrupts must be disabled during bus mastering calculations and
Quoted 210 lines
-----Original Message-----
From: Mukesh Rathor [mailto:[email protected]]
Sent: Friday, July 03, 2009 9:19 AM
To: [email protected]
Cc: George Dunlap; Tian, Kevin; [email protected]; Yu, Ke; Kurt C. Hackel
Subject: Re: [Xen-devel] dom0 hangHi Kevin/Yu:
acpi_processor_idle(){ sched_tick_suspend(); /* * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer, * which will break the later assumption of no sofirq pending, * so add do_softirq */ if ( softirq_pending(smp_processor_id()) ) do_softirq(); <=============== local_irq_disable(); if ( softirq_pending(smp_processor_id()) ) { local_irq_enable(); sched_tick_resume(); cpufreq_dbs_timer_resume(); return; }wouldn't the
do_softirq()call scheduler with tick suspended, and the scheduler then context switches to another vcpu0 (with*_BOOST) which would result in the stuck vcpu I described?thanks
MukeshQuoted 9 lines · Mukesh Rathor
ah, i totally missed
csched_tick():
if ( !is_idle_vcpu(current) )
csched_vcpu_acct(cpu);yeah, looks like that's what is going on. i'm still waiting to reproduce. at first glance, looking at c/s 19460, seems like suspend/resume, well at least the resume, should happen in
csched_schedule().....Quoted 47 lines
thanks,
MukeshQuoted 42 lines · George Dunlap
[Oops, adding back in distro list, also adding Kevin Tian and Yu Ke who wrote cs 19460]
The functionality I was talking about, subtracting credits and clearing BOOST, happens in
csched_vcpu_acct()(which is different thancsched_acct()).vcpu_acct()is called fromcsched_tick(), which should still happen every 10ms on every cpu.The patch I referred to (cs 19460) disables and re-enables tickers in xen/arch/x86/acpi/cpu_idle.c:acpi_processor_idle() every time the processor idles. I can't see anywhere else that tickers are disabled, so it's probably something not properly re-enabling them again.
Try applying the attached patch to see if that changes anything. (I'm on the road, so I can't repro the lockup issue.) If that doesn't work, try disabling c-states and see if that helps. Then at least we'll know where the problem lies.
-George
Quoted 20 lines · Mukesh Rathor
that seems to only suspend csched_pcpu.ticker which is
csched_tickthat is
only sorting local runq.again, we are concerned about csched_priv.master_ticker that calls
csched_acct? correct, so i can trace that?thanks,
mukeshQuoted 8 lines · George Dunlap
Ah, I see that there's been some changes to tick stuff with the c-state (e.g., cs 19460). It looks like they're supposed to be going still, but perhaps the
tick_suspend()andtick_resume()aren't being called properly. Let me take a closer look.-George
On Thu, Jul 2, 2009 at 8:14 PM, Mukesh
Rathor<[email protected]>
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines · wrote:
Quoted 9 lines · George Dunlap
Quoted 6 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending
IPI
to vcpu1. for that, vcpu0 gets into the
HYPERVISOR_event_channel_opQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
HCALL and is waiting to return. Meanwhile, vcpu1 got running,
and is
spinning on it's runq lock in
"schedule():spin_lock_irq(&rq->lock);",
that vcpu0 is holding (and is waiting to return from the HCALL).Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As aresult,
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
the scheduler always picks vcpu1, and vcpu0 is starved. Also, I
see in
kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out. BTW, just a comment on following (all in sched_credit.c): if ( svc->pri == CSCHED_PRI_TS_UNDER && !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; } comibined with if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext);Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Setting
CSCHED_PRI_TS_BOOSTas pri of vcpu seems dangerous.To
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
me,
sincecsched_schedule()never checks for time accumulated by a vcpu at priCSCHED_PRI_TS_BOOST, that is same as pinning a
vcpu to a
pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally,csched_schedule()should
always
check for cpu time accumulated and reduce the priority overtime.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
Quoted 2 lines
I can't tell right off if it already does that. or something like that :)... my 2 cents.
Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into
OVER (and thus also losing boost).Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in
csched_acct()? Looks like that's somehow gotten removed. If true, then may be that's the fundamental problem to chase.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tickdata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003ee347ece164 fn:time_calibration
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
3: exp=0x00003ee69a28f04b fn:mce_work_fn
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
4: exp=0x00003f055895e25f fn:plt_overflow
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
5: exp=0x00003ee353810216 fn:rtc_update_second
data:ffff83007f0226d8
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fndata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback
data:ffff83007f022a68
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
thanks
Mukesh_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Well, the problem takes long to reproduce (only on certain boxes). And then it may not always happen. So I want to make sure I understand the fix, as it was pretty hard to debug.
While the fix will still allow softirqs pending, I guess, functionally it's OK because after irq disable, it'll check for pending softirq, and just return. I think the comment about expecting no softirq pending should be fixed.
BTW, why can't the tick be suspended when csched_schedule() concludes it's idle vcpu before returning? won't that would make it less intrusive.
thanks,
Mukesh
Quoted 232 lines · Ke
Hi Mukesh,
Could you please try the following patch, to see if it can resolve the issue you observed? Thanks.
Best Regards
Kediff -r
d461c4d8af17xen/arch/x86/acpi/cpu_idle.cxen/arch/x86/acpi/cpu_idle.c +3
-3@@ -228,10 +228,10 @@ static void acpi_processor_idle(void)/* * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer, * which will break the later assumption of no sofirq pending, -* so add do_softirq +* so process the pending timers */ -if (softirq_pending (smp_processor_id ()) ) -do_softirq (); + +process_pending_timers ();/* * Interrupts must be disabled during bus mastering calculations and Quoted 208 lines
-----Original Message-----
From: Mukesh Rathor [mailto:[email protected]]
Sent: Friday, July 03, 2009 9:19 AM
To: [email protected]
Cc: George Dunlap; Tian, Kevin; [email protected]; Yu, Ke; Kurt C. Hackel
Subject: Re: [Xen-devel] dom0 hangHi Kevin/Yu:
acpi_processor_idle(){ sched_tick_suspend(); /* * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer, * which will break the later assumption of no sofirq pending, * so add do_softirq */ if ( softirq_pending(smp_processor_id()) ) do_softirq(); <=============== local_irq_disable(); if ( softirq_pending(smp_processor_id()) ) { local_irq_enable(); sched_tick_resume(); cpufreq_dbs_timer_resume(); return; }wouldn't the
do_softirq()call scheduler with tick suspended, and the scheduler then context switches to another vcpu0 (with*_BOOST) which would result in the stuck vcpu I described?thanks
MukeshQuoted 9 lines · Mukesh Rathor
ah, i totally missed
csched_tick():
if ( !is_idle_vcpu(current) )
csched_vcpu_acct(cpu);yeah, looks like that's what is going on. i'm still waiting to reproduce. at first glance, looking at c/s 19460, seems like suspend/resume, well at least the resume, should happen in
csched_schedule().....Quoted 47 lines
thanks,
MukeshQuoted 42 lines · George Dunlap
[Oops, adding back in distro list, also adding Kevin Tian and Yu Ke who wrote cs 19460]
The functionality I was talking about, subtracting credits and clearing BOOST, happens in
csched_vcpu_acct()(which is different thancsched_acct()).vcpu_acct()is called fromcsched_tick(), which should still happen every 10ms on every cpu.The patch I referred to (cs 19460) disables and re-enables tickers in xen/arch/x86/acpi/cpu_idle.c:acpi_processor_idle() every time the processor idles. I can't see anywhere else that tickers are disabled, so it's probably something not properly re-enabling them again.
Try applying the attached patch to see if that changes anything. (I'm on the road, so I can't repro the lockup issue.) If that doesn't work, try disabling c-states and see if that helps. Then at least we'll know where the problem lies.
-George
Quoted 20 lines · Mukesh Rathor
that seems to only suspend csched_pcpu.ticker which is
csched_tickthat is
only sorting local runq.again, we are concerned about csched_priv.master_ticker that calls
csched_acct? correct, so i can trace that?thanks,
mukeshQuoted 8 lines · George Dunlap
Ah, I see that there's been some changes to tick stuff with the c-state (e.g., cs 19460). It looks like they're supposed to be going still, but perhaps the
tick_suspend()andtick_resume()aren't being called properly. Let me take a closer look.-George
On Thu, Jul 2, 2009 at 8:14 PM, Mukesh
Rathor<[email protected]>
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines · wrote:
Quoted 9 lines · George Dunlap
Quoted 6 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending
IPI
to vcpu1. for that, vcpu0 gets into the
HYPERVISOR_event_channel_opQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
HCALL and is waiting to return. Meanwhile, vcpu1 got running,
and is
spinning on it's runq lock in
"schedule():spin_lock_irq(&rq->lock);",
that vcpu0 is holding (and is waiting to return from the HCALL).Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As aresult,
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
the scheduler always picks vcpu1, and vcpu0 is starved. Also, I
see in
kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out. BTW, just a comment on following (all in sched_credit.c): if ( svc->pri == CSCHED_PRI_TS_UNDER && !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; } comibined with if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext);Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Setting
CSCHED_PRI_TS_BOOSTas pri of vcpu seems dangerous.To
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
me,
sincecsched_schedule()never checks for time accumulated by a vcpu at priCSCHED_PRI_TS_BOOST, that is same as pinning a
vcpu to a
pcpu. if that vcpu never makes progress, essentially, the system has lost a physical cpu. Optionally,csched_schedule()should
always
check for cpu time accumulated and reduce the priority overtime.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
Quoted 2 lines
I can't tell right off if it already does that. or something like that :)... my 2 cents.
Hmm... what's supposed to happen is that eventually a timer tick will interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER, and lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into
OVER (and thus also losing boost).Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in
csched_acct()? Looks like that's somehow gotten removed. If true, then may be that's the fundamental problem to chase.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tickdata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003ee347ece164 fn:time_calibration
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
3: exp=0x00003ee69a28f04b fn:mce_work_fn
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
4: exp=0x00003f055895e25f fn:plt_overflow
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
5: exp=0x00003ee353810216 fn:rtc_update_second
data:ffff83007f0226d8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fndata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback
data:ffff83007f022a68
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
thanks
Mukesh_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 9 lines
-----Original Message-----
From: Mukesh Rathor [mailto:[email protected]]
Sent: Tuesday, July 07, 2009 11:47 AM
To: Yu, Ke
Cc: George Dunlap; Tian, Kevin; [email protected]; Kurt C. Hackel
Subject: Re: [Xen-devel] dom0 hang
Quoted 3 lines
Well, the problem takes long to reproduce (only on certain boxes). And then it may not always happen. So I want to make sure I understand the fix, as it was pretty hard to debug.
Ok, looking forward your update.
Quoted 5 lines
While the fix will still allow softirqs pending, I guess, functionally it's OK because after irq disable, it'll check for pending softirq, and just return. I think the comment about expecting no softirq pending should be fixed.
Right. the comment will also be fixed.
Quoted 3 lines
BTW, why can't the tick be suspended when
csched_schedule()concludes it's idle vcpu before returning? won't that would make it less intrusive.
The tick suspend can be put in csched_schedule, but the suspend/resume logic is still needed in acpi_processor_idle anyway, due to another dbs_timer suspend/resume. The intention here is to make acpi_processor_idle the central place for timers which are stoppable during idle period. If there is other stoppable timer in the future, it can be easily added to acpi_processor_idle. So it is clean to keep current logic. and as long as we carefully not over doing the softirq, it looks not so intrusive. How do you think?
Best Regards
Ke
Quoted 248 lines
thanks,
MukeshQuoted 3 lines · Ke
Hi Mukesh,
Could you please try the following patch, to see if it can resolve the issue
you observed? Thanks.
Quoted 22 lines
Best Regards
Kediff -r
d461c4d8af17xen/arch/x86/acpi/cpu_idle.cxen/arch/x86/acpi/cpu_idle.c +3
-3@@ -228,10 +228,10 @@ static void acpi_processor_idle(void)/* * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer, * which will break the later assumption of no sofirq pending, -* so add do_softirq +* so process the pending timers */ -if (softirq_pending (smp_processor_id ()) ) -do_softirq (); + +process_pending_timers ();/* * Interrupts must be disabled during bus mastering calculations and Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: Mukesh Rathor [mailto:[email protected]]
Sent: Friday, July 03, 2009 9:19 AM
To: [email protected]
Cc: George Dunlap; Tian, Kevin; [email protected]; Yu, Ke;Kurt C.
Quoted 26 lines
Quoted 26 lines
Hackel
Subject: Re: [Xen-devel] dom0 hangHi Kevin/Yu:
acpi_processor_idle(){ sched_tick_suspend(); /* * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer, * which will break the later assumption of no sofirq pending, * so add do_softirq */ if ( softirq_pending(smp_processor_id()) ) do_softirq(); <=============== local_irq_disable(); if ( softirq_pending(smp_processor_id()) ) { local_irq_enable(); sched_tick_resume(); cpufreq_dbs_timer_resume(); return; }Quoted 2 lines
Quoted 2 lines
wouldn't the
do_softirq()call scheduler with tick suspended, and the scheduler then context switches to another vcpu0 (with*_BOOST)which
Quoted 116 lines
Quoted 116 lines
would result in the stuck vcpu I described?
thanks
MukeshQuoted 9 lines · Mukesh Rathor
ah, i totally missed
csched_tick():
if ( !is_idle_vcpu(current) )
csched_vcpu_acct(cpu);yeah, looks like that's what is going on. i'm still waiting to reproduce. at first glance, looking at c/s 19460, seems like suspend/resume, well at least the resume, should happen in
csched_schedule().....Quoted 47 lines
thanks,
MukeshQuoted 42 lines · George Dunlap
[Oops, adding back in distro list, also adding Kevin Tian and Yu Ke who wrote cs 19460]
The functionality I was talking about, subtracting credits and clearing BOOST, happens in
csched_vcpu_acct()(which is different thancsched_acct()).vcpu_acct()is called fromcsched_tick(), which should still happen every 10ms on every cpu.The patch I referred to (cs 19460) disables and re-enables tickers in xen/arch/x86/acpi/cpu_idle.c:acpi_processor_idle() every time the processor idles. I can't see anywhere else that tickers are disabled, so it's probably something not properly re-enabling them again.
Try applying the attached patch to see if that changes anything. (I'm on the road, so I can't repro the lockup issue.) If that doesn't work, try disabling c-states and see if that helps. Then at least we'll know where the problem lies.
-George
Quoted 20 lines · Mukesh Rathor
that seems to only suspend csched_pcpu.ticker which is
csched_tickthat is
only sorting local runq.again, we are concerned about csched_priv.master_ticker that calls
csched_acct? correct, so i can trace that?thanks,
mukeshQuoted 8 lines · George Dunlap
Ah, I see that there's been some changes to tick stuff with the c-state (e.g., cs 19460). It looks like they're supposed to be going still, but perhaps the
tick_suspend()andtick_resume()aren't being called properly. Let me take a closer look.-George
On Thu, Jul 2, 2009 at 8:14 PM, Mukesh
Rathor<[email protected]>
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines · wrote:
Quoted 9 lines · George Dunlap
Quoted 6 lines · Mukesh Rathor
dom0 hang:
vcpu0 is trying to wakeup a task and intry_to_wake_up()callstask_rq_lock(). since the task has cpu set to 1, it gets runq lock for vcpu1. next it callsresched_task()which results in sending
IPI
to vcpu1. for that, vcpu0 gets into the
HYPERVISOR_event_channel_opQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
HCALL and is waiting to return. Meanwhile, vcpu1 got running,
and is
spinning on it's runq lock in
"schedule():spin_lock_irq(&rq->lock);",
that vcpu0 is holding (and is waiting to return from the HCALL).Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
As I had noticed before, vcpu0 never gets scheduled in xen. So looking further into xen:
xen:
Both vcpu's are on the same runq, in this case cpu1. But the priority of vcpu1 has been set toCSCHED_PRI_TS_BOOST. As aresult,
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
the scheduler always picks vcpu1, and vcpu0 is starved. Also, I
see in
kdb that the scheduler timer is not set on cpu 0. That would've allowedcsched_load_balance()to kick in on cpu0. [Also, on cpu1, the accounting timer,csched_tick, is not set. Altho,csched_tick()is running on cpu0, it only checks runq for cpu0.]Looks like c/s 19500 changed
csched_schedule():(quoted diff) +2
-1- ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); + ret.time = (is_idle_vcpu(snext->vcpu) ? + -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE)); The quickest fix for us would be to just back that out. BTW, just a comment on following (all in sched_credit.c): if ( svc->pri == CSCHED_PRI_TS_UNDER && !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; } comibined with if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext);Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Setting
CSCHED_PRI_TS_BOOSTas pri of vcpu seemsdangerous.
Quoted 3 lines
Quoted 3 lines
To
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
me,
sincecsched_schedule()never checks for time accumulatedby a
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
vcpu at pri
CSCHED_PRI_TS_BOOST, that is same as pinning a
vcpu to a
pcpu. if that vcpu never makes progress, essentially, thesystem
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
has lost a physical cpu. Optionally,
csched_schedule()should
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
always
check for cpu time accumulated and reduce the priority overtime.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
I can't tell right off if it already does that. or something like that :)... my 2 cents.
Hmm... what's supposed to happen is that eventually a timer tick
will
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
interrupt vcpu1. If cpu1 is set to be "active", then it will be debited 10ms worth of credit. Eventually, it will go into OVER,
and
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lose BOOST. If it's "inactive", then when the tick happens, it will be set to "active" and be debited 10ms again, setting it directly into
OVER (and thus also losing boost).Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Can you see if the timer ticks are still happening, and perhaps put some tracing it to verify that what I described above is happening?
-George
George,
Is that in
csched_acct()? Looks like that's somehow gotten removed.If
Quoted 30 lines
Quoted 30 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
true, then may be that's the fundamental problem to chase.
Here's what the trq looks like when hung, not in any schedule function:
[0]xkdb> dtrq
CPU[00]: NOW:0x00003f2db9af369e
1: exp=0x00003ee31cb32200 fn:csched_tickdata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003ee347ece164 fn:time_calibration
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
3: exp=0x00003ee69a28f04b fn:mce_work_fn
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
4: exp=0x00003f055895e25f fn:plt_overflow
data:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
5: exp=0x00003ee353810216 fn:rtc_update_second
data:ffff83007f0226d8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CPU[01]: NOW:0x00003f2db9af369e
1: exp=0x00003ee30b847988 fn:s_timer_fndata:0000000000000000
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
2: exp=0x00003f1b309ebd45 fn:pmt_timer_callback
data:ffff83007f022a68
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
thanks
Mukesh_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 10 lines · Ke
Quoted 2 lines
BTW, why can't the tick be suspended when
csched_schedule()concludes it's idle vcpu before returning? won't that would make it less intrusive.The tick suspend can be put in
csched_schedule, but the suspend/resume logic is still needed inacpi_processor_idleanyway, due to anotherdbs_timersuspend/resume. The intention here is to makeacpi_processor_idlethe central place for timers which are stoppable during idle period. If there is other stoppable timer in the future, it can be easily added toacpi_processor_idle. So it is clean to keep current logic. and as long as we carefully not over doing the softirq, it looks not so intrusive. How do you think?
I think the approach is fine. I also already applied your patch since it is obviously a good bug fix, even if it doesn't fix Mukesh's bug. And I fixed the comment at the same time. And I backported it for Xen 3.4.1.
-- Keir
Quoted 12 lines · Keir Fraser
Quoted 9 lines · Ke
Quoted 2 lines
BTW, why can't the tick be suspended when
csched_schedule()concludes it's idle vcpu before returning? won't that would make it less intrusive.The tick suspend can be put in
csched_schedule, but the suspend/resume logic is still needed inacpi_processor_idleanyway, due to anotherdbs_timersuspend/resume. The intention here is to makeacpi_processor_idlethe central place for timers which are stoppable during idle period. If there is other stoppable timer in the future, it can be easily added toacpi_processor_idle. So it is clean to keep current logic. and as long as we carefully not over doing the softirq, it looks not so intrusive. How do you think?
Quoted 6 lines
I think the approach is fine. I also already applied your patch since it is obviously a good bug fix, even if it doesn't fix Mukesh's bug. And I fixed the comment at the same time. And I backported it for Xen 3.4.1.
-- Keir
It fixes my bug.
Thanks,
Mukesh