From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1GF7-00041b-AZ for qemu-devel@nongnu.org; Wed, 17 Dec 2014 10:10:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1GEv-0002Y2-Qy for qemu-devel@nongnu.org; Wed, 17 Dec 2014 10:10:25 -0500 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:33383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1GEv-0002Xr-Ku for qemu-devel@nongnu.org; Wed, 17 Dec 2014 10:10:13 -0500 Received: by mail-wi0-f171.google.com with SMTP id bs8so16075229wib.4 for ; Wed, 17 Dec 2014 07:10:13 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 17 Dec 2014 16:10:00 +0100 Message-Id: <1418829000-20288-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1418829000-20288-1-git-send-email-pbonzini@redhat.com> References: <1418829000-20288-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] 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: kwolf@redhat.com 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 --- 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