]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: decrease iterations complexity when formatting iothreads
authorPeter Krempa <pkrempa@redhat.com>
Mon, 21 Mar 2016 16:04:35 +0000 (17:04 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 29 Mar 2016 19:26:06 +0000 (21:26 +0200)
Create a bitmap of iothreads that have scheduler info set so that the
transformation algorithm does not have to iterate the empty bitmap many
times. By reusing self-expanding bitmaps the bitmap size does not need
to be pre-calculated.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1264008

src/conf/domain_conf.c

index 35c23948f66c28c07ebd8d1ae7f29e47898b50f3..580809121b2c603373aa1da9d652c4de74e7e544 100644 (file)
@@ -21964,19 +21964,32 @@ static int
 virDomainFormatIOThreadSchedDef(virDomainDefPtr def,
                                 virBufferPtr buf)
 {
-    virBitmapPtr allthreadmap;
-    int ret;
+    virBitmapPtr threadmap;
+    size_t i;
+    int ret = -1;
 
     if (def->niothreadids == 0)
         return 0;
 
-    if (!(allthreadmap = virDomainIOThreadIDMap(def)))
+    if (!(threadmap = virBitmapNewEmpty()))
         return -1;
 
+    for (i = 0; i < def->niothreadids; i++) {
+        if (def->iothreadids[i]->sched.policy != VIR_PROC_POLICY_NONE &&
+            virBitmapSetBitExpand(threadmap, def->iothreadids[i]->iothread_id) < 0)
+            goto cleanup;
+    }
+
+    if (virBitmapIsAllClear(threadmap)) {
+        ret = 0;
+        goto cleanup;
+    }
+
     ret = virDomainFormatSchedDef(def, buf, "iothreads",
-                                  virDomainDefGetIOThreadSched, allthreadmap);
+                                  virDomainDefGetIOThreadSched, threadmap);
 
-    virBitmapFree(allthreadmap);
+ cleanup:
+    virBitmapFree(threadmap);
     return ret;
 }