From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] KVM: x86: Convert INIT and SIPI signals into synchronously handled events Date: Wed, 13 Mar 2013 10:03:07 +0100 Message-ID: <514040CB.3070704@redhat.com> References: <513F1529.3040309@siemens.com> <513F1A63.9070107@redhat.com> <51402D1F.8000109@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , Marcelo Tosatti , kvm To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:64802 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754127Ab3CMJDS (ORCPT ); Wed, 13 Mar 2013 05:03:18 -0400 In-Reply-To: <51402D1F.8000109@web.de> Sender: kvm-owner@vger.kernel.org List-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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; Paolo -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJRQEDHAAoJEBvWZb6bTYbyjhcP/iiky7ZedYXuAA3nI9rVNI79 YUNL9wWzK7EEa7sT54/ky6D5cY+6f/Zjy3TBQexpNscJWJvdPWgU33nA4cA4YnXn cguOUbZ63AKe1a/fFmyc8Kb45Y2tJVJ3tLOH0WZHBh1gPE8BWOCSx/cUncb15oBc CTWS7l6ZjTN5wSJytR/nbGSBvdzBmrlKgMpFb9eiP0lhnMLhrtX/ihdsyLzk8mJV nyTH9LFu3jJoVsSMDn341egx6QGaWiZ/1yzBg8zS9YbbqamxYsUKhBZtF+jwdwR/ hDQsQJuk6d3zJxJysAb1ESQGA18ulKZ2FAa0ozUIn6W1BqKihzW9smZ5gDrs7ZNW zQaraN6swhxvN1UN/Ik1r6esBc2b/LCGtKAgl/Vjm+Kyf5skhVxREUZAGHLOY+Q6 e3TuEAY0N4zLtS4zTB/1tom+MzpWdS2Zrla8pTP8hDGj54vopxCK1fbonv13dwzH hkd+ddzWqRzclDy6MIDNW9e/hzn4g37UMIr4ZkezwciFHz/Oxti5qj8+DOOO0R9r k0CNpyRFwyC+IccS00omdivX9sHW7tbYw2LVKuw4rWvgW5RnGCcRUj9TdxtO1twy 66DhSobVUZr6RHJsYCWtOzyZacKcRHzYGKuizSq9idTRqMpArTVn8jIt69nruG04 LFGiA06mwKP+OGLmmAbN =Y3al -----END PGP SIGNATURE-----