[PATCH 2/3] conf: decrease iterations complexity when formatting iothreads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d5d9ff7..d7f0291 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21808,19 +21808,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;
 }

-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]