From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8Hfz-0001P9-Tn for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:12:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8Hfv-0001Gn-0i for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:12:15 -0500 Received: from [199.232.76.173] (port=33259 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8Hfu-0001GZ-ST for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:12:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34655) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8Hfu-0000ay-F4 for qemu-devel@nongnu.org; Wed, 11 Nov 2009 13:12:10 -0500 Date: Wed, 11 Nov 2009 20:09:28 +0200 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments Message-ID: <20091111180928.GB31061@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 > > 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 Right. I don't think CONFIG_IOTHREAD can work correctly without kvm though: how would atomics be handled? -- MST