From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y20WS-0001WK-VQ for qemu-devel@nongnu.org; Fri, 19 Dec 2014 11:35:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y20WM-0002lF-R6 for qemu-devel@nongnu.org; Fri, 19 Dec 2014 11:35:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y20WM-0002kv-KY for qemu-devel@nongnu.org; Fri, 19 Dec 2014 11:35:18 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBJGZIrk014100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 19 Dec 2014 11:35:18 -0500 From: Kevin Wolf Date: Fri, 19 Dec 2014 17:34:56 +0100 Message-Id: <1419006909-1781-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1419006909-1781-1-git-send-email-kwolf@redhat.com> References: <1419006909-1781-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 06/19] 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 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 */ -- 1.8.3.1