From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: x86: Convert INIT and SIPI signals into synchronously handled events Date: Wed, 13 Mar 2013 10:08:13 +0100 Message-ID: <514041FD.4050107@siemens.com> References: <513F1529.3040309@siemens.com> <513F1A63.9070107@redhat.com> <51402D1F.8000109@web.de> <514040CB.3070704@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , Marcelo Tosatti , kvm To: Paolo Bonzini Return-path: Received: from david.siemens.de ([192.35.17.14]:20207 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889Ab3CMJIT (ORCPT ); Wed, 13 Mar 2013 05:08:19 -0400 In-Reply-To: <514040CB.3070704@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2013-03-13 10:03, Paolo Bonzini wrote: > Il 13/03/2013 08:39, Jan Kiszka ha scritto: >>> I think this should clear pending SIPIs, unless KVM_APIC_INIT >>> was already set in which case it should be a no-op. Something >>> like: >>> >>> e = apic->pending_events; while (!(e & KVM_APIC_INIT)) e = >>> cmpxchg(&apic->pending_events, e, (e | KVM_APIC_INIT) & >>> ~KVM_APIC_SIPI); >>> >>> If you do this, better make pending_events an atomic_t. > >> Quick question: Why atomic_t? It becomes a bit ugly to poke into >> the atomic counter for bitops, and cmpxchg is mapped on an >> interlocked version. > > It's a bit safer because it forces you to use atomic_read, and > generally points out to reviewers to think about memory barriers. But > indeed the lack of atomic_set_bit and atomic_clear_bit makes the code > uglier. And as long as there are no other bits in > apic->pending_events, the above loop is actually the same as just > > apic->pending_events = 1 << KVM_APIC_INIT; Yeah, can simplify this in the next version of the just posted patch. Jan -- Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux