提交 0b4b5869 编写于 作者: P Peter Krempa

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
上级 917426c8
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册