sched: fix scheduler_disable() with core scheduling
PATCH 1/1 sched: fix scheduler_disable() with core scheduling
In core-scheduling mode, Xen might crash when entering ACPI S5 state. This happens in sched_slave() during is_idle_unit(next) check because next->vcpu_list is stale and points to an already freed memory.
This situation happens shortly after scheduler_disable() is called if some CPU is still inside sched_slave() softirq. Current logic simply returns prev->next_task from sched_wait_rendezvous_in() which causes the described crash because next_task->vcpu_list has become invalid.
Fix the crash by returning NULL from sched_wait_rendezvous_in() in the case when scheduler_disable() has been called.
---
CC: Juergen Gross <[email protected]>
CC: Dario Faggioli <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
--- xen/common/sched/core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
xen/common/sched/core.c +4 -8
@@ -2484,19 +2484,15 @@ static struct sched_unit *sched_wait_rendezvous_in(struct sched_unit *prev, *lock =pcpu_schedule_lock_irq (cpu); -if (unlikely (!scheduler_active) ) - { -ASSERT (is_idle_unit (prev)); -atomic_set (&prev->next_task->rendezvous_out_cnt,0 ); - prev->rendezvous_in_cnt =0 ; - } -/* * Check for scheduling resource switched. This happens when we are * moved away from our cpupool and cpus are subject of the idle * scheduler now. +* +* This is also a bail out case when scheduler_disable() has been +* called. */ -if (unlikely (sr !=get_sched_res (cpu)) ) +if (unlikely (sr !=get_sched_res (cpu) || !scheduler_active) ) {ASSERT (is_idle_unit (prev));atomic_set (&prev->next_task->rendezvous_out_cnt,0 );
Signature · 1 line
2.17.1
Quoted 9 lines · Sergey Dyasli
In core-scheduling mode, Xen might crash when entering ACPI S5 state. This happens in
sched_slave()duringis_idle_unit(next)check becausenext->vcpu_listis stale and points to an already freed memory.This situation happens shortly after
scheduler_disable()is called if some CPU is still insidesched_slave()softirq. Current logic simply returnsprev->next_taskfromsched_wait_rendezvous_in()which causes the described crash becausenext_task->vcpu_listhas become invalid.
Quoted 4 lines
Fix the crash by returning NULL from
sched_wait_rendezvous_in()in the case whenscheduler_disable()has been called.Signed-off-by Sergey Dyasli <[email protected]>
Good catch!
Have you seen any further problems (e.g. with cpu on/offlining) with this patch applied?
Juergen
(CC Igor)
Quoted 13 lines · Jürgen Groß
Quoted 12 lines · Sergey Dyasli
In core-scheduling mode, Xen might crash when entering ACPI S5 state. This happens in
sched_slave()duringis_idle_unit(next)check becausenext->vcpu_listis stale and points to an already freed memory.This situation happens shortly after
scheduler_disable()is called if some CPU is still insidesched_slave()softirq. Current logic simply returnsprev->next_taskfromsched_wait_rendezvous_in()which causes the described crash becausenext_task->vcpu_listhas become invalid.Fix the crash by returning NULL from
sched_wait_rendezvous_in()in the case whenscheduler_disable()has been called.
Quoted 6 lines
Quoted 1 line
Signed-off-by Sergey Dyasli <[email protected]>Good catch!
Have you seen any further problems (e.g. with cpu on/offlining) with this patch applied?
This patch shouldn't affect cpu on/offlining AFAICS. Igor was the one testing cpu on/offlining and I think he came to a conclusion that it's broken even without core-scheduling enabled.
Quoted 1 line
Reviewed-by Juergen Gross <[email protected]>
Thanks!
--
Sergey
Dario Faggioli
Reviewed-byQuoted 16 lines · Jürgen Groß
Quoted 15 lines · Sergey Dyasli
In core-scheduling mode, Xen might crash when entering ACPI S5 state.
This happens insched_slave()duringis_idle_unit(next)check becausenext->vcpu_listis stale and points to an already freed memory.This situation happens shortly after
scheduler_disable()is called if
some CPU is still insidesched_slave()softirq. Current logic simply
returnsprev->next_taskfromsched_wait_rendezvous_in()which causes
the described crash becausenext_task->vcpu_listhas become invalid.
Quoted 7 lines
Quoted 4 lines
Fix the crash by returning NULL from
sched_wait_rendezvous_in()in the case whenscheduler_disable()has been called.Signed-off-by Sergey Dyasli <[email protected]>Reviewed-by Juergen Gross <[email protected]>
Thanks and Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)