xen/sched: fix csched2_deinit_pdata()
authorJuergen Gross <jgross@suse.com>
Fri, 17 May 2019 13:41:17 +0000 (15:41 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 17 May 2019 13:41:17 +0000 (15:41 +0200)
commitffd3367ed682b6ac6f57fcb151921054dd4cce7e
treedecd0ad54c6e196d87d899f3a158a22a75ea1a1a
parent9cf11fdcd91ff8e9cd038f8336cf21f0701e8b7b
xen/sched: fix csched2_deinit_pdata()

Commit 753ba43d6d16e688 ("xen/sched: fix credit2 smt idle handling")
introduced a regression when switching cpus between cpupools.

When assigning a cpu to a cpupool with credit2 being the default
scheduler csched2_deinit_pdata() is called for the credit2 private data
after the new scheduler's private data has been hooked to the per-cpu
scheduler data. Unfortunately csched2_deinit_pdata() will cycle through
all per-cpu scheduler areas it knows of for removing the cpu from the
respective sibling masks including the area of the just moved cpu. This
will (depending on the new scheduler) either clobber the data of the
new scheduler or in case of sched_rt lead to a crash.

Avoid that by removing the cpu from the list of active cpus in credit2
data first.

The opposite problem is occurring when removing a cpu from a cpupool:
init_pdata() of credit2 will access the per-cpu data of the old
scheduler.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/sched_credit2.c