All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: Chao Gao <chao.gao@intel.com>,
	 "aashish@aashishsharma.net" <aashish@aashishsharma.net>,
	"guang.zeng@intel.com" <guang.zeng@intel.com>,
	 "dmaluka@chromium.org" <dmaluka@chromium.org>,
	 "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	 "vineeth@bitbyteword.org" <vineeth@bitbyteword.org>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	 "jaszczyk@chromium.org" <jaszczyk@chromium.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	 "pbonzini@redhat.com" <pbonzini@redhat.com>,
	Chuanxiao Dong <chuanxiao.dong@intel.com>
Subject: Re: [PATCH] KVM: VMX: Postpone IPIv setup after successful vCPU creation
Date: Mon, 20 Jul 2026 16:15:07 -0700	[thread overview]
Message-ID: <al6r-2sAm2tVh1Wn@google.com> (raw)
In-Reply-To: <a4f683a52c096d8a7cd7d6c4ab895fd41f197eda.camel@intel.com>

On Mon, Jul 20, 2026, Kai Huang wrote:
> > E.g. for the xarray approacy (sketch only, completely untested):
> > 
> > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> > index fdbd697d0337..e34ca5920393 100644
> > --- a/include/linux/kvm_host.h
> > +++ b/include/linux/kvm_host.h
> > @@ -791,6 +791,7 @@ struct kvm {
> >         /* The current active memslot set for each address space */
> >         struct kvm_memslots __rcu *memslots[KVM_MAX_NR_ADDRESS_SPACES];
> >         struct xarray vcpu_array;
> > +       struct xarray pending_vcpu_ids;
> >         /*
> >          * Protected by slots_lock, but can be read outside if an
> >          * incorrect answer is acceptable.
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > index 2df8ee9ecf6c..8bc4f7ffd76d 100644
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -4179,6 +4179,12 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, unsigned long id)
> >                 return r;
> >         }
> >  
> > +       r = xa_insert(&kvm->pending_vcpu_ids, id, xa_mk_value(id), GFP_KERNEL);
> > +       if (r) {
> > +               mutex_unlock(&kvm->lock);
> > +               return r;
> > +       }
> > +
> 
> (No preference between xarray vs bitmap)
> 
> Should we move this before kvm_arch_vcpu_precreate() to avoid any "precreate"
> for duplicated vcpu_id?

Hmm, I'm not sure.  I'm leaning "yes".  At a glance, I like the idea.  My only
concern is that we could consume a garbage @id if kvm_arch_vcpu_precreate()
performs additional checks on @id, as x86's implementation does.  However, I
don't think that's a meaningful concern since kvm_vm_ioctl_create_vcpu() *must*
perform at least basic sanity checks.

So yeah, I think moving the check before precreate() makes sense.

  reply	other threads:[~2026-07-20 23:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 16:08 [PATCH] KVM: VMX: Postpone IPIv setup after successful vCPU creation Dmytro Maluka
2026-07-16 16:29 ` sashiko-bot
2026-07-16 17:24   ` Dmytro Maluka
2026-07-20 14:18     ` Naveen N Rao
2026-07-20 21:38       ` Sean Christopherson
2026-07-17 12:59 ` Huang, Kai
2026-07-17 16:20   ` Dmytro Maluka
2026-07-17 21:21     ` Huang, Kai
2026-07-20 22:17       ` Sean Christopherson
2026-07-20 23:10         ` Huang, Kai
2026-07-20 23:15           ` Sean Christopherson [this message]
2026-07-20 23:22             ` Huang, Kai
2026-07-21  9:26         ` Dmytro Maluka
2026-07-20  6:29 ` Chao Gao

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=al6r-2sAm2tVh1Wn@google.com \
    --to=seanjc@google.com \
    --cc=aashish@aashishsharma.net \
    --cc=chao.gao@intel.com \
    --cc=chuanxiao.dong@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dmaluka@chromium.org \
    --cc=guang.zeng@intel.com \
    --cc=jaszczyk@chromium.org \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vineeth@bitbyteword.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.