Re: [PATCH] KVM: x86: async_pf: check earlier if can deliver async pf
From: Sean Christopherson
Date: Thu Nov 21 2024 - 16:05:43 EST
On Thu, Nov 21, 2024, Nikita Kalyazin wrote:
> On 19/11/2024 13:24, Sean Christopherson wrote:
> > None of this justifies breaking host-side, non-paravirt async page faults. If a
> > vCPU hits a missing page, KVM can schedule out the vCPU and let something else
> > run on the pCPU, or enter idle and let the SMT sibling get more cycles, or maybe
> > even enter a low enough sleep state to let other cores turbo a wee bit.
> >
> > I have no objection to disabling host async page faults, e.g. it's probably a net
> > negative for 1:1 vCPU:pCPU pinned setups, but such disabling needs an opt-in from
> > userspace.
>
> That's a good point, I didn't think about it. The async work would still
> need to execute somewhere in that case (or sleep in GUP until the page is
> available).
The "async work" is often an I/O operation, e.g. to pull in the page from disk,
or over the network from the source. The *CPU* doesn't need to actively do
anything for those operations. The I/O is initiated, so the CPU can do something
else, or go idle if there's no other work to be done.
> If processing the fault synchronously, the vCPU thread can also sleep in the
> same way freeing the pCPU for something else,
If and only if the vCPU can handle a PV async #PF. E.g. if the guest kernel flat
out doesn't support PV async #PF, or the fault happened while the guest was in an
incompatible mode, etc.
If KVM doesn't do async #PFs of any kind, the vCPU will spin on the fault until
the I/O completes and the page is ready.
> so the amount of work to be done looks equivalent (please correct me
> otherwise). What's the net gain of moving that to an async work in the host
> async fault case? "while allowing interrupt delivery into the guest." -- is
> this the main advantage?