Re: [PATCH 4/4] KVM guest implementation

From: Peter Zijlstra
Date: Tue Aug 31 2021 - 03:23:04 EST


On Tue, Aug 31, 2021 at 09:59:19AM +0800, Tianqiang Xu wrote:
> Guest OS uses 'is_idle' field of kvm_steal_time to know if a pCPU
> is idle and decides whether to schedule a task to a preempted vCPU
> or not. If the pCPU is idle, scheduling a task to this pCPU will
> improve cpu utilization. If not, avoiding scheduling a task to this
> preempted vCPU can avoid host/guest switch, hence improving performance.
>
> Guest OS invokes available_idle_cpu_sched() to get the value of
> 'is_idle' field of kvm_steal_time.
>
> Other modules in kernel except kernel/sched/fair.c which invokes
> available_idle_cpu() is left unchanged, because other modules in
> kernel need the semantic provided by 'preempted' field of kvm_steal_time.

> ---
> kernel/sched/fair.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)

Goes and replaces every single available_idle_cpu() in fair with the new
function that doesn't consider vCPU preemption.

So what do you reckon now happens in the oversubscribed virt scenario
where each CPU has multiple vCPUs?