Re: [PATCH v2 0/9] sched/kvm: Semantics-aware vCPU scheduling for oversubscribed KVM
From: Sean Christopherson
Date: Thu Mar 12 2026 - 21:13:46 EST
On Fri, Dec 19, 2025, Wanpeng Li wrote:
> Part 2: KVM IPI-Aware Directed Yield (patches 6-9)
>
> Enhance kvm_vcpu_on_spin() with lightweight IPI tracking to improve
> directed yield candidate selection. Track sender/receiver relationships
> when IPIs are delivered and use this information to prioritize yield
> targets.
>
> The tracking mechanism:
>
> - Hooks into kvm_irq_delivery_to_apic() to detect unicast fixed IPIs (the
> common case for inter-processor synchronization). When exactly one
> destination vCPU receives an IPI, record the sender->receiver relationship
> with a monotonic timestamp.
>
> In high VM density scenarios, software-based IPI tracking through
> interrupt delivery interception becomes particularly valuable. It
> captures precise sender/receiver relationships that can be leveraged
> for intelligent scheduling decisions, providing performance benefits
> that complement or even exceed hardware-accelerated interrupt delivery
> in overcommitted environments.
>
> - Uses lockless READ_ONCE/WRITE_ONCE accessors for minimal overhead. The
> per-vCPU ipi_context structure is carefully designed to avoid cache line
> bouncing.
>
> - Implements a short recency window (50ms default) to avoid stale IPI
> information inflating boost priority on throughput-sensitive workloads.
> Old IPI relationships are naturally aged out.
>
> - Clears IPI context on EOI with two-stage precision: unconditionally clear
> the receiver's context (it processed the interrupt), but only clear the
> sender's pending flag if the receiver matches and the IPI is recent. This
> prevents unrelated EOIs from prematurely clearing valid IPI state.
That all relies on lack of IPI and EOI virtualization, which seems very
counter-productive given the way hardware is headed.
My reaction to all of this is that in the long run, we'd be far better off getting
the guest to "cooperate" in the sense of communicating intent, status, etc. As
a stop-gap for older hardware, this obviously is beneficial. But AFAICT the IPI
tracking is going to be dead weight in the near future.
And there are many, many use cases that what PV scheduling, i.e. if people band
together, I suspect it's feasible to get Linux-as-a-guest to provide hints to the
host that can be used to make scheduling decisions.
> Performance Results
> -------------------
>
> Test environment: Intel Xeon, 16 physical cores, 16 vCPUs per VM
What generation of CPU?