From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=52864 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiO6d-0008NC-0l for qemu-devel@nongnu.org; Thu, 27 Jan 2011 04:25:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PiO6b-0000nU-TJ for qemu-devel@nongnu.org; Thu, 27 Jan 2011 04:25:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PiO6b-0000nD-IK for qemu-devel@nongnu.org; Thu, 27 Jan 2011 04:25:29 -0500 Message-ID: <4D413A02.5060700@redhat.com> Date: Thu, 27 Jan 2011 11:25:22 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC][PATCH 11/12] qcow2: Convert qcow2 to use coroutines for async I/O References: <1295688567-25496-1-git-send-email-stefanha@linux.vnet.ibm.com> <1295688567-25496-12-git-send-email-stefanha@linux.vnet.ibm.com> <4D40406B.2070302@redhat.com> <4D4042A8.2040903@redhat.com> <4D4046EF.3050108@codemonkey.ws> <4D40481E.9040309@redhat.com> <4D404B9F.7040801@codemonkey.ws> <4D404E1F.50809@redhat.com> <4D4055FB.6090104@codemonkey.ws> In-Reply-To: <4D4055FB.6090104@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org On 01/26/2011 07:12 PM, Anthony Liguori wrote: >> What do you actually save? The longjmp() to the coroutine code, >> linking in to the mutex wait queue, and another switch back to the >> main coroutine? Given that we don't expect to block often, it seems >> hardly a cost worth optimizing. > > > It's a matter of correctness, not optimization. > > Consider the following example: > > coroutine { > l2 = find_l2(offset); > // allocates but does not increment max cluster offset > l2[l2_offset(offset)] = alloc_cluster(); > > co_mutex_lock(&lock); > write_l2(l2); > co_mutex_unlock(&lock); > > l1[l1_offset(offset)] = l2; > > co_mutex_lock(&lock); > write_l1(l1); > co_mutex_unlock(&lock); > > commit_cluster(l2[l2_offset(offset)]); > } > > This code is incorrect. Yes it's incorrect, but it isn't what I'm proposing. -- error compiling committee.c: too many arguments to function