xen: credit2: fix shutdown/suspend when playing with cpupools.
In fact, during shutdown/suspend, we temporarily move all
the vCPUs to the BSP (i.e., pCPU 0, as of now). For Credit2
domains, we call csched2_vcpu_migrate(), expects to find the
target pCPU in the domain's pool
Therefore, if Credit2 is the default scheduler and we have
removed pCPU 0 from cpupool0, shutdown/suspend fails like
this:
RIP: e008:[<
ffff82d08012906d>] sched_credit2.c#migrate+0x274/0x2d1
Xen call trace:
[<
ffff82d08012906d>] sched_credit2.c#migrate+0x274/0x2d1
[<
ffff82d080129138>] sched_credit2.c#csched2_vcpu_migrate+0x6e/0x86
[<
ffff82d08012c468>] schedule.c#vcpu_move_locked+0x69/0x6f
[<
ffff82d08012ec14>] cpu_disable_scheduler+0x3d7/0x430
[<
ffff82d08019669b>] __cpu_disable+0x299/0x2b0
[<
ffff82d0801012f8>] cpu.c#take_cpu_down+0x2f/0x38
[<
ffff82d0801312d8>] stop_machine.c#stopmachine_action+0x7f/0x8d
[<
ffff82d0801330b8>] tasklet.c#do_tasklet_work+0x74/0xab
[<
ffff82d0801333ed>] do_tasklet+0x66/0x8b
[<
ffff82d080166a73>] domain.c#idle_loop+0x3b/0x5e
****************************************
Panic on CPU 8:
Assertion 'svc->vcpu->processor < nr_cpu_ids' failed at sched_credit2.c:1729
****************************************
On the other hand, if Credit2 is the scheduler of another
pool, when trying (still during shutdown/suspend) to move
the vCPUs of the Credit2 domains to pCPU 0, it figures
out that pCPU 0 is not a Credit2 pCPU, and fails like this:
RIP: e008:[<
ffff82d08012916b>] sched_credit2.c#csched2_vcpu_migrate+0xa1/0x107
Xen call trace:
[<
ffff82d08012916b>] sched_credit2.c#csched2_vcpu_migrate+0xa1/0x107
[<
ffff82d08012c4e9>] schedule.c#vcpu_move_locked+0x69/0x6f
[<
ffff82d08012edfc>] cpu_disable_scheduler+0x3d7/0x430
[<
ffff82d08019687b>] __cpu_disable+0x299/0x2b0
[<
ffff82d0801012f8>] cpu.c#take_cpu_down+0x2f/0x38
[<
ffff82d0801314c0>] stop_machine.c#stopmachine_action+0x7f/0x8d
[<
ffff82d0801332a0>] tasklet.c#do_tasklet_work+0x74/0xab
[<
ffff82d0801335d5>] do_tasklet+0x66/0x8b
[<
ffff82d080166c53>] domain.c#idle_loop+0x3b/0x5e
The solution is to recognise the specific situation, inside
csched2_vcpu_migrate() and, considering it is something temporary,
which only happens during shutdown/suspend, quickly deal with it.
Then, in the resume path, in restore_vcpu_affinity(), things
are set back to normal, and a new v->processor is chosen, for
each vCPU, from the proper set of pCPUs (i.e., the ones of
the proper cpupool).
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>