[libvirt] [PATCH 0/3] qemu: support -overcommit cpu-pm=on|off

QEMU introduced a CPU power management feature with commit 6f131f13e68d ("kvm: support -overcommit cpu-pm=on|off"). With this flag, kvm allows guest to control host CPU power state. This increases latency for other processes using same host CPU in an unpredictable way, but if decreases idle entry/exit times for the running VCPU, so to use it QEMU needs a hint about whether host CPU is overcommitted, hence the flag name. This patch series adds a new kvm feature 'cpu-pm' for controlling "-overcommit cpu-pm=[on|off]" <features> <kvm> <cpu-pm state='on'/> </kvm> </features> Menno Lageman (2): qemu: introduce qemuBuildOvercommitCommandLine() tests: add tests for cpu-pm feature Wim ten Have (1): qemu: add hypervisor feature cpu-pm support for kvm docs/formatdomain.html.in | 7 ++++ docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 4 ++ src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 39 +++++++++++++++++-- src/qemu/qemu_domain.c | 25 ++++++++---- tests/qemuxml2argvdata/kvm-features-off.args | 2 +- tests/qemuxml2argvdata/kvm-features-off.xml | 1 + tests/qemuxml2argvdata/kvm-features.args | 2 +- tests/qemuxml2argvdata/kvm-features.xml | 1 + tests/qemuxml2argvtest.c | 4 +- tests/qemuxml2xmloutdata/kvm-features-off.xml | 1 + tests/qemuxml2xmloutdata/kvm-features.xml | 1 + 14 files changed, 79 insertions(+), 15 deletions(-) -- 2.21.0

In preparation for adding support for '-overcommit cpu-pm=[on|off]', add qemuBuildOvercommitCommandLine() to generate the '-overcommit' commandline. Move the existing '-overcommit mem-lock=[on|off]' generation code from qemuBuildMemCommandline() to this function. Signed-off-by: Menno Lageman <menno.lageman@oracle.com> --- src/qemu/qemu_command.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f096e8f27e58..922456ec679e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7832,10 +7832,11 @@ qemuBuildMemCommandLine(virCommandPtr cmd, qemuBuildMemPathStr(cfg, def, cmd, priv) < 0) return -1; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) { - virCommandAddArg(cmd, "-overcommit"); - virCommandAddArgFormat(cmd, "mem-lock=%s", def->mem.locked ? "on" : "off"); - } else { + /* + * '-overcommit mem-lock=on|off' is handled with other + * overcommit options later on. + */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) { virCommandAddArg(cmd, "-realtime"); virCommandAddArgFormat(cmd, "mlock=%s", def->mem.locked ? "on" : "off"); @@ -7845,6 +7846,19 @@ qemuBuildMemCommandLine(virCommandPtr cmd, } +static int +qemuBuildOvercommitCommandLine(virCommandPtr cmd, + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) { + virCommandAddArg(cmd, "-overcommit"); + virCommandAddArgFormat(cmd, "mem-lock=%s", def->mem.locked ? "on" : "off"); + } + return 0; +} + + static int qemuBuildIOThreadCommandLine(virCommandPtr cmd, const virDomainDef *def) @@ -10657,6 +10671,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildMemCommandLine(cmd, cfg, def, qemuCaps, priv) < 0) goto error; + if (qemuBuildOvercommitCommandLine(cmd, def, qemuCaps) < 0) + goto error; + if (qemuBuildSmpCommandLine(cmd, def) < 0) goto error; -- 2.21.0

On Mon, Aug 19, 2019 at 10:32:24AM +0200, Menno Lageman wrote:
In preparation for adding support for '-overcommit cpu-pm=[on|off]', add qemuBuildOvercommitCommandLine() to generate the '-overcommit' commandline. Move the existing '-overcommit mem-lock=[on|off]' generation code from qemuBuildMemCommandline() to this function.
I guess we could proclaim that -realtime mlock= also deals with overcommit and separate it into the same function, especially since the rest of the MemCommandLine does not depend on it (and we would touch def->mem.locked in the new Overcommit function anyway). Jano
Signed-off-by: Menno Lageman <menno.lageman@oracle.com> --- src/qemu/qemu_command.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)

