From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAisj-00063V-7k for qemu-devel@nongnu.org; Mon, 12 Jan 2015 12:34:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAisd-0004ow-0x for qemu-devel@nongnu.org; Mon, 12 Jan 2015 12:34:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAisc-0004oY-PT for qemu-devel@nongnu.org; Mon, 12 Jan 2015 12:34:18 -0500 From: Stefan Hajnoczi Date: Mon, 12 Jan 2015 16:39:55 +0000 Message-Id: <1421080834-14724-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1421080834-14724-1-git-send-email-stefanha@redhat.com> References: <1421080834-14724-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL v2 05/44] block: replace g_new0 with g_new for bottom half allocation. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Paolo Bonzini From: Paolo Bonzini This saves about 15% of the clock cycles spent on allocation. Using the slice allocator does not add a visible improvement; allocation is faster than malloc, while freeing seems to be slower. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- async.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/async.c b/async.c index 572f239..2be88cc 100644 --- a/async.c +++ b/async.c @@ -44,10 +44,12 @@ struct QEMUBH { QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) { QEMUBH *bh; - bh = g_new0(QEMUBH, 1); - bh->ctx = ctx; - bh->cb = cb; - bh->opaque = opaque; + bh = g_new(QEMUBH, 1); + *bh = (QEMUBH){ + .ctx = ctx, + .cb = cb, + .opaque = opaque, + }; qemu_mutex_lock(&ctx->bh_lock); bh->next = ctx->first_bh; /* Make sure that the members are ready before putting bh into list */ -- 2.1.0