From patchwork Tue Nov 24 18:00:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 548194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 394B91402C0 for ; Wed, 25 Nov 2015 05:02:18 +1100 (AEDT) Received: from localhost ([::1]:40358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1Huy-0001Ag-Af for incoming@patchwork.ozlabs.org; Tue, 24 Nov 2015 13:02:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1HuT-0000Cg-1t for qemu-devel@nongnu.org; Tue, 24 Nov 2015 13:01:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1HuS-0005kS-5b for qemu-devel@nongnu.org; Tue, 24 Nov 2015 13:01:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1HuN-0005hD-6h; Tue, 24 Nov 2015 13:01:39 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CE410A3D31; Tue, 24 Nov 2015 18:01:38 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAOI1X3h027817; Tue, 24 Nov 2015 13:01:37 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 24 Nov 2015 19:00:52 +0100 Message-Id: <1448388091-117282-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1448388091-117282-1-git-send-email-pbonzini@redhat.com> References: <1448388091-117282-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/40] 9pfs: allocate pdus with g_malloc/g_free X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Prepare for moving the allocation to virtqueue_pop. Signed-off-by: Paolo Bonzini --- hw/9pfs/virtio-9p-device.c | 7 +------ hw/9pfs/virtio-9p.c | 10 +++------- hw/9pfs/virtio-9p.h | 2 -- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index e3abcfa..72a93c2 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -57,7 +57,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); V9fsState *s = VIRTIO_9P(dev); - int i, len; + int len; struct stat stat; FsDriverEntry *fse; V9fsPath path; @@ -65,12 +65,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp) virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, sizeof(struct virtio_9p_config) + MAX_TAG_LEN); - /* initialize pdu allocator */ - QLIST_INIT(&s->free_list); QLIST_INIT(&s->active_list); - for (i = 0; i < (MAX_REQ - 1); i++) { - QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next); - } s->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output); diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index f972731..747306b 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -565,13 +565,9 @@ static int fid_to_qid(V9fsPDU *pdu, V9fsFidState *fidp, V9fsQID *qidp) static V9fsPDU *alloc_pdu(V9fsState *s) { - V9fsPDU *pdu = NULL; + V9fsPDU *pdu = g_new(V9fsPDU, 1); - if (!QLIST_EMPTY(&s->free_list)) { - pdu = QLIST_FIRST(&s->free_list); - QLIST_REMOVE(pdu, next); - QLIST_INSERT_HEAD(&s->active_list, pdu, next); - } + QLIST_INSERT_HEAD(&s->active_list, pdu, next); return pdu; } @@ -584,8 +580,8 @@ static void free_pdu(V9fsState *s, V9fsPDU *pdu) */ if (!pdu->cancelled) { QLIST_REMOVE(pdu, next); - QLIST_INSERT_HEAD(&s->free_list, pdu, next); } + g_free(pdu); } } diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index d7a4dc1..1fb4ff9 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -201,8 +201,6 @@ typedef struct V9fsState { VirtIODevice parent_obj; VirtQueue *vq; - V9fsPDU pdus[MAX_REQ]; - QLIST_HEAD(, V9fsPDU) free_list; QLIST_HEAD(, V9fsPDU) active_list; V9fsFidState *fid_list; FileOperations *ops;