From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPU52-00071z-J1 for qemu-devel@nongnu.org; Fri, 27 Sep 2013 05:11:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPU4w-0003f3-EH for qemu-devel@nongnu.org; Fri, 27 Sep 2013 05:11:20 -0400 Date: Fri, 27 Sep 2013 11:11:07 +0200 From: Stefan Hajnoczi Message-ID: <20130927091107.GA9972@stefanha-thinkpad.redhat.com> References: <1378910555-24753-1-git-send-email-stefanha@redhat.com> <52451595.1000506@weilnetz.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52451595.1000506@weilnetz.de> Subject: Re: [Qemu-devel] [PATCH] coroutine: add ./configure --disable-coroutine-pool List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Kevin Wolf , gabriel@kerneis.info, qemu-devel@nongnu.org, qemu-stable On Fri, Sep 27, 2013 at 07:20:21AM +0200, Stefan Weil wrote: > Am 11.09.2013 16:42, schrieb Stefan Hajnoczi: > > The 'gthread' coroutine backend was written before the freelist (aka > > pool) existed in qemu-coroutine.c. > > > > This means that every thread is expected to exit when its coroutine > > terminates. It is not possible to reuse threads from a pool. > > > > This patch automatically disables the pool when 'gthread' is used. This > > allows the 'gthread' backend to work again (for example, > > tests/test-coroutine completes successfully instead of hanging). > > > > I considered implementing thread reuse but I don't want quirks like CPU > > affinity differences due to coroutine threads being recycled. The > > 'gthread' backend is a reference backend and it's therefore okay to skip > > the pool optimization. > > > > Note this patch also makes it easy to toggle the pool for benchmarking > > purposes: > > > > ./configure --with-coroutine-backend=ucontext \ > > --disable-coroutine-pool > > > > Reported-by: Gabriel Kerneis > > Signed-off-by: Stefan Hajnoczi > > --- > > configure | 24 ++++++++++++++++++++++++ > > qemu-coroutine.c | 34 +++++++++++++++++++--------------- > > 2 files changed, 43 insertions(+), 15 deletions(-) > > > > This patch is important for QEMU 1.5 as well, but needs some > modifications there. > A recent bug report for MinGW shows that the win32 coroutine needs it, too. coroutine-win32.c is designed to support reuse: static void CALLBACK coroutine_trampoline(void *co_) { Coroutine *co = co_; while (true) { co->entry(co->entry_arg); qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); } } We return from qemu_coroutine_switch() when the fiber is reused and simply run another iteration of the while loop. Why do you say win32 coroutines should disable the pool? Stefan