From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhL4J-0002Ip-Eg for qemu-devel@nongnu.org; Thu, 14 Jul 2011 08:31:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhL4I-0001Iz-Io for qemu-devel@nongnu.org; Thu, 14 Jul 2011 08:31:03 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:42383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhL4I-0001Iu-Fj for qemu-devel@nongnu.org; Thu, 14 Jul 2011 08:31:02 -0400 Received: by gyf2 with SMTP id 2so83859gyf.4 for ; Thu, 14 Jul 2011 05:31:01 -0700 (PDT) Message-ID: <4E1EE183.5050100@codemonkey.ws> Date: Thu, 14 Jul 2011 07:30:59 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1447945249.1317755.1310627692984.JavaMail.root@zmail01.collab.prod.int.phx2.redhat.com> <4E1EAA72.1060103@redhat.com> In-Reply-To: <4E1EAA72.1060103@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] New thread for the VM migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Umesh Deshpande , qemu-devel@nongnu.org, kvm@vger.kernel.org On 07/14/2011 03:36 AM, Avi Kivity wrote: > On 07/14/2011 10:14 AM, Umesh Deshpande wrote: >> Following patch is implemented to deal with the VCPU and iothread >> starvation during the migration of a guest. Currently iothread is >> responsible for performing the migration. It holds the qemu_mutex >> during the migration and doesn't allow VCPU to enter the qemu mode and >> delays its return to the guest. The guest migration, executed as an >> iohandler also delays the execution of other iohandlers. In the >> following patch, the migration has been moved to a separate thread to >> reduce the qemu_mutex contention and iohandler starvation. >> >> >> @@ -260,10 +260,15 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int >> stage, void *opaque) >> return 0; >> } >> >> + if (stage != 3) >> + qemu_mutex_lock_iothread(); > > Please read CODING_STYLE, especially the bit about braces. > > Does this mean that the following code is sometimes executed without > qemu_mutex? I don't think any of it is thread safe. That was my reaction too. I think the most rational thing to do is have a separate thread and a pair of producer/consumer queues. The I/O thread can push virtual addresses and sizes to the queue for the migration thread to compress/write() to the fd. The migration thread can then push sent regions onto a separate queue for the I/O thread to mark as dirty. Regards, Anthony Liguori > > Even just reading memory is not thread safe. You either have to copy it > into a buffer under lock, or convert the memory API to RCU. >