From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUoWu-0005CN-AB for qemu-devel@nongnu.org; Wed, 16 May 2012 20:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUoWg-0000Ce-Ie for qemu-devel@nongnu.org; Wed, 16 May 2012 20:25:19 -0400 Received: from gate.crashing.org ([63.228.1.57]:54876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUoWg-0000Ah-9p for qemu-devel@nongnu.org; Wed, 16 May 2012 20:25:06 -0400 Message-ID: <1337214293.30558.25.camel@pasglop> From: Benjamin Herrenschmidt Date: Thu, 17 May 2012 10:24:53 +1000 In-Reply-To: <1337213257.30558.22.camel@pasglop> References: <1336625347-10169-1-git-send-email-benh@kernel.crashing.org> <1336625347-10169-14-git-send-email-benh@kernel.crashing.org> <4FB1A8BF.7060503@codemonkey.ws> <20120515014449.GF30229@truffala.fritz.box> <1337142938.6727.122.camel@pasglop> <4FB4028F.7070003@codemonkey.ws> <1337213257.30558.22.camel@pasglop> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 13/13] iommu: Add a memory barrier to DMA RW function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, David Gibson On Thu, 2012-05-17 at 10:07 +1000, Benjamin Herrenschmidt wrote: .../... > Also, should I make the barrier conditional to kvm_enabled() ? IE. It's > pointless in full emulation and might actually be a performance hit on > something already quite slow... Finally ... something like smp_mb() in qemu will turn into a lock op or an mfence on x86, ie not a nop. That means overhead from today's implementation, which leads to the question ... is today implementation correct ? IE. Is a barrier needed on x86 as well or not ? If not (I'm trying to figure out why exactly does x86 have a barrier in the first place and when it's in order), then I might add a new barrier type in qemu-barriers.h, something like dma_mb(), and define it as a nop on x86, a lwsync or sync (still thinking about it) on ppc, and __sync_synchronize() on unknown archs. Any x86 guru around cares to explain me what exactly is the x86 memory model and when does it need barriers ? Cheers, Ben.