From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXv1n-0002os-Km for qemu-devel@nongnu.org; Tue, 06 Dec 2011 08:25:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXv1h-0007qg-UU for qemu-devel@nongnu.org; Tue, 06 Dec 2011 08:25:47 -0500 Received: from mail-fx0-f45.google.com ([209.85.161.45]:46991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXv1h-0007qa-Me for qemu-devel@nongnu.org; Tue, 06 Dec 2011 08:25:41 -0500 Received: by faao26 with SMTP id o26so1286768faa.4 for ; Tue, 06 Dec 2011 05:25:40 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1323105612-32419-1-git-send-email-avi@redhat.com> References: <1323105612-32419-1-git-send-email-avi@redhat.com> Date: Tue, 6 Dec 2011 13:25:40 +0000 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] coroutine: switch per-thread free pool to a global pool List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On Mon, Dec 5, 2011 at 5:20 PM, Avi Kivity wrote: > ucontext-based coroutines use a free pool to reduce allocations and > deallocations of coroutine objects. =A0The pool is per-thread, presumably > to improve locality. =A0However, as coroutines are usually allocated in > a vcpu thread and freed in the I/O thread, the pool accounting gets > screwed up and we end allocating and freeing a coroutine for every I/O > request. =A0This is expensive since large objects are allocated via the > kernel, and are not cached by the C runtime. > > Fix by switching to a global pool. =A0This is safe since we're protected > by the global mutex. Looks good to me. I did check how hw/9pfs/ uses coroutines because it bounces them into worker threads that are not under the QEMU mutex but they are not created/destroyed there so we should be okay. Stefan