public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"mtosatti@redhat.com" <mtosatti@redhat.com>,
	"Zhang, Xiantao" <xiantao.zhang@intel.com>
Subject: Re: [PATCH v6 3/6] KVM : Return destination vcpu on interrupt injection
Date: Fri, 22 Mar 2013 09:57:06 +0200	[thread overview]
Message-ID: <20130322075706.GO9382@redhat.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E099EB993@SHSMSX101.ccr.corp.intel.com>

On Fri, Mar 22, 2013 at 07:50:11AM +0000, Zhang, Yang Z wrote:
> Gleb Natapov wrote on 2013-03-22:
> > On Fri, Mar 22, 2013 at 01:24:02PM +0800, Yang Zhang wrote:
> >> From: Yang Zhang <yang.z.zhang@Intel.com>
> >> 
> >> Add a new parameter to know vcpus who received the interrupt.
> >> 
> >> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> >> ---
> >>  arch/x86/kvm/lapic.c |   25 ++++++++++++++++---------
> >>  arch/x86/kvm/lapic.h |    5 +++--
> >>  virt/kvm/ioapic.c    |    2 +-
> >>  virt/kvm/ioapic.h    |    2 +-
> >>  virt/kvm/irq_comm.c  |   12 ++++++------
> >>  5 files changed, 27 insertions(+), 19 deletions(-)
> >> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> >> index d3e322a..d7915a1 100644
> >> --- a/arch/x86/kvm/lapic.c
> >> +++ b/arch/x86/kvm/lapic.c
> >> @@ -431,14 +431,16 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu
> > *vcpu)
> >>  }
> >>  
> >>  static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
> >> -			     int vector, int level, int trig_mode);
> >> +			     int vector, int level, int trig_mode,
> >> +			     unsigned long *dest_map);
> >> 
> >> -int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq)
> >> +int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
> >> +		unsigned long *dest_map)
> >>  {
> >>  	struct kvm_lapic *apic = vcpu->arch.apic;
> >>  
> >>  	return __apic_accept_irq(apic, irq->delivery_mode, irq->vector,
> >> -			irq->level, irq->trig_mode);
> >> +			irq->level, irq->trig_mode, dest_map);
> >>  }
> >>  
> >>  static int pv_eoi_put_user(struct kvm_vcpu *vcpu, u8 val)
> >> @@ -611,7 +613,7 @@ int kvm_apic_match_dest(struct kvm_vcpu *vcpu,
> > struct kvm_lapic *source,
> >>  }
> >>  
> >>  bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
> >> -		struct kvm_lapic_irq *irq, int *r)
> >> +		struct kvm_lapic_irq *irq, int *r, unsigned long *dest_map)
> >>  {
> >>  	struct kvm_apic_map *map;
> >>  	unsigned long bitmap = 1;
> >> @@ -622,7 +624,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm,
> > struct kvm_lapic *src,
> >>  	*r = -1;
> >>  
> >>  	if (irq->shorthand == APIC_DEST_SELF) {
> >> -		*r = kvm_apic_set_irq(src->vcpu, irq);
> >> +		*r = kvm_apic_set_irq(src->vcpu, irq, dest_map);
> >>  		return true;
> >>  	}
> >> @@ -667,7 +669,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm,
> > struct kvm_lapic *src,
> >>  			continue;
> >>  		if (*r < 0)
> >>  			*r = 0;
> >> -		*r += kvm_apic_set_irq(dst[i]->vcpu, irq);
> >> +		*r += kvm_apic_set_irq(dst[i]->vcpu, irq, dest_map);
> >>  	}
> >>  
> >>  	ret = true;
> >> @@ -681,7 +683,8 @@ out:
> >>   * Return 1 if successfully added and 0 if discarded.
> >>   */
> >>  static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
> >> -			     int vector, int level, int trig_mode)
> >> +			     int vector, int level, int trig_mode,
> >> +			     unsigned long *dest_map)
> >>  {
> >>  	int result = 0;
> >>  	struct kvm_vcpu *vcpu = apic->vcpu;
> >> @@ -694,6 +697,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int
> > delivery_mode,
> >>  		if (unlikely(!apic_enabled(apic)))
> >>  			break;
> >> +		if (dest_map)
> >> +			set_bit(vcpu->vcpu_id, dest_map);
> >> +
> > __set_bit()
> no, __apic_accept_irq() may be called to deliver interrupt from IOAPIC and LAPIC interrupt.
> Though the dest_map is only used by RTC interrupt now, it may be use by LAPIC interrupt in future. So it's better to use set_bit not __set_bit.
It is a caller responsibility to not provide pointer to the same memory
to concurrent function invocations.

--
			Gleb.

  reply	other threads:[~2013-03-22  7:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22  5:23 [PATCH v6 0/6] Use eoi to track RTC interrupt delivery status Yang Zhang
2013-03-22  5:24 ` [PATCH v6 1/6] KVM: Add vcpu info to ioapic_update_eoi() Yang Zhang
2013-03-22  5:24 ` [PATCH v6 2/6] KVM: Introduce struct rtc_status Yang Zhang
2013-03-22  5:24 ` [PATCH v6 3/6] KVM : Return destination vcpu on interrupt injection Yang Zhang
2013-03-22  7:05   ` Gleb Natapov
2013-03-22  7:50     ` Zhang, Yang Z
2013-03-22  7:57       ` Gleb Natapov [this message]
2013-03-22  5:24 ` [PATCH v6 4/6] KVM: Add reset/restore rtc_status support Yang Zhang
2013-03-26 14:04   ` Paolo Bonzini
2013-03-29  3:17     ` Zhang, Yang Z
2013-03-26 14:09   ` Paolo Bonzini
2013-03-29  3:19     ` Zhang, Yang Z
2013-03-22  5:24 ` [PATCH v6 5/6] KVM : Force vmexit with virtual interrupt delivery Yang Zhang
2013-03-22  5:24 ` [PATCH v6 6/6] KVM: Use eoi to track RTC interrupt delivery status Yang Zhang
2013-03-22  7:50   ` Gleb Natapov
2013-03-22  8:05     ` Zhang, Yang Z
2013-03-22  8:14       ` Gleb Natapov
2013-03-22  8:25         ` Zhang, Yang Z
2013-03-22  8:30           ` Gleb Natapov
2013-03-22  8:37             ` Zhang, Yang Z
2013-03-22  8:44               ` Gleb Natapov
2013-03-22  8:51                 ` Zhang, Yang Z
2013-03-22  8:54                   ` Gleb Natapov
2013-03-22 10:50                     ` Zhang, Yang Z
2013-03-24  9:20                       ` Gleb Natapov
2013-03-26 14:26                     ` Paolo Bonzini
2013-03-26 14:14   ` Paolo Bonzini
2013-03-29  3:25     ` Zhang, Yang Z
2013-03-29  8:35       ` Paolo Bonzini
2013-03-29  8:42         ` Zhang, Yang Z
2013-04-02 13:08       ` Gleb Natapov
2013-04-03  0:21         ` Zhang, Yang Z
2013-04-03  4:03           ` 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=20130322075706.GO9382@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox