From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzDut-0004dl-Eq for qemu-devel@nongnu.org; Thu, 01 Sep 2011 16:31:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzDus-0000bJ-92 for qemu-devel@nongnu.org; Thu, 01 Sep 2011 16:31:15 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:45268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzDur-0000bF-U7 for qemu-devel@nongnu.org; Thu, 01 Sep 2011 16:31:14 -0400 Date: Thu, 1 Sep 2011 16:31:09 -0400 (EDT) From: Paolo Bonzini Message-ID: <786649703.1049386.1314909069542.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> In-Reply-To: <20110901163359.GB11620@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio: Make memory barriers be memory barriers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: aliguori@us.ibm.com, aik@ozlabs.ru, rusty@rustcorp.com.au, agraf@suse.de, qemu-devel@nongnu.org, David Gibson > > > Why not limit the change to ppc then? > > > > Because the bug is masked by the x86 memory model, but it is still > > there even there conceptually. It is not really true that x86 does > > not need memory barriers, though it doesn't in this case: > > > > http://bartoszmilewski.wordpress.com/2008/11/05/who-ordered-memory-fences-on-an-x86/ > > > > Paolo > > Right. > To summarize, on x86 we probably want wmb and rmb to be compiler > barrier only. Only mb might in theory need to be an mfence. No, wmb needs to be sfence and rmb needs to be lfence. GCC does not provide those, so they should become __sync_synchronize() too, or you should use inline assembly. > But there might be reasons why that is not an issue either > if we look closely enough. Since the ring buffers are not using locked instructions (no xchg or cmpxchg) the barriers simply must be there, even on x86. Whether it works in practice is not interesting, only the formal model is interesting. Paolo