From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nadav Amit Subject: Re: [PATCH 1/5] KVM: x86: avoid atomic operations on APICv vmentry Date: Fri, 14 Oct 2016 12:44:53 -0700 Message-ID: <9B7F4808-2294-426D-B463-CEB188CED2E0@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> <770436977.3704467.1476471398385.JavaMail.zimbra@redhat.com> Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: LKML , KVM , =?utf-8?B?UmFkaW0gS3LEjW3DocWZ?= , Yang Zhang , feng wu , mst@redhat.com To: Paolo Bonzini Return-path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:32979 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754025AbcJNTo4 (ORCPT ); Fri, 14 Oct 2016 15:44:56 -0400 In-Reply-To: <770436977.3704467.1476471398385.JavaMail.zimbra@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: > On Oct 14, 2016, at 11:56 AM, Paolo Bonzini = wrote: >>>=20 >>> for (i =3D 0; i <=3D 7; i++) { >>> - pir_val =3D xchg(&pir[i], 0); >>> - if (pir_val) >>> + pir_val =3D READ_ONCE(pir[i]); >>=20 >> Out of curiosity, do you really need this READ_ONCE? >=20 > 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. Hm.. So the idea is to make the code "race-free=E2=80=9D in the sense that every concurrent memory access is done using READ_ONCE/WRITE_ONCE? If that is the case, I think there are many other cases that need to be changed, for example apic->irr_pending and vcpu->arch.pv.pv_unhalted.