xen/sched: add fall back to idle vcpu when scheduling unit
authorJuergen Gross <jgross@suse.com>
Wed, 2 Oct 2019 07:27:32 +0000 (09:27 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 4 Oct 2019 10:57:24 +0000 (12:57 +0200)
commitbe9dde875792517be55e986f8a65ccdfb5c67dfe
tree95c0cd96ef0a3890b83a343c6375d549e2be8093
parent6a4d4066756ca655026b73dfa7b5e8f9a001b9a3
xen/sched: add fall back to idle vcpu when scheduling unit

When scheduling an unit with multiple vcpus there is no guarantee all
vcpus are available (e.g. above maxvcpus or vcpu offline). Fall back to
idle vcpu of the current cpu in that case. This requires to store the
correct schedule_unit pointer in the idle vcpu as long as it used as
fallback vcpu.

In order to modify the runstates of the correct vcpus when switching
schedule units merge sched_unit_runstate_change() into
sched_switch_units() and loop over the affected physical cpus instead
of the unit's vcpus. This in turn requires an access function to the
current variable of other cpus.

Today context_saved() is called in case previous and next vcpus differ
when doing a context switch. With an idle vcpu being capable to be a
substitute for an offline vcpu this is problematic when switching to
an idle scheduling unit. An idle previous vcpu leaves us in doubt which
schedule unit was active previously, so save the previous unit pointer
in the per-schedule resource area. If it is NULL the unit has not
changed and we don't have to set the previous unit to be not running.

When running an idle vcpu in a non-idle scheduling unit use a specific
guest idle loop not performing any non-softirq tasklets and
livepatching in order to avoid populating the cpu caches with memory
used by other domains (as far as possible). Softirqs are considered to
be save.

In order to avoid livepatching when going to guest idle another
variant of reset_stack_and_jump() not calling check_for_livepatch_work
is needed.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domain.c
xen/common/schedule.c
xen/include/asm-arm/current.h
xen/include/asm-x86/current.h
xen/include/asm-x86/smp.h
xen/include/xen/sched-if.h
xen/include/xen/sched.h