Received: from eggs.gnu.org ([208.118.235.92]:33169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHssY-0008V0-0D for qemu-devel@nongnu.org; Tue, 19 Mar 2013 05:30:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHssU-0001XU-OG for qemu-devel@nongnu.org; Tue, 19 Mar 2013 05:30:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHssU-0001XD-Cu for qemu-devel@nongnu.org; Tue, 19 Mar 2013 05:30:42 -0400 From: Markus Armbruster References: <1363154346-14827-1-git-send-email-qemulist@gmail.com> <51405BEA.6080109@redhat.com> <87hakfiild.fsf@codemonkey.ws> Date: Tue, 19 Mar 2013 10:30:34 +0100 In-Reply-To: (Peter Maydell's message of "Thu, 14 Mar 2013 10:04:23 +0000") Message-ID: <87r4jbn3d1.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [RFC PATCH 0/2] port network layer onto glib List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: mdroth , "Michael S. Tsirkin" , Stefan Hajnoczi , qemu-devel@nongnu.org, Liu Ping Fan , Anthony Liguori , Paolo Bonzini Peter Maydell writes: > On 13 March 2013 12:34, Anthony Liguori wrote: >> AioContext is necessary for the block layer because the block layer >> still has synchronous I/O. I think we should aim to replace all sync >> I/O in the long term with coroutine based I/O. > > I think coroutines are dreadful and we should really not be moving > towards greater use of them. They're just really really not portable > and they don't fit with the C language, and they're a constant source > of problems.(For instance I have a bug I need to look into where we > seem to hang using the gthread coroutine backend but not sigaltstack.) > > Use threads, or a genuinely asynchronous API, or a select/poll loop > with callbacks, but not more coroutines please. I disagree. Coroutines are a perfectly pedestrian control flow construct. Stefan already explained why we use them, and why callbacks are not a viable alternative when things get hairy. Coroutines fit about as well with C as threads, namely not really. Unfortunate, but switching to threads won't improve that aspect one bit, just add "interesting" concurrency and performance problems to the mix. If portable coroutines in C really was an intractable problem, the solution could not be "no more coroutines, please", only "no coroutines, period". As long as we have to pay the price for coroutines anyway, I can't see why we should deny ourselves the benefits. C programs have been doing coroutines since forever, using either hand coded assembly language stack switching, sigaltstack() trickery, ucontext(), w32 fibers, or some coroutine library built on top of these. We chose "all of the above" (except for assembly). No wonder we got more problems. Some of our portability problems come from our heroic (quixotic?) quest to keep QEMU portable to the widest range of hosts, without sacrificing performance on any of them. Sometimes it takes a tough man to make a tender chicken.