[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 05/17] garbage collector: introduced for support
From: |
Ming Lei |
Subject: |
[Qemu-devel] [PATCH v1 05/17] garbage collector: introduced for support of bypass coroutine |
Date: |
Tue, 5 Aug 2014 11:33:06 +0800 |
In case of bypass coroutine, some buffers in stack have to convert
to survive in the whole I/O submit & completion cycle.
Garbase collector is one of the best data structure for this purpose,
as I thought of.
Signed-off-by: Ming Lei <address@hidden>
---
include/qemu/gc.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 include/qemu/gc.h
diff --git a/include/qemu/gc.h b/include/qemu/gc.h
new file mode 100644
index 0000000..b9a3f6e
--- /dev/null
+++ b/include/qemu/gc.h
@@ -0,0 +1,56 @@
+#ifndef QEMU_GC_HEADER
+#define QEMU_GC_HEADER
+
+#include "qemu/queue.h"
+
+/* simple garbage collector implementation for bypass coroutine */
+
+/* internal type and helper */
+typedef struct SimpleGCNode SimpleGCNode;
+struct SimpleGCNode {
+ void *addr;
+ void (*free)(void *data);
+ QLIST_ENTRY(SimpleGCNode) node;
+};
+
+static inline void simple_gc_free_one(SimpleGCNode *node)
+{
+ if (node->free) {
+ node->free(node->addr);
+ } else {
+ qemu_vfree(node->addr);
+ }
+
+ g_free(node);
+}
+
+/* public type and helpers */
+typedef struct {
+ QLIST_HEAD(, SimpleGCNode) head;
+} SimpleGC;
+
+static inline void simple_gc_init(SimpleGC *gc)
+{
+ QLIST_INIT(&gc->head);
+}
+
+static inline void simple_gc_add(SimpleGC *gc, void *addr,
+ void (*free)(void *data))
+{
+ SimpleGCNode *node = g_malloc0(sizeof(*node));
+
+ node->addr = addr;
+ node->free = free;
+ QLIST_INSERT_HEAD(&gc->head, node, node);
+}
+
+static inline void simple_gc_free_all(SimpleGC *gc)
+{
+ SimpleGCNode *curr, *next;
+
+ QLIST_FOREACH_SAFE(curr, &gc->head, node, next) {
+ QLIST_REMOVE(curr, node);
+ simple_gc_free_one(curr);
+ }
+}
+#endif
--
1.7.9.5
[Qemu-devel] [PATCH v1 02/17] dataplane: use object pool to speed up allocation for virtio blk request, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 03/17] qemu coroutine: support bypass mode, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 04/17] block: prepare for supporting selective bypass coroutine, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 05/17] garbage collector: introduced for support of bypass coroutine,
Ming Lei <=
[Qemu-devel] [PATCH v1 06/17] block: introduce bdrv_co_can_bypass_co, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 07/17] block: support to bypass qemu coroutinue, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 08/17] Revert "raw-posix: drop raw_get_aio_fd() since it is no longer used", Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 09/17] dataplane: enable selective bypassing coroutine, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 10/17] linux-aio: fix submit aio as a batch, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 11/17] linux-aio: handling -EAGAIN for !s->io_q.plugged case, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 12/17] linux-aio: increase max event to 256, Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 13/17] linux-aio: remove 'node' from 'struct qemu_laiocb', Ming Lei, 2014/08/04
[Qemu-devel] [PATCH v1 14/17] hw/virtio/virtio-blk.h: introduce VIRTIO_BLK_F_MQ, Ming Lei, 2014/08/04