All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Yang Zhang <yang.z.zhang@intel.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com, xiantao.zhang@intel.com
Subject: Re: [PATCH v4 1/7] KVM: Call kvm_apic_match_dest() to check destination vcpu
Date: Wed, 20 Mar 2013 14:16:23 +0200	[thread overview]
Message-ID: <20130320121623.GK3889@redhat.com> (raw)
In-Reply-To: <1363779379-20212-2-git-send-email-yang.z.zhang@intel.com>

On Wed, Mar 20, 2013 at 07:36:13PM +0800, Yang Zhang wrote:
> 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    |    7 +++++--
>  3 files changed, 5 insertions(+), 53 deletions(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 02b51dd..ee14f94 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 1676d34..5806ef8 100644
> --- a/arch/x86/kvm/lapic.h
> +++ b/arch/x86/kvm/lapic.h
> @@ -154,8 +154,4 @@ 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);
> -
>  #endif
> diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
> index ce82b94..4443075 100644
> --- a/virt/kvm/ioapic.c
> +++ b/virt/kvm/ioapic.c
> @@ -135,8 +135,11 @@ void kvm_ioapic_calculate_eoi_exitmap(struct kvm_vcpu *vcpu,
>  			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, irqe.shorthand,
> +						irqe.dest_id, irqe.dest_mode))
> +				__set_bit(irqe.vector,
> +					(unsigned long *)eoi_exit_bitmap);
Nice! But you do not need irqe any more.

>  		}
>  	}
>  	spin_unlock(&ioapic->lock);
> -- 
> 1.7.1

--
			Gleb.

  reply	other threads:[~2013-03-20 12:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 11:36 [PATCH v4 0/7] Use eoi to track RTC interrupt delivery status Yang Zhang
2013-03-20 11:36 ` [PATCH v4 1/7] KVM: Call kvm_apic_match_dest() to check destination vcpu Yang Zhang
2013-03-20 12:16   ` Gleb Natapov [this message]
2013-03-20 11:36 ` [PATCH v4 2/7] KVM: Call common update function when ioapic entry changed Yang Zhang
2013-03-20 11:36 ` [PATCH v4 3/7] KVM: Add vcpu info to ioapic_update_eoi() Yang Zhang
2013-03-20 11:36 ` [PATCH v4 4/7] KVM: Introduce struct rtc_status Yang Zhang
2013-03-20 11:36 ` [PATCH v4 5/7] KVM: Recalculate destination vcpu map Yang Zhang
2013-03-20 15:22   ` Gleb Natapov
2013-03-21  3:42     ` Zhang, Yang Z
2013-03-21  5:08       ` Gleb Natapov
2013-03-21  5:30         ` Zhang, Yang Z
2013-03-21  5:34           ` Gleb Natapov
2013-03-21  5:39             ` Zhang, Yang Z
2013-03-21  6:57               ` Gleb Natapov
2013-03-21  7:01                 ` Zhang, Yang Z
2013-03-21  7:02     ` Zhang, Yang Z
2013-03-21  7:04       ` Gleb Natapov
2013-03-20 11:36 ` [PATCH v4 6/7] KVM: Add reset/restore rtc_status support Yang Zhang
2013-03-20 11:36 ` [PATCH v4 7/7] KVM: Use eoi to track RTC interrupt delivery status 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=20130320121623.GK3889@redhat.com \
    --to=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=xiantao.zhang@intel.com \
    --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 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.