All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH v3 2/4] KVM: Add unified KVM_GET/SET_VCPU_STATE IOCTL
Date: Tue, 10 Nov 2009 14:22:28 +0100	[thread overview]
Message-ID: <4AF96914.6010606@siemens.com> (raw)
In-Reply-To: <4AF96342.4060205@redhat.com>

Avi Kivity wrote:
> On 11/10/2009 02:03 PM, Jan Kiszka wrote:
>>> I'm having some second thoughts about this.
>>>
>>> What does the new API buy us?  Instead of declaring two new ioctls for
>>> new/fixed substates, we only have to declare one.  We still have the
>>> capability check.  We still have to declare a structure.
>>>      
>> Right, we still need CAPs to protect us against undefined types. So
>> KVM_CHECK_VCPU_STATES is actually pointless - well, someone asked for it...
>>    
> 
> It's not pointless - you can do a compile-time check for 
> KVM_VCPU_STATE_... and a runtime check using KVM_CHECK_VCPU_STATES.  But 
> it does duplicate the existing KVM_CAP_ functionality.

It's redundant, therefore I considered it pointless.

> 
>>> It's true that the internals are currently a mess.  We can fix that with
>>> a table-driven approach:
>>>
>>> static struct kvm_state_ioctl state_ioctls[] = {
>>>      {
>>>           .get_ioctl = KVM_GET_FPU,
>>>           .set_ioctl = KVM_SET_FPU,
>>>           .get = kvm_get_fpu,
>>>           .set = kvm_set_fpu,
>>>           .size = sizeof(struct kvm_fpu), /* 0 for variable-size state */
>>>      
>> Even a variable-sized state has a fixed-size header. The handlers would
>> have to deal with this, or we would need to define which field in the
>> header holds the extension size, and what is its multiplier.
>>    
> 
> Since we have very few variable-size states, and their number is 
> unlikely to increase, ad-hoc handling should be sufficient.

Regarding CPU states, there is actually only the MSR interface.

> 
>>> So, what's the real justification for the new ABI?
>>>      
>> The remaining differences are:
>>   - single kernel call possible
>>    
> 
> Is there a real advantage in this?  It's not a high performance call, 
> typically only called during save/restore, reset, and for vmware's 
> wonderful ioport interface.

And debugging. But, true, this is all fairly uncritical.

> 
>>   - slightly higher regularity (the IOCTL space is rather chaotic)
>>    
> 
> But still, actually handling the state is not regular either on the 
> userspace or kernel side.
> 
>>> Jan, my apologies for raising this at such a very late stage in the
>>> review, after all the nits have been satisfactorily addressed.  But I
>>> want to make sure we don't bloat the interface without very good reasons.
>>>      
>> I think we came from the idea: "Let's have one new IOCTL that will fit
>> it all - now and then." That's obviously not cheaply achievable. So the
>> valid question is what our extension concept of the future should be,
>> the existing multi-IOCTL approach or the substates? I only have a slight
>> bias towards the latter but the strong wish to achieve to a final decision.
>>    
> 
> It would have been better to start from substates in the first place, 
> since there is less duplication: instead of 2 x NR_STATES ioctls, we 
> define 2 ioctls + NR_STATES defines.  It's more regular and less chance 
> for errors (like misspelling _IOR/_IOW).
> 
> But given that we already do have the old interface, perhaps it's best 
> to stick with it and concentrate on improving the internals.

So the new roadmap shall be like this:

 o Add KVM_X86_GET/SET_EVENT_STATES (instead of
   KVM_X86_VCPU_STATE_EVENTS)

 o Refactor in-kernel VCPU state IOCTLs to use table-driven dispatching
   and shared argument passing

 o Maybe refactor user space as well towards a table-driven state sync
   (need to think about this a bit more)

Any other comments or does everyone agree?

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux

  reply	other threads:[~2009-11-10 13:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-02 16:20 [PATCH v3 0/4] Extensible VCPU state IOCTL Jan Kiszka
2009-11-02 16:20 ` [PATCH v3 1/4] KVM: Reorder IOCTLs in main kvm.h Jan Kiszka
2009-11-10 10:17   ` Avi Kivity
2009-11-02 16:20 ` [PATCH v3 2/4] KVM: Add unified KVM_GET/SET_VCPU_STATE IOCTL Jan Kiszka
2009-11-04 11:18   ` Avi Kivity
2009-11-04 11:35     ` Jan Kiszka
2009-11-04 12:52       ` Avi Kivity
2009-11-10 10:14   ` Avi Kivity
2009-11-10 12:03     ` Jan Kiszka
2009-11-10 12:57       ` Avi Kivity
2009-11-10 13:22         ` Jan Kiszka [this message]
2009-11-10 13:31           ` Avi Kivity
2009-11-10 13:41             ` Jan Kiszka
2009-11-02 16:20 ` [PATCH v3 3/4] KVM: x86: Add support for KVM_GET/SET_VCPU_STATE Jan Kiszka
2009-11-02 16:20 ` [PATCH v3 4/4] KVM: x86: Add VCPU substate for event states Jan Kiszka
2009-11-04 11:23   ` Avi Kivity
2009-11-04 11:34     ` Jan Kiszka
2009-11-04 12:51       ` Avi Kivity
2009-11-04 14:44         ` Jan Kiszka
2009-11-05  8:25   ` [PATCH v4 " Jan Kiszka
2009-11-05 11:00     ` Gleb Natapov
2009-11-05 11:51     ` [PATCH v5 " Jan Kiszka

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=4AF96914.6010606@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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 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.