[PATCH 0/2] qemuDomainPinIOThread: Update live definition after process pinning

see 2/2 Peter Krempa (2): qemuDomainPinIOThread: Copy the cpu bitmap instead of re-parsing it qemuDomainPinIOThread: Update live definition after process pinning src/qemu/qemu_driver.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) -- 2.34.1

The bitmap recorded in the live/persistent definition was re-parsed two more times. We can copy it which is cheaper and less verbose. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e150b86cef..077547e1d3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5011,7 +5011,6 @@ qemuDomainPinIOThread(virDomainPtr dom, if (def) { virDomainIOThreadIDDef *iothrid; - virBitmap *cpumask; if (!(iothrid = virDomainIOThreadIDFind(def, iothread_id))) { virReportError(VIR_ERR_INVALID_ARG, @@ -5019,11 +5018,8 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; } - if (!(cpumask = virBitmapNewData(cpumap, maplen))) - goto endjob; - virBitmapFree(iothrid->cpumask); - iothrid->cpumask = cpumask; + iothrid->cpumask = virBitmapNewCopy(pcpumap); iothrid->autofill = false; /* Configure the corresponding cpuset cgroup before set affinity. */ @@ -5060,7 +5056,6 @@ qemuDomainPinIOThread(virDomainPtr dom, if (persistentDef) { virDomainIOThreadIDDef *iothrid; - virBitmap *cpumask; if (!(iothrid = virDomainIOThreadIDFind(persistentDef, iothread_id))) { virReportError(VIR_ERR_INVALID_ARG, @@ -5068,11 +5063,8 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; } - if (!(cpumask = virBitmapNewData(cpumap, maplen))) - goto endjob; - virBitmapFree(iothrid->cpumask); - iothrid->cpumask = cpumask; + iothrid->cpumask = virBitmapNewCopy(pcpumap); iothrid->autofill = false; ret = virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir); -- 2.34.1

Otherwise we'll keep using the new pinning value even if it can't be applied to the thread. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2040555 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 077547e1d3..3c0c81a6b9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5018,10 +5018,6 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; } - virBitmapFree(iothrid->cpumask); - iothrid->cpumask = virBitmapNewCopy(pcpumap); - iothrid->autofill = false; - /* Configure the corresponding cpuset cgroup before set affinity. */ if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { @@ -5039,6 +5035,10 @@ qemuDomainPinIOThread(virDomainPtr dom, if (virProcessSetAffinity(iothrid->thread_id, pcpumap, false) < 0) goto endjob; + virBitmapFree(iothrid->cpumask); + iothrid->cpumask = virBitmapNewCopy(pcpumap); + iothrid->autofill = false; + qemuDomainSaveStatus(vm); if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, -- 2.34.1

On a Tuesday in 2022, Peter Krempa wrote:
see 2/2
Peter Krempa (2): qemuDomainPinIOThread: Copy the cpu bitmap instead of re-parsing it qemuDomainPinIOThread: Update live definition after process pinning
src/qemu/qemu_driver.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On Tue, Jan 18, 2022 at 10:31:44AM +0100, Peter Krempa wrote:
see 2/2
Peter Krempa (2): qemuDomainPinIOThread: Copy the cpu bitmap instead of re-parsing it qemuDomainPinIOThread: Update live definition after process pinning
src/qemu/qemu_driver.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
participants (3)
-
Ján Tomko
-
Pavel Hrdina
-
Peter Krempa