Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933012AbcJNS4t (ORCPT ); Fri, 14 Oct 2016 14:56:49 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:58956 "EHLO mx3-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbcJNS4k (ORCPT ); Fri, 14 Oct 2016 14:56:40 -0400 Date: Fri, 14 Oct 2016 14:56:38 -0400 (EDT) From: Paolo Bonzini To: Nadav Amit Cc: LKML , KVM , Radim =?utf-8?B?S3LEjW3DocWZ?= , Yang Zhang , feng wu , mst@redhat.com Message-ID: <770436977.3704467.1476471398385.JavaMail.zimbra@redhat.com> In-Reply-To: <4B0C832B-BB75-40BD-85A9-9DC84DEB44E2@gmail.com> References: <1476469291-5039-1-git-send-email-pbonzini@redhat.com> <1476469291-5039-2-git-send-email-pbonzini@redhat.com> <4B0C832B-BB75-40BD-85A9-9DC84DEB44E2@gmail.com> Subject: Re: [PATCH 1/5] KVM: x86: avoid atomic operations on APICv vmentry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.4.164.1, 10.5.100.50] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF49 (Linux)/8.0.6_GA_5922) Thread-Topic: x86: avoid atomic operations on APICv vmentry Thread-Index: 4flHIYdpb7XR/XsfzLUh0HT+rY1dgQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 583 Lines: 18 > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > > index 23b99f305382..63a442aefc12 100644 > > --- a/arch/x86/kvm/lapic.c > > +++ b/arch/x86/kvm/lapic.c > > @@ -342,9 +342,11 @@ void __kvm_apic_update_irr(u32 *pir, void *regs) > > u32 i, pir_val; > > > > for (i = 0; i <= 7; i++) { > > - pir_val = xchg(&pir[i], 0); > > - if (pir_val) > > + pir_val = READ_ONCE(pir[i]); > > Out of curiosity, do you really need this READ_ONCE? The answer can only be "depends on the compiler's whims". :) If you think of READ_ONCE as a C11 relaxed atomic load, then yes. Paolo