From: Avi Kivity <avi@redhat.com>
To: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
Cc: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>,
mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: [RFC PATCH] KVM: x86: Skip request checking branches in vcpu_enter_guest() more effectively
Date: Thu, 27 Sep 2012 11:28:12 +0200 [thread overview]
Message-ID: <50641C2C.3000001@redhat.com> (raw)
In-Reply-To: <20120926110629.e4073b6d6d7cc458ed0a283b@gmail.com>
On 09/26/2012 04:06 AM, Takuya Yoshikawa wrote:
> On Mon, 24 Sep 2012 16:50:13 +0200
> Avi Kivity <avi@redhat.com> wrote:
>
>> Afterwards, most exits are APIC and interrupt related, HLT, and MMIO.
>> Of these, some are special (HLT, interrupt injection) and some are not
>> (read/write most APIC registers). I don't think one group dominates the
>> other. So already vcpu->requests processing is not such a slow path, it
>> is relatively common. We still see a lot of page faults during boot and
>> during live migration though.
>>
>> With AVIC/APIC-V (still in the future) the mix will change again, with
>> both special and non-special exits eliminated. We'll be left mostly
>> with APIC timer and HLT (and ICR writes for APIC-V).
>>
>> So maybe the direction of your patch makes sense. Things like
>> KVM_REQ_EVENT (or anything above 2-3% of exits) shouldn't be in
>> vcpu->requests or maybe they deserve special treatment.
>
> I see the point.
>
> Since KVM_REQ_EVENT must be checked after handling some other requests,
> it needs special treatment anyway -- if we think defining it as the
> last flag for for_each_set_bit() is kind of special treatment.
Note that's an optimization - the code will work even if we don't do that.
But we can go further, like making it a bool, so it can be set without
an atomic operation.
It would depend on how frequent it is, in a real workload.
>
> As Gleb and you pointed out, KVM_REQ_STEAL_UPDATE needs to be fixed
> first not to be set unnecessarily.
>
> Then by special casing KVM_REQ_EVENT, one line change or moving it out
> from vcpu->requests, we can see if further improvement is needed.
>
> If a few requests exceed the threshold, 2-3% as you wrote?, we can also
> define a mask to indicate which requests should be treated as "not unlikely".
Right, it will depend on each individual case. For example synchronous
requests (can only happen from the vcpu thread) would be better off
outside vcpu->requests.
>
>> > BTW, schedule() is really rare? We do either cond_resched() or
>> > heavy weight exit, no?
>>
>> If 25% of exits are HLT (like a ping workload), then 25% of your exits
>> end up in schedule().
>>
>> On modern hardware, a relatively larger percentage of exits are
>> heavyweight (same analysis as above). On AVIC hardware most exits will
>> be mmio, HLT, and host interrupts. Of these only host interrupts that
>> don't lead to a context switch will be lightweight.
>>
>> >
>> > I always see vcpu threads actively move around the cores.
>> > (When I do not pin them.)
>>
>> Sure, but the frequency is quite low. If not that's a bug.
>
> That's what I was originally testing for: if vcpu threads were being
> scheduled as expected.
>
> I forgot why I reached here.
Human minds also tend to move around a lot.
--
error compiling committee.c: too many arguments to function
prev parent reply other threads:[~2012-09-27 9:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-24 6:24 [RFC PATCH] KVM: x86: Skip request checking branches in vcpu_enter_guest() more effectively Takuya Yoshikawa
2012-09-24 6:59 ` Xiao Guangrong
2012-09-24 10:09 ` Avi Kivity
2012-09-24 14:32 ` Takuya Yoshikawa
2012-09-24 14:53 ` Avi Kivity
2012-09-24 13:55 ` Takuya Yoshikawa
2012-09-24 7:16 ` Gleb Natapov
2012-09-24 10:10 ` Avi Kivity
2012-09-24 13:58 ` Takuya Yoshikawa
2012-10-04 16:11 ` Takuya Yoshikawa
2012-09-24 10:18 ` Avi Kivity
2012-09-24 14:14 ` Takuya Yoshikawa
2012-09-24 14:50 ` Avi Kivity
2012-09-26 2:06 ` Takuya Yoshikawa
2012-09-27 9:28 ` Avi Kivity [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=50641C2C.3000001@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=takuya.yoshikawa@gmail.com \
--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 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.