From 0b4b58690d61e5b23cca24eec9912791cf4c21a3 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 21 Mar 2016 17:04:35 +0100 Subject: [PATCH] conf: decrease iterations complexity when formatting iothreads 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 | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 35c23948f6..580809121b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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; - ret = virDomainFormatSchedDef(def, buf, "iothreads", - virDomainDefGetIOThreadSched, allthreadmap); + 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; + } - virBitmapFree(allthreadmap); + if (virBitmapIsAllClear(threadmap)) { + ret = 0; + goto cleanup; + } + + ret = virDomainFormatSchedDef(def, buf, "iothreads", + virDomainDefGetIOThreadSched, threadmap); + + cleanup: + virBitmapFree(threadmap); return ret; }