Skip to contentSkip to conversation

iothread: Add "spawns" property

RFC PATCH In review Fam Zheng 4 participants 5 messages Oct 19, 2016 – Nov 4, 2016

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

RFC PATCH 1/1 iothread: Add "spawns" property

The option specifies how many threads to spawn under the iothread object. All threads share the same AioContext so they can safely run (contend) together.

With AioContext going away, the spawns will natually enable the block multi-queue work.

---

Based on v2 of Paolo's RFifoLock removal series, with which the symmetric contention on the single AioContext is no longer a busy preempt loop.

---
 include/sysemu/iothread.h |  19 ++++--
 iothread.c                | 148 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 125 insertions(+), 42 deletions(-)
include/sysemu/iothread.h +14 -5
index 68ac2de..b50e76c 100644
@@ -19,16 +19,25 @@
 
 #define TYPE_IOTHREAD "iothread"
 
-typedef struct {
-    Object parent_obj;
+typedef struct IOThread IOThread;
 
+typedef struct {
     QemuThread thread;
-    AioContext *ctx;
+    int thread_id;
+    IOThread *iothread;
     QemuMutex init_done_lock;
     QemuCond init_done_cond;    /* is thread initialization done? */
+    bool running;
+} IOThreadSpawn;
+
+struct IOThread {
+    Object parent_obj;
+
+    uint32_t nspawns;
+    IOThreadSpawn *spawns;
+    AioContext *ctx;
     bool stopping;
-    int thread_id;
-} IOThread;
+};
 
 #define IOTHREAD(obj) \
    OBJECT_CHECK(IOThread, obj, TYPE_IOTHREAD)
iothread.c +111 -37

223 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 11 lines · Fam Zheng

The option specifies how many threads to spawn under the iothread object. All threads share the same AioContext so they can safely run (contend) together.

With AioContext going away, the spawns will natually enable the block multi-queue work.

---

Quoted 7 lines

Based on v2 of Paolo's RFifoLock removal series, with which the symmetric contention on the single AioContext is no longer a busy preempt loop.

---
 include/sysemu/iothread.h |  19 ++++--
 iothread.c                | 148 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 125 insertions(+), 42 deletions(-)

I'm not happy with "IOThread" becoming a group of threads. IOThread should stay the way it is. Instead you should add a new object type that simply groups IOThreads for convenient assignment to devices, e.g. IOThreadGroup. Then multiqueue devices can use an IOThreadGroup to work inside multiple IOThreads.

Quoted 28 lines
iothread.c +11 -6
@@ -161,22 +225,32 @@ static int query_one_iothread(Object *object, void *opaque)
     IOThreadInfoList *elem;
     IOThreadInfo *info;
     IOThread *iothread;
+    char *id;
+    int i;
 
     iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD);
     if (!iothread) {
         return 0;
     }
 
-    info = g_new0(IOThreadInfo, 1);
-    info->id = iothread_get_id(iothread);
-    info->thread_id = iothread->thread_id;
+    id = iothread_get_id(iothread);
+    for (i = 0; i < iothread->nspawns; ++i) {
+        info = g_new0(IOThreadInfo, 1);
+        info->thread_id = iothread->spawns[i].thread_id;
+        if (iothread->nspawns > 1) {
+            info->id = g_strdup_printf("%s[%d]", id, i);
+        } else {
+            info->id = g_strdup(id);
+        }
 
-    elem = g_new0(IOThreadInfoList, 1);
-    elem->value = info;
-    elem->next = NULL;

iothread.c static int query_one_iothread(Object *object, void *opaque) · line 253

Quoted 10 lines
iothread.c +7 -2
+        elem = g_new0(IOThreadInfoList, 1);
+        elem->value = info;
+        elem->next = NULL;
 
-    **prev = elem;
-    *prev = &elem->next;
+        **prev = elem;
+        *prev = &elem->next;
+    }
+    g_free(id);

^-- yikes, now we're pretending to the QMP client that there are multiple IOThread objects but internally we only have one. Let's not go down that road.

#2 lore raw
Quoted 20 lines · Stefan Hajnoczi
Quoted 11 lines · Fam Zheng

The option specifies how many threads to spawn under the iothread object. All threads share the same AioContext so they can safely run (contend) together.

With AioContext going away, the spawns will natually enable the block multi-queue work.

---

Quoted 7 lines

Based on v2 of Paolo's RFifoLock removal series, with which the symmetric contention on the single AioContext is no longer a busy preempt loop.

---
 include/sysemu/iothread.h |  19 ++++--
 iothread.c                | 148 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 125 insertions(+), 42 deletions(-)
Quoted 5 lines

I'm not happy with "IOThread" becoming a group of threads. IOThread should stay the way it is. Instead you should add a new object type that simply groups IOThreads for convenient assignment to devices, e.g. IOThreadGroup. Then multiqueue devices can use an IOThreadGroup to work inside multiple IOThreads.

Do we even need a IOThreadGroup object ? Can't we just explicitly pass a list of IOThread object IDs to the device. eg something like

-device virtio-blk-pci,iothread=t1,iothread=t2,iothread=t3

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
author
#3 lore raw
Quoted 27 lines · Daniel P. Berrange
Quoted 20 lines · Stefan Hajnoczi
Quoted 11 lines · Fam Zheng

The option specifies how many threads to spawn under the iothread object. All threads share the same AioContext so they can safely run (contend) together.

With AioContext going away, the spawns will natually enable the block multi-queue work.

---

Quoted 7 lines

Based on v2 of Paolo's RFifoLock removal series, with which the symmetric contention on the single AioContext is no longer a busy preempt loop.

---
 include/sysemu/iothread.h |  19 ++++--
 iothread.c                | 148 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 125 insertions(+), 42 deletions(-)
Quoted 5 lines

I'm not happy with "IOThread" becoming a group of threads. IOThread should stay the way it is. Instead you should add a new object type that simply groups IOThreads for convenient assignment to devices, e.g. IOThreadGroup. Then multiqueue devices can use an IOThreadGroup to work inside multiple IOThreads.

Quoted 4 lines

Do we even need a IOThreadGroup object ? Can't we just explicitly pass a list of IOThread object IDs to the device. eg something like

-device virtio-blk-pci,iothread=t1,iothread=t2,iothread=t3

Is that a supported syntax by qdev/QOM?

Fam

#4 lore raw
Quoted 6 lines · Fam Zheng
Quoted 4 lines

Do we even need a IOThreadGroup object ? Can't we just explicitly pass a list of IOThread object IDs to the device. eg something like

-device virtio-blk-pci,iothread=t1,iothread=t2,iothread=t3

Is that a supported syntax by qdev/QOM?

With all the qdict_crumple conversation going on, we definitely want SOME sort of list syntax. The CLI currently allows repetitive specification of a key to create a list, although we may change the syntax to iothread.0=t1,iothread.1=t2,iothread.2=t3 to explicitly call out that we are passing a list.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org