From: Nikita Kalyazin <kalyazin@amazon.com>
To: Sean Christopherson <seanjc@google.com>
Cc: <pbonzini@redhat.com>, <tglx@linutronix.de>, <mingo@redhat.com>,
<bp@alien8.de>, <dave.hansen@linux.intel.com>, <hpa@zytor.com>,
<kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<david@redhat.com>, <peterx@redhat.com>, <oleg@redhat.com>,
<vkuznets@redhat.com>, <gshan@redhat.com>, <graf@amazon.de>,
<jgowans@amazon.com>, <roypat@amazon.co.uk>, <derekmn@amazon.com>,
<nsaenz@amazon.es>, <xmarcalx@amazon.com>
Subject: Re: [PATCH] KVM: x86: async_pf: check earlier if can deliver async pf
Date: Wed, 27 Nov 2024 10:35:17 +0000 [thread overview]
Message-ID: <522cb8d6-63fa-4450-a786-86da64f8ecc3@amazon.com> (raw)
In-Reply-To: <Z0ZHSHxpagw_HXDQ@google.com>
On 26/11/2024 22:10, Sean Christopherson wrote:
> On Tue, Nov 26, 2024, Nikita Kalyazin wrote:
>> On 26/11/2024 00:06, Sean Christopherson wrote:
>>> On Mon, Nov 25, 2024, Nikita Kalyazin wrote:
>>>> In both cases the fault handling code is blocked and the pCPU is free for
>>>> other tasks. I can't see the vCPU spinning on the IO to get completed if
>>>> the async task isn't created. I tried that with and without async PF
>>>> enabled by the guest (MSR_KVM_ASYNC_PF_EN).
>>>>
>>>> What am I missing?
>>>
>>> Ah, I was wrong about the vCPU spinning.
>>>
>>> The goal is specifically to schedule() from KVM context, i.e. from kvm_vcpu_block(),
>>> so that if a virtual interrupt arrives for the guest, KVM can wake the vCPU and
>>> deliver the IRQ, e.g. to reduce latency for interrupt delivery, and possible even
>>> to let the guest schedule in a different task if the IRQ is the guest's tick.
>>>
>>> Letting mm/ or fs/ do schedule() means the only wake event even for the vCPU task
>>> is the completion of the I/O (or whatever the fault is waiting on).
>>
>> Ok, great, then that's how I understood it last time. The only thing that
>> is not entirely clear to me is like Vitaly says, KVM_ASYNC_PF_SEND_ALWAYS is
>> no longer set, because we don't want to inject IRQs into the guest when it's
>> in kernel mode, but the "host async PF" case would still allow IRQs (eg
>> ticks like you said). Why is it safe to deliver them?
>
> IRQs are fine, the problem with PV async #PF is that it directly injects a #PF,
> which the kernel may not be prepared to handle.
You're right indeed, I was overfocused on IRQs for some reason.
>>>>>>> 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.
>> Back to this, I couldn't see a significant effect of this optimisation with
>> the original async PF so happy to give it up, but it does make a difference
>> when applied to async PF user [2] in my setup. Would a new cap be a good
>> way for users to express their opt-in for it?
>
> This probably needs to be handled in the context of the async #PF user series.
> If that series never lands, adding a new cap is likely a waste. And I suspect
> that even then, a capability may not be warranted (truly don't know, haven't
> looked at your other series).
Yes, I meant that to be included in the async #PF user series (if
required), not this one. Just wanted to bring it up here, because the
thread already had the relevant context. Thanks.
prev parent reply other threads:[~2024-11-27 10:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 13:04 Nikita Kalyazin
2024-11-18 17:58 ` Vitaly Kuznetsov
2024-11-21 18:10 ` Nikita Kalyazin
2024-11-22 9:33 ` Vitaly Kuznetsov
2024-11-22 14:32 ` Sean Christopherson
2024-11-19 13:24 ` Sean Christopherson
2024-11-21 17:59 ` Nikita Kalyazin
2024-11-21 21:05 ` Sean Christopherson
2024-11-25 15:50 ` Nikita Kalyazin
2024-11-26 0:06 ` Sean Christopherson
2024-11-26 15:35 ` Nikita Kalyazin
2024-11-26 22:10 ` Sean Christopherson
2024-11-27 10:35 ` Nikita Kalyazin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=522cb8d6-63fa-4450-a786-86da64f8ecc3@amazon.com \
--to=kalyazin@amazon.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=derekmn@amazon.com \
--cc=graf@amazon.de \
--cc=gshan@redhat.com \
--cc=hpa@zytor.com \
--cc=jgowans@amazon.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nsaenz@amazon.es \
--cc=oleg@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=roypat@amazon.co.uk \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=xmarcalx@amazon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®