All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Alexander Graf <graf@amazon.de>,
	kvm@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org,
	Nicolas Saenz Julienne <nsaenz@amazon.es>,
	Fred Griffoul <fgriffo@amazon.com>
Subject: Re: [RFC] KVM: x86: Allow userspace exit on HLT and MWAIT, else yield on MWAIT
Date: Tue, 26 Sep 2023 13:29:36 -0700	[thread overview]
Message-ID: <ZRM_MHBpePiAQ__1@google.com> (raw)
In-Reply-To: <21C2A5D8-66D9-4EF0-A416-4B1049C91E83@infradead.org>

On Tue, Sep 26, 2023, David Woodhouse wrote:
> 
> 
> On 26 September 2023 19:20:24 CEST, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >On Sat, Sep 23, 2023 at 6:44 PM Alexander Graf <graf@amazon.de> wrote:
> >> On 23.09.23 11:24, Paolo Bonzini wrote:
> >> > Why do you need it?  You can just use KVM_RUN to go to sleep, and if you
> >> > get another job you kick out the vCPU with pthread_kill.  (I also didn't
> >> > get the VSM reference).
> >>
> >> With the original VSM patches, we used to make a vCPU aware of the fact
> >> that it can morph into one of many VTLs. That approach turned out to be
> >> insanely intrusive and fragile and so we're currently reimplementing
> >> everything as VTLs as vCPUs. That allows us to move the majority of VSM
> >> functionality to user space. Everything we've seen so far looks as if
> >> there is no real performance loss with that approach.
> >
> >Yes, that was also what I remember, sharing the FPU somehow while
> >having separate vCPU file descriptors.
> >
> >> One small problem with that is that now user space is responsible for
> >> switching between VTLs: It determines which VTL is currently running and
> >> leaves all others (read: all other vCPUs) as stopped. That means if you
> >> are running happily in KVM_RUN in VTL0 and VTL1 gets an interrupt, user
> >> space needs to stop VTL0 and unpause VTL1 until it triggers VTL_RETURN
> >> at which point VTL1 stops execution and VTL0 runs again.
> >
> >That's with IPIs in VTL1, right? I understand now. My idea was, since
> >we need a link from VTL1 to VTL0 for the FPU, to use the same link to
> >trigger a vmexit to userspace if source VTL > destination VTL. I am
> >not sure how you would handle the case where the destination vCPU is
> >not running; probably by detecting the IPI when VTL0 restarts on the
> >destination vCPU?
> >
> >In any case, making vCPUs poll()-able is sensible.
> 
> Thinking about this a bit more, even for HLT it probably isn't just as simple
> as checking for mp_state changes. If there's a REQ_EVENT outstanding for
> something like a timer delivery, that won't get handled and the IRQ actually
> delivered to the local APIC until the vCPU is actually *run*, will it?

I haven't been following this conversation, just reacting to seeing "HLT" and
"mp_state", which is a bit of a mess:

https://lore.kernel.org/all/ZMgIQ5m1jMSAogT4@google.com

      reply	other threads:[~2023-09-26 20:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18  9:06 [RFC] KVM: x86: Allow userspace exit on HLT and MWAIT, else yield on MWAIT David Woodhouse
2023-09-18  9:41 ` Alexander Graf
2023-09-18 11:10   ` David Woodhouse
2023-09-18 11:59     ` Alexander Graf
2023-09-19  9:04       ` Peter Zijlstra
2023-09-22 12:00 ` Paolo Bonzini
2023-09-23  7:22   ` David Woodhouse
2023-09-23  9:24     ` Paolo Bonzini
2023-09-23 16:43       ` Alexander Graf
2023-09-26 17:20         ` Paolo Bonzini
2023-09-26 17:28           ` David Woodhouse
2023-09-26 20:29             ` Sean Christopherson [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=ZRM_MHBpePiAQ__1@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=fgriffo@amazon.com \
    --cc=graf@amazon.de \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nsaenz@amazon.es \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.