sched: fix cpu offlining with core scheduling
authorJuergen Gross <jgross@suse.com>
Thu, 26 Mar 2020 11:23:59 +0000 (12:23 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 26 Mar 2020 11:23:59 +0000 (12:23 +0100)
commitb6f5334aeaca133ad47ade06f4d22baf5984b55d
tree76b2e21587b04c1cfc648c26adc7e3297d14a287
parent0537d246f8db3ac0a1df2ce653b07e85cd887962
sched: fix cpu offlining with core scheduling

Offlining a cpu with core scheduling active can result in a hanging
system. Reason is the scheduling resource and unit of the to be removed
cpus needs to be split in order to remove the cpu from its cpupool and
move it to the idle scheduler. In case one of the involved cpus happens
to have received a sched slave event due to a vcpu former having been
running on that cpu being woken up again, it can happen that this cpu
will enter sched_wait_rendezvous_in() while its scheduling resource is
just about to be split. It might wait for ever for the other sibling
to join, which will never happen due to the resources already being
modified.

This can easily be avoided by:
- resetting the rendezvous counters of the idle unit which is kept
- checking for a new scheduling resource in sched_wait_rendezvous_in()
  after reacquiring the scheduling lock and resetting the counters in
  that case without scheduling another vcpu
- moving schedule resource modifications (in schedule_cpu_rm()) and
  retrieving (schedule(), sched_slave() is fine already, others are not
  critical) into locked regions

Reported-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/sched/core.c