From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H. Peter Anvin" Subject: Re: [PATCH] bitops: add _local bitops Date: Wed, 09 May 2012 07:03:37 -0700 Message-ID: <4FAA7939.6040706@zytor.com> References: <20120509134528.GA18044@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20120509134528.GA18044@redhat.com> Sender: linux-doc-owner@vger.kernel.org To: "Michael S. Tsirkin" Cc: Rob Landley , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Arnd Bergmann , Andrew Morton , David Howells , Akinobu Mita , Alexey Dobriyan , Herbert Xu , Stephen Rothwell , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Gleb Natapov , Paolo Bonzini , kvm@vger.kernel.org, Avi Kivity , Marcelo Tosatti , Linus Torvalds List-Id: linux-arch.vger.kernel.org On 05/09/2012 06:45 AM, Michael S. Tsirkin wrote: > kvm needs to update some hypervisor variables atomically > in a sense that the operation can't be interrupted > in the middle. However the hypervisor always runs > on the same CPU so it does not need any memory > barrier or lock prefix. > > At Peter Anvin's suggestion, add _local bitops for this purpose: > define them as non-atomics for x86 and (for now) atomics > for everyone else. > > Uses are not restricted to virtualization: they > might be useful to communicate with an interrupt > handler if we know that it's running on the same CPU. > > Signed-off-by: Michael S. Tsirkin I don't think you can use the x86 nonatomics as-is, because they don't contain optimization barriers. -hpa From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from terminus.zytor.com ([198.137.202.10]:40726 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641Ab2EIOER (ORCPT ); Wed, 9 May 2012 10:04:17 -0400 Message-ID: <4FAA7939.6040706@zytor.com> Date: Wed, 09 May 2012 07:03:37 -0700 From: "H. Peter Anvin" MIME-Version: 1.0 Subject: Re: [PATCH] bitops: add _local bitops References: <20120509134528.GA18044@redhat.com> In-Reply-To: <20120509134528.GA18044@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: "Michael S. Tsirkin" Cc: Rob Landley , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Arnd Bergmann , Andrew Morton , David Howells , Akinobu Mita , Alexey Dobriyan , Herbert Xu , Stephen Rothwell , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Gleb Natapov , Paolo Bonzini , kvm@vger.kernel.org, Avi Kivity , Marcelo Tosatti , Linus Torvalds Message-ID: <20120509140337.hGOF4tzgP9M4uGCEf4F63x6dXUcMPmpDWu-NSNmwcks@z> On 05/09/2012 06:45 AM, Michael S. Tsirkin wrote: > kvm needs to update some hypervisor variables atomically > in a sense that the operation can't be interrupted > in the middle. However the hypervisor always runs > on the same CPU so it does not need any memory > barrier or lock prefix. > > At Peter Anvin's suggestion, add _local bitops for this purpose: > define them as non-atomics for x86 and (for now) atomics > for everyone else. > > Uses are not restricted to virtualization: they > might be useful to communicate with an interrupt > handler if we know that it's running on the same CPU. > > Signed-off-by: Michael S. Tsirkin I don't think you can use the x86 nonatomics as-is, because they don't contain optimization barriers. -hpa