Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1492617

Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv interrupt injection

From Paolo Bonzini <pbonzini@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv interrupt injection
Date 2016-09-28 16:10 +0200
Message-ID <smnIB-7Ly-1@gated-at.bofh.it> (permalink)
References <sm86R-6hq-5@gated-at.bofh.it> <sm86S-6hq-37@gated-at.bofh.it> <sm9FD-7lr-11@gated-at.bofh.it> <smipz-4jE-5@gated-at.bofh.it> <smnpf-7q5-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 28/09/2016 15:46, Michael S. Tsirkin wrote:
> On Wed, Sep 28, 2016 at 10:21:41AM +0200, Paolo Bonzini wrote:
>> Basically the order for interrupt injection is:
>>
>> (1)	set PIR
>> 	smp_wmb()
> 
> Empty on x86 btw but good for reasoning about barrier
> pairing. So - where's the paired smp_rmb? See below.
> 
>> (2)	set ON
>> 	smp_mb()
> 
> This one can be combined to smp_store_mb to save
> a couple of cycles.

Yeah, this was very much a pseudo-code view.  In reality it's a
test_and_set_bit().  If ON=1 already there's no need to go on with 3/4.

>> (3)	read vcpu->mode
>> 	if IN_GUEST_MODE
>> (4a)		send posted interrupt IPI
>> 	else
>> (4b)		kick (i.e. cmpxchg vcpu->mode from IN_GUEST_MODE to
>> 		      EXITING_GUEST_MODE and send reschedule IPI)
>>
>> while the order for entering the guest must be the opposite.  The
>> numbers on the left identify the pairing between interrupt injection and
>> vcpu_entr_guest
>>
>> (4a)	enable posted interrupt processing (i.e. disable interrupts!)
>> (3)	set vcpu->mode to IN_GUEST_MODE
>> 	smp_mb()
> 
> This one can be combined to smp_store_mb to save
> a couple of cycles.

Here the actual code has smp_mb__after_srcu_unlock.

>> (2)	read ON
>> 	if ON then
> 
> do we need smp_rmb here?

Yes, we have test_and_clear here which has an implicit barrier.

Paolo

> 
>> (1)		read PIR
>> 		sync PIR to IRR
>> (4b)	read vcpu->mode
>> 	if vcpu->mode == EXITING_GUEST_MODE then
>> 		cancel vmentry
>> (3/2/1)		# posted interrupts are processed on the next vmentry
>>
>> Paolo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 0/3] kvm: x86: speedups for APICv Paolo Bonzini <pbonzini@redhat.com> - 2016-09-27 23:30 +0200
  [PATCH 3/3] KVM: x86: do not scan IRR twice on APICv vmentry Paolo Bonzini <pbonzini@redhat.com> - 2016-09-27 23:30 +0200
    Re: [PATCH 3/3] KVM: x86: do not scan IRR twice on APICv vmentry "Michael S. Tsirkin" <mst@redhat.com> - 2016-09-28 16:10 +0200
      Re: [PATCH 3/3] KVM: x86: do not scan IRR twice on APICv vmentry Paolo Bonzini <pbonzini@redhat.com> - 2016-09-28 16:50 +0200
    RE: [PATCH 3/3] KVM: x86: do not scan IRR twice on APICv vmentry "Wu, Feng" <feng.wu@intel.com> - 2016-09-29 05:00 +0200
  [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv interrupt injection Paolo Bonzini <pbonzini@redhat.com> - 2016-09-27 23:30 +0200
    Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection "Michael S. Tsirkin" <mst@redhat.com> - 2016-09-28 01:10 +0200
      Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection Paolo Bonzini <pbonzini@redhat.com> - 2016-09-28 10:30 +0200
        RE: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection "Wu, Feng" <feng.wu@intel.com> - 2016-09-28 13:50 +0200
          Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection Paolo Bonzini <pbonzini@redhat.com> - 2016-09-28 14:00 +0200
            RE: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection "Wu, Feng" <feng.wu@intel.com> - 2016-09-28 14:10 +0200
              Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection Paolo Bonzini <pbonzini@redhat.com> - 2016-09-28 14:20 +0200
        Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection "Michael S. Tsirkin" <mst@redhat.com> - 2016-09-28 15:50 +0200
          Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection Paolo Bonzini <pbonzini@redhat.com> - 2016-09-28 16:10 +0200
    RE: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection "Wu, Feng" <feng.wu@intel.com> - 2016-09-28 12:10 +0200
      Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection Paolo Bonzini <pbonzini@redhat.com> - 2016-09-28 12:20 +0200
        Re: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection Paolo Bonzini <pbonzini@redhat.com> - 2016-09-28 14:00 +0200
          RE: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection "Wu, Feng" <feng.wu@intel.com> - 2016-09-28 14:10 +0200
        RE: [PATCH 2/3] kvm: x86: do not use KVM_REQ_EVENT for APICv  interrupt injection "Wu, Feng" <feng.wu@intel.com> - 2016-09-28 14:00 +0200
  Re: [RFC PATCH 0/3] kvm: x86: speedups for APICv Radim Krčmář <rkrcmar@redhat.com> - 2016-09-29 22:00 +0200
    Re: [RFC PATCH 0/3] kvm: x86: speedups for APICv Paolo Bonzini <pbonzini@redhat.com> - 2016-09-29 23:50 +0200
      Re: [RFC PATCH 0/3] kvm: x86: speedups for APICv Radim Krčmář <rkrcmar@redhat.com> - 2016-09-30 15:30 +0200
      Re: [RFC PATCH 0/3] kvm: x86: speedups for APICv Radim Krčmář <rkrcmar@redhat.com> - 2016-09-30 15:40 +0200

csiph-web