From: Avi Kivity <avi@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com, mst@redhat.com
Subject: Re: [PATCHv2] KVM: optimize apic interrupt delivery
Date: Tue, 11 Sep 2012 18:51:29 +0300 [thread overview]
Message-ID: <504F5E01.5050705@redhat.com> (raw)
In-Reply-To: <20120911144639.GD25827@redhat.com>
On 09/11/2012 05:46 PM, Gleb Natapov wrote:
> On Tue, Sep 11, 2012 at 04:26:17PM +0300, Avi Kivity wrote:
>> On 09/11/2012 04:02 PM, Gleb Natapov wrote:
>> > Most interrupt are delivered to only one vcpu. Use pre-build tables to
>> > find interrupt destination instead of looping through all vcpus. In case
>> > of logical mode loop only through vcpus in a logical cluster irq is sent
>> > to.
>> >
>> > * fix rcu issues pointed to by MST. All but one. Still use
>> > call_rcu(). Do not think this is serious issue. If it is should be
>> > solved by RCU subsystem.
>>
>> Agree.
>>
>> Patch looks good but some minor comments follow.
>>
>> > struct kvm_arch {
>> > unsigned int n_used_mmu_pages;
>> > unsigned int n_requested_mmu_pages;
>> > @@ -528,6 +536,8 @@ struct kvm_arch {
>> > struct kvm_ioapic *vioapic;
>> > struct kvm_pit *vpit;
>> > int vapics_in_nmi_mode;
>> > + struct kvm_apic_map *apic_map;
>> > + struct mutex apic_map_lock;
>>
>> Reversing the order will make it clearer what the lock protects.
>>
> Hmm, OK. I thought names make it clear.
They do, but it is conventional and good practice to put the lock in front.
>
>> >
>> > +static void kvm_apic_get_logical_id(u32 ldr, bool flat, u8 ldr_bits,
>> > + u16 *cid, u16 *lid)
>> > +{
>> > + if (ldr_bits == 32) {
>> > + *cid = ldr >> 16;
>> > + *lid = ldr & 0xffff;
>> > + } else {
>> > + ldr = GET_APIC_LOGICAL_ID(ldr);
>> > +
>> > + if (flat) {
>> > + *cid = 0;
>> > + *lid = ldr;
>> > + } else {
>> > + *cid = ldr >> 4;
>> > + *lid = ldr & 0xf;
>> > + }
>> > + }
>> > +}
>>
>> You could precaclulate lid_shift/lid_mask/cid_shift/cid_mask and have
>> just one version here. In fact you could drop the function.
>>
> You mean precalculate them in recalculate_apic_map() and store in kvm_apic_map?
Yes.
>
>> > +
>> > + new->phys_map[kvm_apic_id(apic)] = apic;
>> > + kvm_apic_get_logical_id(kvm_apic_get_reg(apic, APIC_LDR),
>> > + new->flat, new->ldr_bits, &cid, &lid);
>> > +
>> > + if (lid)
>> > + new->logical_map[cid][ffs(lid) - 1] = apic;
>> > + }
>> > +out:
>> > + old = kvm->arch.apic_map;
>>
>> rcu_dereference(), just for kicks.
>>
> MST says rcu_dereference_protected() but honestly I look at it and
> rcu_dereference_check(...., 1) and condition they check are so obviously
> correct in the code that using them is just a clutter.
They say to the reader, or to a static checker "this case was considered
and that is the conclusion we arrived at". Using the variable directly
says nothing.
> In more complex
> cases, when dereference happens far away from locking it have its point.
> If you insist on it here should we add it too irq routing code too?
Thanks.
>> > /*
>> > @@ -6319,6 +6320,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
>> > put_page(kvm->arch.apic_access_page);
>> > if (kvm->arch.ept_identity_pagetable)
>> > put_page(kvm->arch.ept_identity_pagetable);
>> > + kfree(kvm->arch.apic_map);
>>
>> rcu_dereference(), even though it cannot be needed here, to shut down
>> static code checkers.
>>
> How to run those code checkers? Do they complain about irq routing code?
> Just curious.
No idea. Julia Lawall sends patches from time to time with this kind of
things, so people do run them.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2012-09-11 15:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-11 13:02 [PATCHv2] KVM: optimize apic interrupt delivery Gleb Natapov
2012-09-11 13:26 ` Avi Kivity
2012-09-11 14:02 ` Michael S. Tsirkin
2012-09-11 14:46 ` Gleb Natapov
2012-09-11 15:51 ` Avi Kivity [this message]
2012-09-11 14:10 ` Michael S. Tsirkin
2012-09-11 17:13 ` Paul E. McKenney
2012-09-11 20:04 ` Avi Kivity
2012-09-11 22:39 ` Michael S. Tsirkin
2012-09-12 7:41 ` Avi Kivity
2012-09-11 22:33 ` Michael S. Tsirkin
2012-09-12 1:03 ` Paul E. McKenney
2012-09-12 7:45 ` Avi Kivity
2012-09-12 12:34 ` Gleb Natapov
[not found] ` <505081E9.8080505@redhat.com>
2012-09-12 12:44 ` Gleb Natapov
2012-09-12 15:13 ` Paul E. McKenney
2013-11-26 16:24 ` Michael S. Tsirkin
2013-11-26 19:35 ` Paul E. McKenney
2013-11-27 8:00 ` Gleb Natapov
2013-11-27 17:06 ` Paul E. McKenney
2013-11-28 8:55 ` Gleb Natapov
2013-12-05 23:00 ` Paul E. McKenney
2013-12-06 11:32 ` Gleb Natapov
2013-11-26 20:07 ` Marcelo Tosatti
2012-09-12 12:17 ` Gleb Natapov
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=504F5E01.5050705@redhat.com \
--to=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox