Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-06-02 Thread Gleb Natapov
On Fri, May 31, 2013 at 11:48:10AM +0200, Paolo Bonzini wrote: Il 31/05/2013 11:18, Gleb Natapov ha scritto: On Fri, May 31, 2013 at 10:48:32AM +0200, Paolo Bonzini wrote: Il 31/05/2013 06:36, Gleb Natapov ha scritto: In my commit message there is two INITs in a row: vpu0:

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-06-02 Thread Paolo Bonzini
Il 02/06/2013 15:14, Gleb Natapov ha scritto: Can you show what is the case in my patch where you have coalescing? I You'ev said it in some of your emails. Quoting: INIT-INIT-SIPI-INIT-SIPI your version would do many SIPIs, while mine would do just one. Cancelling is very different

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-06-02 Thread Gleb Natapov
On Sun, Jun 02, 2013 at 04:32:25PM +0200, Paolo Bonzini wrote: So what I didn't like from the start about pending_events is that it introduces two locked instruction on each interrupt injection path, your patch makes it worse by change one of those locked instruction to cmpxchg, while mine

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-31 Thread Paolo Bonzini
Il 31/05/2013 06:36, Gleb Natapov ha scritto: In my commit message there is two INITs in a row: vpu0:vcpu1: set INIT test_and_clear_bit(KVM_APIC_INIT) process INIT set INIT set SIPI

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-31 Thread Gleb Natapov
On Fri, May 31, 2013 at 10:48:32AM +0200, Paolo Bonzini wrote: Il 31/05/2013 06:36, Gleb Natapov ha scritto: In my commit message there is two INITs in a row: vpu0:vcpu1: set INIT test_and_clear_bit(KVM_APIC_INIT)

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-31 Thread Paolo Bonzini
Il 31/05/2013 11:18, Gleb Natapov ha scritto: On Fri, May 31, 2013 at 10:48:32AM +0200, Paolo Bonzini wrote: Il 31/05/2013 06:36, Gleb Natapov ha scritto: In my commit message there is two INITs in a row: vpu0:vcpu1: set INIT

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Gleb Natapov
On Thu, May 30, 2013 at 07:41:05AM +0200, Paolo Bonzini wrote: Il 30/05/2013 03:20, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 06:33:39PM +0200, Paolo Bonzini wrote: Il 28/05/2013 17:00, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 03:48:58PM +0200, Paolo Bonzini wrote: Il

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Paolo Bonzini
Il 30/05/2013 08:01, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 07:41:05AM +0200, Paolo Bonzini wrote: Il 30/05/2013 03:20, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 06:33:39PM +0200, Paolo Bonzini wrote: Il 28/05/2013 17:00, Gleb Natapov ha scritto: On Tue, May 28, 2013 at

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Gleb Natapov
On Thu, May 30, 2013 at 08:31:11AM +0200, Paolo Bonzini wrote: Il 30/05/2013 08:01, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 07:41:05AM +0200, Paolo Bonzini wrote: Il 30/05/2013 03:20, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 06:33:39PM +0200, Paolo Bonzini wrote: Il

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Paolo Bonzini
Il 30/05/2013 09:09, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 08:31:11AM +0200, Paolo Bonzini wrote: Il 30/05/2013 08:01, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 07:41:05AM +0200, Paolo Bonzini wrote: Il 30/05/2013 03:20, Gleb Natapov ha scritto: On Tue, May 28, 2013 at

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Gleb Natapov
On Thu, May 30, 2013 at 09:30:41AM +0200, Paolo Bonzini wrote: Il 30/05/2013 09:09, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 08:31:11AM +0200, Paolo Bonzini wrote: Il 30/05/2013 08:01, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 07:41:05AM +0200, Paolo Bonzini wrote: Il

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Paolo Bonzini
Il 30/05/2013 14:34, Gleb Natapov ha scritto: Ah, we check kvm_apic_has_events() in runnable. Then yes, we will not lose the event. Ok, then I'd prefer to have the cmpxchg directly in the if, as in http://article.gmane.org/gmane.comp.emulators.kvm.devel/110505 I still do not.

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Gleb Natapov
On Thu, May 30, 2013 at 02:58:09PM +0200, Paolo Bonzini wrote: Il 30/05/2013 14:34, Gleb Natapov ha scritto: Ah, we check kvm_apic_has_events() in runnable. Then yes, we will not lose the event. Ok, then I'd prefer to have the cmpxchg directly in the if, as in

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Paolo Bonzini
Il 30/05/2013 15:10, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 02:58:09PM +0200, Paolo Bonzini wrote: Il 30/05/2013 14:34, Gleb Natapov ha scritto: Ah, we check kvm_apic_has_events() in runnable. Then yes, we will not lose the event. Ok, then I'd prefer to have the cmpxchg directly

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Gleb Natapov
On Thu, May 30, 2013 at 03:23:35PM +0200, Paolo Bonzini wrote: Il 30/05/2013 15:10, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 02:58:09PM +0200, Paolo Bonzini wrote: Il 30/05/2013 14:34, Gleb Natapov ha scritto: Ah, we check kvm_apic_has_events() in runnable. Then yes, we will not

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Paolo Bonzini
Il 30/05/2013 15:35, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 03:23:35PM +0200, Paolo Bonzini wrote: Il 30/05/2013 15:10, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 02:58:09PM +0200, Paolo Bonzini wrote: Il 30/05/2013 14:34, Gleb Natapov ha scritto: Ah, we check

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-30 Thread Gleb Natapov
On Thu, May 30, 2013 at 04:15:35PM +0200, Paolo Bonzini wrote: Il 30/05/2013 15:35, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 03:23:35PM +0200, Paolo Bonzini wrote: Il 30/05/2013 15:10, Gleb Natapov ha scritto: On Thu, May 30, 2013 at 02:58:09PM +0200, Paolo Bonzini wrote: Il

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-29 Thread Gleb Natapov
On Tue, May 28, 2013 at 06:33:39PM +0200, Paolo Bonzini wrote: Il 28/05/2013 17:00, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 03:48:58PM +0200, Paolo Bonzini wrote: Il 28/05/2013 14:56, Gleb Natapov ha scritto: else vcpu-arch.mp_state =

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-29 Thread Paolo Bonzini
Il 30/05/2013 03:20, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 06:33:39PM +0200, Paolo Bonzini wrote: Il 28/05/2013 17:00, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 03:48:58PM +0200, Paolo Bonzini wrote: Il 28/05/2013 14:56, Gleb Natapov ha scritto: else

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-28 Thread Paolo Bonzini
Il 26/05/2013 15:00, Gleb Natapov ha scritto: apic-pending_events processing has a race that may cause INIT and SIPI processing to be reordered: vpu0:vcpu1: set INIT test_and_clear_bit(KVM_APIC_INIT)

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-28 Thread Gleb Natapov
On Tue, May 28, 2013 at 12:56:19PM +0200, Paolo Bonzini wrote: Il 26/05/2013 15:00, Gleb Natapov ha scritto: apic-pending_events processing has a race that may cause INIT and SIPI processing to be reordered: vpu0:vcpu1: set INIT

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-28 Thread Paolo Bonzini
Il 28/05/2013 14:56, Gleb Natapov ha scritto: else vcpu-arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; } - if (test_and_clear_bit(KVM_APIC_SIPI, apic-pending_events) + /* + * Note that we may get another INIT+SIPI sequence right here; process + *

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-28 Thread Gleb Natapov
On Tue, May 28, 2013 at 03:48:58PM +0200, Paolo Bonzini wrote: Il 28/05/2013 14:56, Gleb Natapov ha scritto: else vcpu-arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; } -if (test_and_clear_bit(KVM_APIC_SIPI,

Re: [PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-28 Thread Paolo Bonzini
Il 28/05/2013 17:00, Gleb Natapov ha scritto: On Tue, May 28, 2013 at 03:48:58PM +0200, Paolo Bonzini wrote: Il 28/05/2013 14:56, Gleb Natapov ha scritto: else vcpu-arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; } - if (test_and_clear_bit(KVM_APIC_SIPI,

[PATCH RFC] KVM: Fix race in apic-pending_events processing

2013-05-26 Thread Gleb Natapov
apic-pending_events processing has a race that may cause INIT and SIPI processing to be reordered: vpu0:vcpu1: set INIT test_and_clear_bit(KVM_APIC_INIT) process INIT set INIT set SIPI