mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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
This commit is contained in:
parent
917426c8d7
commit
0b4b58690d
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user