mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Vitaly Kuznetsov" <vkuznets@redhat.com>,
	"Jim Mattson" <jmattson@google.com>,
	"Joerg Roedel" <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] KVM: X86: Refactor kvm_arch_vcpu_create
Date: Thu, 17 Oct 2019 09:12:21 -0700	[thread overview]
Message-ID: <20191017161221.GB20903@linux.intel.com> (raw)
In-Reply-To: <20191015164033.87276-4-xiaoyao.li@intel.com>

On Wed, Oct 16, 2019 at 12:40:32AM +0800, Xiaoyao Li wrote:
> Current x86 arch vcpu creation flow is a little bit messed.
> Specifically, vcpu's data structure allocation and vcpu initialization
> are mixed up, which is unfriendly to read.
> 
> Seperating the vcpu_create and vcpu_init just like what ARM does, that
> it first calls vcpu_create related functions for vcpu's data structure
> allocation and then calls vcpu_init related functions to initialize the
> vcpu.

My vote is to take advantage of the requirement that @vcpu must reside at
offset 0 in vmx_vcpu and svm_vcpu, and allocate the vcpu in x86 code.
That would allow kvm_arch_vcpu_create() to invoke kvm_vcpu_init() directly
instead of bouncing through the vendor code.

And if we're extra lucky and the other architectures can use a similar
pattern, kvm_vm_ioctl_create_vcpu() could be refactored to something like:

	vcpu = kvm_arch_vcpu_alloc(kvm, id);
	if (IS_ERR(vcpu)) {
		r = PTR_ERR(vcpu);
		goto vcpu_decrement;
	}

	r = kvm_arch_vcpu_init(vcpu);
	if (r)
		goto vcpu_destroy;

  reply	other threads:[~2019-10-17 16:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 16:40 [PATCH 0/4] Refactor vcpu creation flow of x86 arch Xiaoyao Li
2019-10-15 16:40 ` [PATCH 1/4] KVM: VMX: rename {vmx,nested_vmx}_vcpu_setup functions Xiaoyao Li
2019-10-15 22:05   ` Krish Sadhukhan
2019-10-16  1:27     ` Xiaoyao Li
2019-10-16 18:09       ` Krish Sadhukhan
2019-10-17  1:25         ` Xiaoyao Li
2019-10-15 16:40 ` [PATCH 2/4] KVM: VMX: Setup MSR bitmap only when has msr_bitmap capability Xiaoyao Li
2019-10-16  0:40   ` Krish Sadhukhan
2019-10-16  1:29     ` Xiaoyao Li
2019-10-15 16:40 ` [PATCH 3/4] KVM: X86: Refactor kvm_arch_vcpu_create Xiaoyao Li
2019-10-17 16:12   ` Sean Christopherson [this message]
2019-10-15 16:40 ` [PATCH 4/4] KVM: X86: Make vcpu's FPU allocation a common function Xiaoyao Li

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=20191017161221.GB20903@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=vkuznets@redhat.com \
    --cc=xiaoyao.li@intel.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

Powered by JetHome