kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: Remove unused KVM_REQ_KICK to save a bit in vcpu->requests
Date: Fri, 8 Jan 2016 13:22:42 +0100	[thread overview]
Message-ID: <568FAA12.5030604@redhat.com> (raw)
In-Reply-To: <568F154D.40407@lab.ntt.co.jp>



On 08/01/2016 02:47, Takuya Yoshikawa wrote:
> 
> Since some request handlers can make other requests which need to be
> checked in the following path, this young number is valuable. In this
> sense, I agree. Your patch looks good to me.
> 
>> This patch can go in for 4.5.  Regarding the other patch,
>> KVM_REQ_MCLOCK_INPROGRESS is indeed not really necessary, see
>> http://www.spinics.net/lists/kvm/msg95944.html and the follow-up.  Were
>> you thinking of the same?  If so I would prefer to have some comments.
> 
> I did not notice that discussion.
> 
> What I have in mind is:
>   http://www.spinics.net/lists/kvm/msg80477.html
> 
> We have more requests than that time and the overhead of
> requests checking has become much worse: Hyper-V code may
> still add some more if-branches, which will always be false
> for many guests.

True, on the other hand they will be well predicted.  Any time I tried
reordering kvm_check_request or other similar micro-optimizations,
everything became slower.  Same for replacing all the clear_bit with a
single xchg and then testing the bits on the value that xchg returned.

Even "obvious" replacements such as

-	if (vcpu->requests)
+	if (vcpu->requests & ~(1 << KVM_REQ_EVENT))

weren't clear winners!  But anyway, this is where I would start from;
not for_each_set_bit or __ffs.

There are other optimizations that are easily done, unrelated to
vcpu->requests: lapic_in_kernel is a dup of kvm_vcpu_has_lapic, but
without the static key optimization.  I prefer the lapic_in_kernel name,
but it has the less efficient implementation.  They ought to be merged.

If you really want to free bits, a possible optimization would be to
move KVM_REQ_REPORT_TPR_ACCESS, KVM_REQ_TRIPLE_FAULT, KVM_REQ_HV_CRASH,
KVM_REQ_HV_RESET, and KVM_REQ_HV_EXIT to a separate
vcpu->vmexit_requests field.  You could either check it on every vmexit,
or just consolidate them into a KVM_REQ_VMEXIT bit.

> Anyway, your patches make enough room for now, so I do not need
> to remove KVM_REQ_MCLOCK_INPROGRESS dummy request for that. It
> depends just on our preference.

I've never liked the dummy request really, but I've never felt like
arguing for its removal either. :)

Paolo

  reply	other threads:[~2016-01-08 12:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 11:43 [PATCH 0/2] KVM: Save two bits in vcpu->requests Takuya Yoshikawa
2016-01-07 11:43 ` [PATCH 1/2] KVM: Remove unused KVM_REQ_KICK to save a bit " Takuya Yoshikawa
2016-01-07 12:37   ` Paolo Bonzini
2016-01-08  1:47     ` Takuya Yoshikawa
2016-01-08 12:22       ` Paolo Bonzini [this message]
2016-01-07 11:43 ` [PATCH 2/2] KVM: Remove KVM_REQ_MCLOCK_INPROGRESS " Takuya Yoshikawa

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=568FAA12.5030604@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=yoshikawa_takuya_b1@lab.ntt.co.jp \
    /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;
as well as URLs for NNTP newsgroup(s).