[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 01/40] 9pfs: allocate pdus with g_malloc/g_free
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 01/40] 9pfs: allocate pdus with g_malloc/g_free |
Date: |
Mon, 30 Nov 2015 10:27:01 +0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, 11/24 19:00, Paolo Bonzini wrote:
> Prepare for moving the allocation to virtqueue_pop.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> 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;
> }
OK, and I think handle_9p_output no longer needs to check the returned pointer.
Fam
>
> @@ -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;
> --
> 1.8.3.1
>
>
>
- [Qemu-devel] [RFC PATCH 00/40] Sneak peek of virtio and dataplane changes for 2.6, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 01/40] 9pfs: allocate pdus with g_malloc/g_free, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 02/40] virtio: move VirtQueueElement at the beginning of the structs, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 06/40] virtio: introduce virtqueue_alloc_element, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 03/40] virtio: move allocation to virtqueue_pop/vring_pop, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 04/40] virtio: introduce qemu_get/put_virtqueue_element, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 07/40] virtio: slim down allocation of VirtQueueElements, Paolo Bonzini, 2015/11/24