From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8Hej-0007sA-ED for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:10:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8Hee-0007jL-GW for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:10:56 -0500 Received: from [199.232.76.173] (port=33179 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8Hee-0007j8-0s for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:10:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1026) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8Hed-0000Je-Jf for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:10:51 -0500 Date: Wed, 11 Nov 2009 20:08:08 +0200 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments Message-ID: <20091111180808.GA31061@redhat.com> References: <20091026131715.GA25271@redhat.com> <200911111301.03427.paul@codesourcery.com> <20091111131253.GC23036@redhat.com> <200911111345.35249.paul@codesourcery.com> <20091111140819.GA29736@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Scott Tsai Cc: Paul Brook , qemu-devel@nongnu.org On Thu, Nov 12, 2009 at 01:18:11AM +0800, Scott Tsai wrote: > On Wed, Nov 11, 2009 at 10:08 PM, Michael S. Tsirkin wrote: > > On Wed, Nov 11, 2009 at 01:45:35PM +0000, Paul Brook wrote: > >> If you don't need real barriers, then why does the kvm code have them? > > > > We need real barriers but AFAIK kvm does not have them :( > > IOW: virtio is currently broken with kvm, and my patch did > > not fix this. The comment that I added says as much. > > How about just using GCC's __sync__synchronize atomic builtin (if > detected as available by configure)? > It's a full memory barrier instead of just a write barrier, for x86, > it generates the same code as the current Linux mb() implementation: > "mfence" on x86_64 > "lock orl $0x0,(%esp)" on x86 unless -march is specified to a > processor with "mfence". > PPC could continue to use "eieio" while other architectures could just > default to __sync_synchronize Hmm, on x86 that's more expensive than it needs to be... We can also ifdef platforms that we care about ... > I do have a newbie question, when exactly would vrtio have to handle > concurrent access from multiple threads? > My current reading of the code suggests: > 1. when CONFIG_IOTHREAD is true > 2. when CONFIG_KVM is true and the guest machine has multiple CPUs