From: Wim ten Have <wim.ten.have@oracle.com> QEMU introduced a CPU power management feature with commit 6f131f13e68d ("kvm: support -overcommit cpu-pm=on|off"). This patch series adds support for controlling QEMU's "-overcommit" command line switch: "-overcommit cpu-pm=[on|off]". By default "cpu-pm" is off. To turn the CPU power management feature on, the following XML needs to be added to the guest's domain description: <features> <kvm> <cpu-pm state='on'/> </kvm> </features> Note that the "cpu-pm" element is only available if the CPU mode is set to "host-passthrough": <cpu mode='host-passthrough ... /> Signed-off-by: Wim ten Have <wim.ten.have@oracle.com> Signed-off-by: Menno Lageman <menno.lageman@oracle.com> --- docs/formatdomain.html.in | 7 +++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 4 ++++ src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 16 +++++++++++++++- src/qemu/qemu_domain.c | 25 ++++++++++++++++++------- 7 files changed, 51 insertions(+), 8 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index a18119f9a08e..7ea819ef6fb2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2045,6 +2045,7 @@ <kvm> <hidden state='on'/> <hint-dedicated state='on'/> + <cpu-pm state='on'/> </kvm> <pvspinlock state='on'/> <gic version='2'/> @@ -2224,6 +2225,12 @@ <td>on, off</td> <td><span class="since">5.7.0 (QEMU 2.12.1)</span></td> </tr> + <tr> + <td>cpu-pm</td> + <td>Enable guest management of the host CPU's power state. Note that enabling this will increase latency for other processes running on the same host CPU.</td> + <td>on, off</td> + <td><span class="since">5.7.0 (QEMU 2.12.1)</span></td> + </tr> </table> </dd> <dt><code>pmu</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 08853f9d9e92..51c9e434aa35 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5970,6 +5970,11 @@ <ref name="featurestate"/> </element> </optional> + <optional> + <element name="cpu-pm"> + <ref name="featurestate"/> + </element> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8642927d6bf3..e348aa0bcb5f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -203,6 +203,7 @@ VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST, "hidden", "hint-dedicated", + "cpu-pm", ); VIR_ENUM_IMPL(virDomainMsrsUnknown, @@ -20412,6 +20413,7 @@ virDomainDefParseXML(xmlDocPtr xml, switch ((virDomainKVM) feature) { case VIR_DOMAIN_KVM_HIDDEN: case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: if (!(tmp = virXMLPropString(nodes[i], "state"))) { virReportError(VIR_ERR_XML_ERROR, _("missing 'state' attribute for " @@ -22625,6 +22627,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, switch ((virDomainKVM) i) { case VIR_DOMAIN_KVM_HIDDEN: case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: if (src->kvm_features[i] != dst->kvm_features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of KVM feature '%s' differs: " @@ -28126,6 +28129,7 @@ virDomainDefFormatFeatures(virBufferPtr buf, switch ((virDomainKVM) j) { case VIR_DOMAIN_KVM_HIDDEN: case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: if (def->kvm_features[j]) virBufferAsprintf(&childBuf, "<%s state='%s'/>\n", virDomainKVMTypeToString(j), diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f7423b1b6f89..b5a4cee46c1e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1766,6 +1766,7 @@ typedef enum { typedef enum { VIR_DOMAIN_KVM_HIDDEN = 0, VIR_DOMAIN_KVM_DEDICATED, + VIR_DOMAIN_KVM_CPU_PM, VIR_DOMAIN_KVM_LAST } virDomainKVM; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9db4ac7933e5..67a3a14c9b36 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -446,6 +446,7 @@ virDomainIOThreadIDDel; virDomainIOThreadIDFind; virDomainKeyWrapCipherNameTypeFromString; virDomainKeyWrapCipherNameTypeToString; +virDomainKVMTypeToString; virDomainLeaseDefFree; virDomainLeaseIndex; virDomainLeaseInsert; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 922456ec679e..163c98bc7d0f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7217,6 +7217,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virBufferAddLit(&buf, ",kvm-hint-dedicated=on"); break; + /* Not a -cpu option */ + case VIR_DOMAIN_KVM_CPU_PM: /* coverity[dead_error_begin] */ case VIR_DOMAIN_KVM_LAST: break; @@ -7852,8 +7854,20 @@ qemuBuildOvercommitCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) { + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *overcommit; + + virBufferAsprintf(&buf, "mem-lock=%s", def->mem.locked ? "on" : "off"); + + if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) + virBufferAsprintf(&buf, ",cpu-pm=%s", + def->kvm_features[VIR_DOMAIN_KVM_CPU_PM] == VIR_TRISTATE_SWITCH_ON ? "on" : "off"); + + overcommit = virBufferContentAndReset(&buf); virCommandAddArg(cmd, "-overcommit"); - virCommandAddArgFormat(cmd, "mem-lock=%s", def->mem.locked ? "on" : "off"); + virCommandAddArgFormat(cmd, "%s", overcommit); + + VIR_FREE(overcommit); } return 0; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a06672333cf7..5571f52fec47 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4442,7 +4442,7 @@ static int qemuDomainDefValidateFeatures(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { - size_t i; + size_t i, j; for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) { const char *featureName = virDomainFeatureTypeToString(i); @@ -4499,12 +4499,23 @@ qemuDomainDefValidateFeatures(const virDomainDef *def, break; case VIR_DOMAIN_FEATURE_KVM: - if (def->kvm_features[VIR_DOMAIN_KVM_DEDICATED] == VIR_TRISTATE_SWITCH_ON && - (!def->cpu || def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("kvm-hint-dedicated=on is only applicable " - "for cpu host-passthrough")); - return -1; + for (j = 0; j < VIR_DOMAIN_KVM_LAST; j++) { + switch ((virDomainKVM) j) { + case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: + if (def->kvm_features[j] == VIR_TRISTATE_SWITCH_ON && + (!def->cpu || def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%s=on is only applicable for cpu host-passthrough"), + virDomainKVMTypeToString(j)); + return -1; + } + break; + + case VIR_DOMAIN_KVM_HIDDEN: + case VIR_DOMAIN_KVM_LAST: + break; + } } break; -- 2.21.0

On Mon, Aug 19, 2019 at 10:32:25AM +0200, Menno Lageman wrote:
From: Wim ten Have <wim.ten.have@oracle.com>
QEMU introduced a CPU power management feature with commit 6f131f13e68d ("kvm: support -overcommit cpu-pm=on|off").
This patch series adds support for controlling QEMU's "-overcommit" command line switch: "-overcommit cpu-pm=[on|off]". By default "cpu-pm" is off.
To turn the CPU power management feature on, the following XML needs to be added to the guest's domain description:
<features> <kvm> <cpu-pm state='on'/> </kvm> </features>
Note that the "cpu-pm" element is only available if the CPU mode is set to "host-passthrough":
<cpu mode='host-passthrough ... />
Signed-off-by: Wim ten Have <wim.ten.have@oracle.com> Signed-off-by: Menno Lageman <menno.lageman@oracle.com> --- docs/formatdomain.html.in | 7 +++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 4 ++++ src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 16 +++++++++++++++- src/qemu/qemu_domain.c | 25 ++++++++++++++++++------- 7 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index a18119f9a08e..7ea819ef6fb2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2045,6 +2045,7 @@ <kvm> <hidden state='on'/> <hint-dedicated state='on'/> + <cpu-pm state='on'/> </kvm> <pvspinlock state='on'/> <gic version='2'/> @@ -2224,6 +2225,12 @@ <td>on, off</td> <td><span class="since">5.7.0 (QEMU 2.12.1)</span></td> </tr>
Hmm, seems we did not bother to document hint-dedicated
+ <tr> + <td>cpu-pm</td> + <td>Enable guest management of the host CPU's power state. Note that enabling this will increase latency for other processes running on the same host CPU.</td> + <td>on, off</td> + <td><span class="since">5.7.0 (QEMU 2.12.1)</span></td> + </tr> </table> </dd> <dt><code>pmu</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 08853f9d9e92..51c9e434aa35 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5970,6 +5970,11 @@ <ref name="featurestate"/> </element> </optional> + <optional> + <element name="cpu-pm"> + <ref name="featurestate"/> + </element> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8642927d6bf3..e348aa0bcb5f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -203,6 +203,7 @@ VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST, "hidden", "hint-dedicated", + "cpu-pm", );
VIR_ENUM_IMPL(virDomainMsrsUnknown, @@ -20412,6 +20413,7 @@ virDomainDefParseXML(xmlDocPtr xml, switch ((virDomainKVM) feature) { case VIR_DOMAIN_KVM_HIDDEN: case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: if (!(tmp = virXMLPropString(nodes[i], "state"))) { virReportError(VIR_ERR_XML_ERROR, _("missing 'state' attribute for " @@ -22625,6 +22627,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, switch ((virDomainKVM) i) { case VIR_DOMAIN_KVM_HIDDEN: case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: if (src->kvm_features[i] != dst->kvm_features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of KVM feature '%s' differs: " @@ -28126,6 +28129,7 @@ virDomainDefFormatFeatures(virBufferPtr buf, switch ((virDomainKVM) j) { case VIR_DOMAIN_KVM_HIDDEN: case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: if (def->kvm_features[j]) virBufferAsprintf(&childBuf, "<%s state='%s'/>\n", virDomainKVMTypeToString(j), diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f7423b1b6f89..b5a4cee46c1e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1766,6 +1766,7 @@ typedef enum { typedef enum { VIR_DOMAIN_KVM_HIDDEN = 0, VIR_DOMAIN_KVM_DEDICATED, + VIR_DOMAIN_KVM_CPU_PM,
VIR_DOMAIN_KVM_LAST } virDomainKVM; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9db4ac7933e5..67a3a14c9b36 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -446,6 +446,7 @@ virDomainIOThreadIDDel; virDomainIOThreadIDFind; virDomainKeyWrapCipherNameTypeFromString; virDomainKeyWrapCipherNameTypeToString; +virDomainKVMTypeToString; virDomainLeaseDefFree; virDomainLeaseIndex; virDomainLeaseInsert; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 922456ec679e..163c98bc7d0f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7217,6 +7217,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virBufferAddLit(&buf, ",kvm-hint-dedicated=on"); break;
+ /* Not a -cpu option */ + case VIR_DOMAIN_KVM_CPU_PM: /* coverity[dead_error_begin] */ case VIR_DOMAIN_KVM_LAST: break; @@ -7852,8 +7854,20 @@ qemuBuildOvercommitCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) { + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *overcommit; + + virBufferAsprintf(&buf, "mem-lock=%s", def->mem.locked ? "on" : "off"); + + if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) + virBufferAsprintf(&buf, ",cpu-pm=%s", + def->kvm_features[VIR_DOMAIN_KVM_CPU_PM] == VIR_TRISTATE_SWITCH_ON ? "on" : "off");
const char *cpu_pm = NULL; if (def->kvm_features[VIR_DOMAIN_KVM_CPU_PM] != VIR_TRISTATE_SWITCH_DEFAULT) cpu_pm = virTristateBoolTypeToString(def->kvm_features[VIR_DOMAIN_KVM_CPU_PM]) if (cpu_pm) virBufferAsprintf... to avoid the super long line.
+ + overcommit = virBufferContentAndReset(&buf); virCommandAddArg(cmd, "-overcommit"); - virCommandAddArgFormat(cmd, "mem-lock=%s", def->mem.locked ? "on" : "off"); + virCommandAddArgFormat(cmd, "%s", overcommit);
You can use virCommandAddArgBuffer and avoid the temporary char* variable
+ + VIR_FREE(overcommit); } return 0; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a06672333cf7..5571f52fec47 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4442,7 +4442,7 @@ static int qemuDomainDefValidateFeatures(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { - size_t i; + size_t i, j;
for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) { const char *featureName = virDomainFeatureTypeToString(i); @@ -4499,12 +4499,23 @@ qemuDomainDefValidateFeatures(const virDomainDef *def, break;
case VIR_DOMAIN_FEATURE_KVM: - if (def->kvm_features[VIR_DOMAIN_KVM_DEDICATED] == VIR_TRISTATE_SWITCH_ON && - (!def->cpu || def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("kvm-hint-dedicated=on is only applicable " - "for cpu host-passthrough")); - return -1; + for (j = 0; j < VIR_DOMAIN_KVM_LAST; j++) { + switch ((virDomainKVM) j) { + case VIR_DOMAIN_KVM_DEDICATED: + case VIR_DOMAIN_KVM_CPU_PM: + if (def->kvm_features[j] == VIR_TRISTATE_SWITCH_ON && + (!def->cpu || def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%s=on is only applicable for cpu host-passthrough"), + virDomainKVMTypeToString(j)); + return -1; + }
What if the user asks for cpu-pm but QEMU_CAPS_OVERCOMMIT is not available? Jano
+ break; + + case VIR_DOMAIN_KVM_HIDDEN: + case VIR_DOMAIN_KVM_LAST: + break; + } } break;
-- 2.21.0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Update the KVM feature tests for the cpu-pm feature Signed-off-by: Menno Lageman <menno.lageman@oracle.com> --- tests/qemuxml2argvdata/kvm-features-off.args | 2 +- tests/qemuxml2argvdata/kvm-features-off.xml | 1 + tests/qemuxml2argvdata/kvm-features.args | 2 +- tests/qemuxml2argvdata/kvm-features.xml | 1 + tests/qemuxml2argvtest.c | 4 ++-- tests/qemuxml2xmloutdata/kvm-features-off.xml | 1 + tests/qemuxml2xmloutdata/kvm-features.xml | 1 + 7 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/qemuxml2argvdata/kvm-features-off.args b/tests/qemuxml2argvdata/kvm-features-off.args index 59a79376d140..5150f93986a7 100644 --- a/tests/qemuxml2argvdata/kvm-features-off.args +++ b/tests/qemuxml2argvdata/kvm-features-off.args @@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \ -S \ -machine pc,accel=tcg,usb=off,dump-guest-core=off \ -m 214 \ --realtime mlock=off \ +-overcommit mem-lock=off,cpu-pm=off \ -smp 6,sockets=6,cores=1,threads=1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/kvm-features-off.xml b/tests/qemuxml2argvdata/kvm-features-off.xml index ab2c16202c3d..81970472d2f3 100644 --- a/tests/qemuxml2argvdata/kvm-features-off.xml +++ b/tests/qemuxml2argvdata/kvm-features-off.xml @@ -13,6 +13,7 @@ <kvm> <hidden state='off'/> <hint-dedicated state='off'/> + <cpu-pm state='off'/> </kvm> </features> <clock offset='utc'/> diff --git a/tests/qemuxml2argvdata/kvm-features.args b/tests/qemuxml2argvdata/kvm-features.args index 8372ca897d8d..315e4cae853c 100644 --- a/tests/qemuxml2argvdata/kvm-features.args +++ b/tests/qemuxml2argvdata/kvm-features.args @@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \ -machine pc,accel=kvm,usb=off,dump-guest-core=off \ -cpu host,kvm=off,kvm-hint-dedicated=on \ -m 214 \ --realtime mlock=off \ +-overcommit mem-lock=off,cpu-pm=on \ -smp 6,sockets=6,cores=1,threads=1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/kvm-features.xml b/tests/qemuxml2argvdata/kvm-features.xml index b942e89a9280..fd12a80a574f 100644 --- a/tests/qemuxml2argvdata/kvm-features.xml +++ b/tests/qemuxml2argvdata/kvm-features.xml @@ -13,6 +13,7 @@ <kvm> <hidden state='on'/> <hint-dedicated state='on'/> + <cpu-pm state='on'/> </kvm> </features> <cpu mode='host-passthrough' check='none'/> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 26b512d24606..4c048b3e768a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -915,8 +915,8 @@ mymain(void) DO_TEST("hyperv-off", NONE); DO_TEST("hyperv-panic", NONE); - DO_TEST("kvm-features", NONE); - DO_TEST("kvm-features-off", NONE); + DO_TEST("kvm-features", QEMU_CAPS_OVERCOMMIT); + DO_TEST("kvm-features-off", QEMU_CAPS_OVERCOMMIT); DO_TEST("pmu-feature", NONE); DO_TEST("pmu-feature-off", NONE); diff --git a/tests/qemuxml2xmloutdata/kvm-features-off.xml b/tests/qemuxml2xmloutdata/kvm-features-off.xml index a0ef9c7e9e15..31d9b586b3f8 100644 --- a/tests/qemuxml2xmloutdata/kvm-features-off.xml +++ b/tests/qemuxml2xmloutdata/kvm-features-off.xml @@ -13,6 +13,7 @@ <kvm> <hidden state='off'/> <hint-dedicated state='off'/> + <cpu-pm state='off'/> </kvm> </features> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/kvm-features.xml b/tests/qemuxml2xmloutdata/kvm-features.xml index b6f16ced1dab..7ceaf15ecf1e 100644 --- a/tests/qemuxml2xmloutdata/kvm-features.xml +++ b/tests/qemuxml2xmloutdata/kvm-features.xml @@ -13,6 +13,7 @@ <kvm> <hidden state='on'/> <hint-dedicated state='on'/> + <cpu-pm state='on'/> </kvm> </features> <cpu mode='host-passthrough' check='none'/> -- 2.21.0

On Mon, Aug 19, 2019 at 10:32:23AM +0200, Menno Lageman wrote:
QEMU introduced a CPU power management feature with commit 6f131f13e68d ("kvm: support -overcommit cpu-pm=on|off").
With this flag, kvm allows guest to control host CPU power state. This increases latency for other processes using same host CPU in an unpredictable way, but if decreases idle entry/exit times for the running VCPU, so to use it QEMU needs a hint about whether host CPU is overcommitted, hence the flag name.
This patch series adds a new kvm feature 'cpu-pm' for controlling "-overcommit cpu-pm=[on|off]"
<features> <kvm> <cpu-pm state='on'/> </kvm> </features>
Unless I'm missing it, there was never a followup v2 for this series ? Did you ever do more work on this, as this is still a useful feature to support for KVM to maximize performance AFAIK. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 26-03-2020 17:04, Daniel P. Berrangé wrote:
On Mon, Aug 19, 2019 at 10:32:23AM +0200, Menno Lageman wrote:
QEMU introduced a CPU power management feature with commit 6f131f13e68d ("kvm: support -overcommit cpu-pm=on|off").
With this flag, kvm allows guest to control host CPU power state. This increases latency for other processes using same host CPU in an unpredictable way, but if decreases idle entry/exit times for the running VCPU, so to use it QEMU needs a hint about whether host CPU is overcommitted, hence the flag name.
This patch series adds a new kvm feature 'cpu-pm' for controlling "-overcommit cpu-pm=[on|off]"
<features> <kvm> <cpu-pm state='on'/> </kvm> </features>
Unless I'm missing it, there was never a followup v2 for this series ? Did you ever do more work on this, as this is still a useful feature to support for KVM to maximize performance AFAIK.
It's on my TODO list but other things got ahead in the queue. Menno
participants (3)
-
Daniel P. Berrangé
-
Ján Tomko
-
Menno Lageman