From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8JLN-0002Le-43 for qemu-devel@nongnu.org; Wed, 11 Nov 2009 14:59:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8JLI-0002FQ-3x for qemu-devel@nongnu.org; Wed, 11 Nov 2009 14:59:04 -0500 Received: from [199.232.76.173] (port=36224 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8JLH-0002FJ-RO for qemu-devel@nongnu.org; Wed, 11 Nov 2009 14:58:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15592) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8JLH-00025v-AF for qemu-devel@nongnu.org; Wed, 11 Nov 2009 14:58:59 -0500 Date: Wed, 11 Nov 2009 21:56:16 +0200 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments Message-ID: <20091111195616.GA31861@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> <20091111180928.GB31061@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 02:37:26AM +0800, Scott Tsai wrote: > On Thu, Nov 12, 2009 at 2:09 AM, Michael S. Tsirkin wrote: > >> 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? > > I naively imagined it to work like this: > When CONFIG_IOTHREAD is true and CONFIG_KVM is false, > all the tcg CPUs run in the tcg_cpu_thread and device emulation code > runs in io_thread, > so if the tcg translators generate suitable memory barrier > instructions when it sees a "lfence", "sfence", "mfence" instruction > while emulating a x86 or "sync" while emulating a MIPS everything > should work that might not be enough. guest can do e.g. atomics on the same memory with iothread. In parctice, with virtio it doesn't. > but a quick look at target-*/translate.c suggests memory > barrier instructions are treated as nops. > > So maybe --enable-io-thread while --disable-kvm should not be allowed > at configure time. > Does anyone actually ship qemu with CONFIG_IOTHREAD enabled?