From: Gleb Natapov <gleb@redhat.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"Tian, Kevin" <kevin.tian@intel.com>
Subject: Re: [PATCH v3 3/4] x86, apicv: add virtual interrupt delivery support
Date: Thu, 6 Dec 2012 09:19:14 +0200 [thread overview]
Message-ID: <20121206071914.GB19514@redhat.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E2D581B@SHSMSX101.ccr.corp.intel.com>
On Thu, Dec 06, 2012 at 07:16:07AM +0000, Zhang, Yang Z wrote:
> Gleb Natapov wrote on 2012-12-06:
> > On Thu, Dec 06, 2012 at 02:55:16AM +0000, Zhang, Yang Z wrote:
> >> Gleb Natapov wrote on 2012-12-05:
> >>> On Wed, Dec 05, 2012 at 01:51:36PM +0000, Zhang, Yang Z wrote:
> >>>> Gleb Natapov wrote on 2012-12-05:
> >>>>> On Wed, Dec 05, 2012 at 06:02:59AM +0000, Zhang, Yang Z wrote:
> >>>>>> Gleb Natapov wrote on 2012-12-05:
> >>>>>>> On Wed, Dec 05, 2012 at 01:55:17AM +0000, Zhang, Yang Z wrote:
> >>>>>>>> Gleb Natapov wrote on 2012-12-04:
> >>>>>>>>> On Tue, Dec 04, 2012 at 06:39:50AM +0000, Zhang, Yang Z wrote:
> >>>>>>>>>> Gleb Natapov wrote on 2012-12-03:
> >>>>>>>>>>> On Mon, Dec 03, 2012 at 03:01:03PM +0800, Yang Zhang wrote:
> >>>>>>>>>>>> Virtual interrupt delivery avoids KVM to inject vAPIC interrupts
> >>>>>>>>>>>> manually, which is fully taken care of by the hardware. This needs
> >>>>>>>>>>>> some special awareness into existing interrupr injection path:
> >>>>>>>>>>>>
> >>>>>>>>>>>> - for pending interrupt, instead of direct injection, we may need
> >>>>>>>>>>>> update architecture specific indicators before resuming to
> >>>>>>>>>>>> guest. - A pending interrupt, which is masked by ISR, should
> >>>>>>>>>>>> be also considered in above update action, since hardware
> >>>>>>>>>>>> will decide when to inject it at right time. Current
> >>>>>>>>>>>> has_interrupt and get_interrupt only returns a valid vector
> >>>>>>>>>>>> from injection p.o.v.
> >>>>>>>>>>> Most of my previous comments still apply.
> >>>>>>>>>>>
> >>>>>>>>>>>> +void kvm_set_eoi_exitmap(struct kvm_vcpu *vcpu, int vector,
> >>>>>>>>>>>> + int trig_mode, int always_set)
> >>>>>>>>>>>> +{
> >>>>>>>>>>>> + if (kvm_x86_ops->set_eoi_exitmap)
> >>>>>>>>>>>> + kvm_x86_ops->set_eoi_exitmap(vcpu, vector,
> >>>>>>>>>>>> + trig_mode, always_set);
> >>>>>>>>>>>> +}
> >>>>>>>>>>>> +
> >>>>>>>>>>>> /*
> >>>>>>>>>>>> * Add a pending IRQ into lapic.
> >>>>>>>>>>>> * Return 1 if successfully added and 0 if discarded.
> >>>>>>>>>>>> @@ -661,6 +669,7 @@ static int __apic_accept_irq(struct
> > kvm_lapic
> >>>>>>> *apic,
> >>>>>>>>> int
> >>>>>>>>>>> delivery_mode,
> >>>>>>>>>>>> if (unlikely(!apic_enabled(apic)))
> >>>>>>>>>>>> break;
> >>>>>>>>>>>> + kvm_set_eoi_exitmap(vcpu, vector, trig_mode, 0);
> >>>>>>>>>>> As I said in the last review rebuild the bitmap when ioapic or irq
> >>>>>>>>>>> notifier configuration changes, user request bit to notify vcpus to
> >>>>>>>>>>> reload the bitmap.
> >>>>>>>>>> It is too complicated. When program ioapic entry, we cannot get the
> >>>>> target
> >>>>>>> vcpu
> >>>>>>>>> easily. We need to read destination format register and logical
> >>>>>>>>> destination register to find out target vcpu if using logical mode.
> >>>>>>>>> Also, we must trap every modification to the two registers to update
> >>>>>>>>> eoi bitmap. No need to check target vcpu. Enable exit on all vcpus
> >>>>>>>>> for the vector
> >>>>>>>> This is wrong. As we known, modern OS uses per VCPU vector. We
> > cannot
> >>>>>>> ensure all vectors have same trigger mode. And what's worse, the
> >>>>>>> vector in another vcpu is used to handle high frequency
> >>>>>>> interrupts(like 10G NIC), then it will hurt performance.
> >>>>>>>>
> >>>>>>> I never saw OSes reuse vector used by ioapic, as far as I see this
> >>>>>> Could you point out which code does this check in Linux kernel? I don't
> >>>>>> see any special checks when Linux kernel allocates a vector.
> >>>>>>
> >>>>> arch/x86/kernel/apic/io_apic.c:create_irq_nr(). It uses
> >>>>> apic->target_cpus() to get cpu mask. target_cpus() return mask of all
> >>>>> online cpus. Actually you wrote arch_pi_create_irq() in PI patches to
> >>>>> workaround this behaviour and allocated vector per cpu, no?
> >>>> Yes, when create an new irq, it will allocate vector from all online cpus. But
> > after
> >>> user changes the irq affinity, then the vector will reallocate with
> >>> new cpumask. And this will leave the vector available on other cpus.
> >>>>
> >>> Since during vector allocation all cpus are checked vector will not be
> >>> reused if it is allocated on any cpu.
> >> Sorry, I still cannot find this check in kernel. Can you point me out to it?
> > You pointed to it above by yourself:
> > "Yes, when create an new irq, it will allocate vector from all online
> > cpus"
> > So if vector is allocated by at least one online cpu it cannot be reused
> > during allocation.
> >
> >> Also, I do see the vector reused by MSI and IOAPIC in my system.
> >>
> > What is your system? What is your qemu command line? We only care if MSI
> > uses the same vector as IOAPICs level interrupt but on different cpu. If
> > this happens we can use apic_map to calculate per cpu eoi exit bitmap.
> >
> >>>>> Are you aware of any guest that I can run, examine ioapic/apic
> >>>>> configuration and see that the same vector is used on different vcpus
> >>>>> for different devices? Can you point me to it?
> >>>>>
> >>> Can you answer this?
> >> I am sure Xen will reused the IOAPIC vector.
> >>
> > What configuration it creates exactly? Also if Xen running as KVM guest
> > will takes small performance hit it is not a big problem. Remember there
> > is not correctness issue here.
> Anyway, it's doesn't matter to discuss which OS will reuse the vector.
> So use apic_map is the final decision?
>
If you are firmly committed to per vcpu bitmap then yes. I tried to make
it simpler for you :)
--
Gleb.
next prev parent reply other threads:[~2012-12-06 7:19 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 7:01 [PATCH v3 0/4] x86, apicv: Add APIC virtualization support Yang Zhang
2012-12-03 7:01 ` [PATCH v3 1/4] x86: PIT connects to pin 2 of IOAPIC Yang Zhang
2012-12-03 9:42 ` Gleb Natapov
2012-12-04 5:32 ` Zhang, Yang Z
2012-12-04 12:55 ` Gleb Natapov
2012-12-05 1:28 ` Zhang, Yang Z
2012-12-03 7:01 ` [PATCH v3 2/4] x86, apicv: add APICv register virtualization support Yang Zhang
2012-12-05 0:29 ` Marcelo Tosatti
2012-12-05 3:17 ` Zhang, Yang Z
2012-12-05 23:11 ` Marcelo Tosatti
2012-12-06 6:45 ` Gleb Natapov
2012-12-03 7:01 ` [PATCH v3 3/4] x86, apicv: add virtual interrupt delivery support Yang Zhang
2012-12-03 11:37 ` Gleb Natapov
2012-12-04 6:39 ` Zhang, Yang Z
2012-12-04 10:58 ` Gleb Natapov
2012-12-05 1:55 ` Zhang, Yang Z
2012-12-05 5:02 ` Gleb Natapov
2012-12-05 6:02 ` Zhang, Yang Z
2012-12-05 10:18 ` Gleb Natapov
2012-12-05 13:51 ` Zhang, Yang Z
2012-12-05 14:00 ` Gleb Natapov
2012-12-06 2:55 ` Zhang, Yang Z
2012-12-06 7:07 ` Gleb Natapov
2012-12-06 7:16 ` Zhang, Yang Z
2012-12-06 7:19 ` Gleb Natapov [this message]
2012-12-06 7:20 ` Zhang, Yang Z
2012-12-04 16:46 ` Michael S. Tsirkin
2012-12-05 2:00 ` Marcelo Tosatti
2012-12-05 3:43 ` Zhang, Yang Z
2012-12-05 11:14 ` Gleb Natapov
2012-12-05 14:16 ` Zhang, Yang Z
2012-12-05 14:34 ` Gleb Natapov
2012-12-06 2:58 ` Zhang, Yang Z
2012-12-05 22:38 ` Marcelo Tosatti
2012-12-06 9:28 ` Gleb Natapov
2012-12-06 11:35 ` Zhang, Yang Z
2012-12-05 22:31 ` Marcelo Tosatti
2012-12-06 3:31 ` Zhang, Yang Z
2012-12-06 5:02 ` Zhang, Yang Z
2012-12-06 6:36 ` Gleb Natapov
2012-12-06 6:56 ` Zhang, Yang Z
2012-12-06 20:08 ` Marcelo Tosatti
2012-12-07 1:00 ` Zhang, Yang Z
2012-12-07 7:28 ` Gleb Natapov
2012-12-03 7:01 ` [PATCH v3 4/4] x86, apicv: add virtual x2apic support Yang Zhang
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=20121206071914.GB19514@redhat.com \
--to=gleb@redhat.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=yang.z.zhang@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;
as well as URLs for NNTP newsgroup(s).