* [PATCH] KVM: Call kvm_apic_match_dest() to check destination vcpu
@ 2013-03-21 11:29 Yang Zhang
2013-04-01 0:42 ` Zhang, Yang Z
0 siblings, 1 reply; 3+ messages in thread
From: Yang Zhang @ 2013-03-21 11:29 UTC (permalink / raw)
To: kvm; +Cc: gleb, mtosatti, xiantao.zhang, Yang Zhang
From: Yang Zhang <yang.z.zhang@Intel.com>
For a given vcpu, kvm_apic_match_dest() will tell you whether
the vcpu in the destination list quickly. Drop kvm_calculate_eoi_exitmap()
and use kvm_apic_match_dest() instead.
Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
---
arch/x86/kvm/lapic.c | 47 -----------------------------------------------
arch/x86/kvm/lapic.h | 4 ----
virt/kvm/ioapic.c | 9 ++++-----
3 files changed, 4 insertions(+), 56 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index a8e9369..e227474 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -145,53 +145,6 @@ static inline int kvm_apic_id(struct kvm_lapic *apic)
return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff;
}
-void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
- struct kvm_lapic_irq *irq,
- u64 *eoi_exit_bitmap)
-{
- struct kvm_lapic **dst;
- struct kvm_apic_map *map;
- unsigned long bitmap = 1;
- int i;
-
- rcu_read_lock();
- map = rcu_dereference(vcpu->kvm->arch.apic_map);
-
- if (unlikely(!map)) {
- __set_bit(irq->vector, (unsigned long *)eoi_exit_bitmap);
- goto out;
- }
-
- if (irq->dest_mode == 0) { /* physical mode */
- if (irq->delivery_mode == APIC_DM_LOWEST ||
- irq->dest_id == 0xff) {
- __set_bit(irq->vector,
- (unsigned long *)eoi_exit_bitmap);
- goto out;
- }
- dst = &map->phys_map[irq->dest_id & 0xff];
- } else {
- u32 mda = irq->dest_id << (32 - map->ldr_bits);
-
- dst = map->logical_map[apic_cluster_id(map, mda)];
-
- bitmap = apic_logical_id(map, mda);
- }
-
- for_each_set_bit(i, &bitmap, 16) {
- if (!dst[i])
- continue;
- if (dst[i]->vcpu == vcpu) {
- __set_bit(irq->vector,
- (unsigned long *)eoi_exit_bitmap);
- break;
- }
- }
-
-out:
- rcu_read_unlock();
-}
-
static void recalculate_apic_map(struct kvm *kvm)
{
struct kvm_apic_map *new, *old = NULL;
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 2c721b9..baa20cf 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -160,10 +160,6 @@ static inline u16 apic_logical_id(struct kvm_apic_map *map, u32 ldr)
return ldr & map->lid_mask;
}
-void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
- struct kvm_lapic_irq *irq,
- u64 *eoi_bitmap);
-
static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu)
{
return vcpu->arch.apic->pending_events;
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index ce82b94..b54ddfa 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -132,11 +132,10 @@ void kvm_ioapic_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
(e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC,
index))) {
- irqe.dest_id = e->fields.dest_id;
- irqe.vector = e->fields.vector;
- irqe.dest_mode = e->fields.dest_mode;
- irqe.delivery_mode = e->fields.delivery_mode << 8;
- kvm_calculate_eoi_exitmap(vcpu, &irqe, eoi_exit_bitmap);
+ if (kvm_apic_match_dest(vcpu, NULL, 0,
+ e->fields.dest_id, e->fields.dest_mode))
+ __set_bit(irqe.vector,
+ (unsigned long *)eoi_exit_bitmap);
}
}
spin_unlock(&ioapic->lock);
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] KVM: Call kvm_apic_match_dest() to check destination vcpu
2013-03-21 11:29 [PATCH] KVM: Call kvm_apic_match_dest() to check destination vcpu Yang Zhang
@ 2013-04-01 0:42 ` Zhang, Yang Z
2013-04-02 12:00 ` Gleb Natapov
0 siblings, 1 reply; 3+ messages in thread
From: Zhang, Yang Z @ 2013-04-01 0:42 UTC (permalink / raw)
To: kvm@vger.kernel.org; +Cc: gleb@redhat.com, mtosatti@redhat.com, Zhang, Xiantao
Zhang, Yang Z wrote on 2013-03-21:
> From: Yang Zhang <yang.z.zhang@Intel.com>
>
> For a given vcpu, kvm_apic_match_dest() will tell you whether
> the vcpu in the destination list quickly. Drop kvm_calculate_eoi_exitmap()
> and use kvm_apic_match_dest() instead.
>
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> ---
> arch/x86/kvm/lapic.c | 47 -----------------------------------------------
> arch/x86/kvm/lapic.h | 4 ----
> virt/kvm/ioapic.c | 9 ++++-----
> 3 files changed, 4 insertions(+), 56 deletions(-)
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index a8e9369..e227474 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -145,53 +145,6 @@ static inline int kvm_apic_id(struct kvm_lapic *apic)
> return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff;
> }
> -void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
> - struct kvm_lapic_irq *irq,
> - u64 *eoi_exit_bitmap)
> -{
> - struct kvm_lapic **dst;
> - struct kvm_apic_map *map;
> - unsigned long bitmap = 1;
> - int i;
> -
> - rcu_read_lock();
> - map = rcu_dereference(vcpu->kvm->arch.apic_map);
> -
> - if (unlikely(!map)) {
> - __set_bit(irq->vector, (unsigned long *)eoi_exit_bitmap);
> - goto out;
> - }
> -
> - if (irq->dest_mode == 0) { /* physical mode */
> - if (irq->delivery_mode == APIC_DM_LOWEST ||
> - irq->dest_id == 0xff) {
> - __set_bit(irq->vector,
> - (unsigned long *)eoi_exit_bitmap);
> - goto out;
> - }
> - dst = &map->phys_map[irq->dest_id & 0xff];
> - } else {
> - u32 mda = irq->dest_id << (32 - map->ldr_bits);
> -
> - dst = map->logical_map[apic_cluster_id(map, mda)];
> -
> - bitmap = apic_logical_id(map, mda);
> - }
> -
> - for_each_set_bit(i, &bitmap, 16) {
> - if (!dst[i])
> - continue;
> - if (dst[i]->vcpu == vcpu) {
> - __set_bit(irq->vector,
> - (unsigned long *)eoi_exit_bitmap);
> - break;
> - }
> - }
> -
> -out:
> - rcu_read_unlock();
> -}
> -
> static void recalculate_apic_map(struct kvm *kvm)
> {
> struct kvm_apic_map *new, *old = NULL;
> diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
> index 2c721b9..baa20cf 100644
> --- a/arch/x86/kvm/lapic.h
> +++ b/arch/x86/kvm/lapic.h
> @@ -160,10 +160,6 @@ static inline u16 apic_logical_id(struct kvm_apic_map
> *map, u32 ldr)
> return ldr & map->lid_mask;
> }
> -void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
> - struct kvm_lapic_irq *irq,
> - u64 *eoi_bitmap);
> -
> static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu)
> {
> return vcpu->arch.apic->pending_events;
> diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
> index ce82b94..b54ddfa 100644
> --- a/virt/kvm/ioapic.c
> +++ b/virt/kvm/ioapic.c
> @@ -132,11 +132,10 @@ void kvm_ioapic_calculate_eoi_exitmap(struct
> kvm_vcpu *vcpu,
> (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
> kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC,
> index))) {
> - irqe.dest_id = e->fields.dest_id; - irqe.vector =
> e->fields.vector; - irqe.dest_mode = e->fields.dest_mode;
> - irqe.delivery_mode = e->fields.delivery_mode << 8;
> - kvm_calculate_eoi_exitmap(vcpu, &irqe, eoi_exit_bitmap); + if
> (kvm_apic_match_dest(vcpu, NULL, 0, + e->fields.dest_id,
> e->fields.dest_mode)) + __set_bit(irqe.vector, + (unsigned long
> *)eoi_exit_bitmap);
> }
> }
> spin_unlock(&ioapic->lock);
> --
> 1.7.1
Any comments?
Best regards,
Yang
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: Call kvm_apic_match_dest() to check destination vcpu
2013-04-01 0:42 ` Zhang, Yang Z
@ 2013-04-02 12:00 ` Gleb Natapov
0 siblings, 0 replies; 3+ messages in thread
From: Gleb Natapov @ 2013-04-02 12:00 UTC (permalink / raw)
To: Zhang, Yang Z; +Cc: kvm@vger.kernel.org, mtosatti@redhat.com, Zhang, Xiantao
On Mon, Apr 01, 2013 at 12:42:33AM +0000, Zhang, Yang Z wrote:
> Zhang, Yang Z wrote on 2013-03-21:
> > From: Yang Zhang <yang.z.zhang@Intel.com>
> >
> > For a given vcpu, kvm_apic_match_dest() will tell you whether
> > the vcpu in the destination list quickly. Drop kvm_calculate_eoi_exitmap()
> > and use kvm_apic_match_dest() instead.
> >
> > Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> > ---
> > arch/x86/kvm/lapic.c | 47 -----------------------------------------------
> > arch/x86/kvm/lapic.h | 4 ----
> > virt/kvm/ioapic.c | 9 ++++-----
> > 3 files changed, 4 insertions(+), 56 deletions(-)
> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> > index a8e9369..e227474 100644
> > --- a/arch/x86/kvm/lapic.c
> > +++ b/arch/x86/kvm/lapic.c
> > @@ -145,53 +145,6 @@ static inline int kvm_apic_id(struct kvm_lapic *apic)
> > return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff;
> > }
> > -void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
> > - struct kvm_lapic_irq *irq,
> > - u64 *eoi_exit_bitmap)
> > -{
> > - struct kvm_lapic **dst;
> > - struct kvm_apic_map *map;
> > - unsigned long bitmap = 1;
> > - int i;
> > -
> > - rcu_read_lock();
> > - map = rcu_dereference(vcpu->kvm->arch.apic_map);
> > -
> > - if (unlikely(!map)) {
> > - __set_bit(irq->vector, (unsigned long *)eoi_exit_bitmap);
> > - goto out;
> > - }
> > -
> > - if (irq->dest_mode == 0) { /* physical mode */
> > - if (irq->delivery_mode == APIC_DM_LOWEST ||
> > - irq->dest_id == 0xff) {
> > - __set_bit(irq->vector,
> > - (unsigned long *)eoi_exit_bitmap);
> > - goto out;
> > - }
> > - dst = &map->phys_map[irq->dest_id & 0xff];
> > - } else {
> > - u32 mda = irq->dest_id << (32 - map->ldr_bits);
> > -
> > - dst = map->logical_map[apic_cluster_id(map, mda)];
> > -
> > - bitmap = apic_logical_id(map, mda);
> > - }
> > -
> > - for_each_set_bit(i, &bitmap, 16) {
> > - if (!dst[i])
> > - continue;
> > - if (dst[i]->vcpu == vcpu) {
> > - __set_bit(irq->vector,
> > - (unsigned long *)eoi_exit_bitmap);
> > - break;
> > - }
> > - }
> > -
> > -out:
> > - rcu_read_unlock();
> > -}
> > -
> > static void recalculate_apic_map(struct kvm *kvm)
> > {
> > struct kvm_apic_map *new, *old = NULL;
> > diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
> > index 2c721b9..baa20cf 100644
> > --- a/arch/x86/kvm/lapic.h
> > +++ b/arch/x86/kvm/lapic.h
> > @@ -160,10 +160,6 @@ static inline u16 apic_logical_id(struct kvm_apic_map
> > *map, u32 ldr)
> > return ldr & map->lid_mask;
> > }
> > -void kvm_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
> > - struct kvm_lapic_irq *irq,
> > - u64 *eoi_bitmap);
> > -
> > static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu)
> > {
> > return vcpu->arch.apic->pending_events;
> > diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
> > index ce82b94..b54ddfa 100644
> > --- a/virt/kvm/ioapic.c
> > +++ b/virt/kvm/ioapic.c
> > @@ -132,11 +132,10 @@ void kvm_ioapic_calculate_eoi_exitmap(struct
> > kvm_vcpu *vcpu,
> > (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
> > kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC,
> > index))) {
> > - irqe.dest_id = e->fields.dest_id; - irqe.vector =
> > e->fields.vector; - irqe.dest_mode = e->fields.dest_mode;
> > - irqe.delivery_mode = e->fields.delivery_mode << 8;
> > - kvm_calculate_eoi_exitmap(vcpu, &irqe, eoi_exit_bitmap); + if
> > (kvm_apic_match_dest(vcpu, NULL, 0, + e->fields.dest_id,
> > e->fields.dest_mode)) + __set_bit(irqe.vector, + (unsigned long
> > *)eoi_exit_bitmap);
> > }
> > }
> > spin_unlock(&ioapic->lock);
> > --
> > 1.7.1
>
> Any comments?
>
You can drop irqe now since it was needed for
kvm_calculate_eoi_exitmap() call.
--
Gleb.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-02 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-21 11:29 [PATCH] KVM: Call kvm_apic_match_dest() to check destination vcpu Yang Zhang
2013-04-01 0:42 ` Zhang, Yang Z
2013-04-02 12:00 ` Gleb Natapov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox