From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH RFC] KVM: Fix race in apic->pending_events processing Date: Thu, 30 May 2013 16:10:54 +0300 Message-ID: <20130530131054.GB5495@redhat.com> References: <20130528150057.GA6891@redhat.com> <51A4DC63.2040906@redhat.com> <20130530012048.GB20766@redhat.com> <51A6E671.8070408@redhat.com> <20130530060150.GA28173@redhat.com> <51A6F22F.2000600@redhat.com> <20130530070906.GA29815@redhat.com> <51A70021.1040809@redhat.com> <20130530123454.GA4845@redhat.com> <51A74CE1.1000700@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Jan Kiszka To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:7208 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751430Ab3E3NK5 (ORCPT ); Thu, 30 May 2013 09:10:57 -0400 Content-Disposition: inline In-Reply-To: <51A74CE1.1000700@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 > >> > http://article.gmane.org/gmane.comp.emulators.kvm.devel/110505 > >> > > > I still do not. Both of them are tricky, mine does not coalesce events > > needlessly. > > Agreed that both are tricky, but I don't think my patch is coalescing > events. If you have > > INIT SIPI INIT SIPI > ^ ^ > INIT bit cleared here SIPI bit checked here > Not sure I understand what you are trying to say here. > my patch KVM sees apic_events = INIT | SIPI and deduces that the SIPI > bit was set by the second SIPI, not by the first. In fact the first > SIPI was cancelled by the second INIT, and thus should not be processed > at all. That is called coalesced. > > Instead, with your patch KVM will service all four events; strictly > speaking it is wrong to service the first SIPI, which is why I prefer > having the cmpxchg in the beginning. > y Why is it wrong? I do not see what are you arguing about. -- Gleb.