]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: support kvm-poll-control performance hint
authorTim Wiederhake <twiederh@redhat.com>
Fri, 13 Nov 2020 08:49:43 +0000 (09:49 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Nov 2020 13:40:46 +0000 (14:40 +0100)
QEMU version 4.2 introduced a performance feature under commit
d645e13287 ("kvm: i386: halt poll control MSR support").

This patch adds a new KVM feature 'poll-control' to set this performance
hint for KVM guests. The feature is off by default.

To enable this hint and have libvirt add "-cpu host,kvm-poll-control=on"
to the QEMU command line, the following XML code needs to be added to the
guest's domain description:

  <features>
    <kvm>
      <poll-control state='on'/>
    </kvm>
  </features>

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.rst
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c

index a6ab845f92c87ea29c474c789af098cc62b5ea29..c2c23371b138844fc37982a5a59add840af7bd10 100644 (file)
@@ -1766,6 +1766,7 @@ Hypervisors may allow certain CPU / machine features to be toggled on/off.
      <kvm>
        <hidden state='on'/>
        <hint-dedicated state='on'/>
+       <poll-control='on'/>
      </kvm>
      <xen>
        <e820_host state='on'/>
@@ -1848,12 +1849,13 @@ are:
 ``kvm``
    Various features to change the behavior of the KVM hypervisor.
 
-   ============== ====================================================================== ======= ============================
-   Feature        Description                                                            Value   Since
-   ============== ====================================================================== ======= ============================
-   hidden         Hide the KVM hypervisor from standard MSR based discovery              on, off :since:`1.2.8 (QEMU 2.1.0)`
-   hint-dedicated Allows a guest to enable optimizations when running on dedicated vCPUs on, off :since:`5.7.0 (QEMU 2.12.0)`
-   ============== ====================================================================== ======= ============================
+   ============== ============================================================================ ======= ============================
+   Feature        Description                                                                  Value   Since
+   ============== ============================================================================ ======= ============================
+   hidden         Hide the KVM hypervisor from standard MSR based discovery                    on, off :since:`1.2.8 (QEMU 2.1.0)`
+   hint-dedicated Allows a guest to enable optimizations when running on dedicated vCPUs       on, off :since:`5.7.0 (QEMU 2.12.0)`
+   poll-control   Decrease IO completion latency by introducing a grace period of busy waiting on, off :since:`6.10.0 (QEMU 4.2)`
+   ============== ============================================================================ ======= ============================
 
 ``xen``
    Various features to change the behavior of the Xen hypervisor.
index e0d09f9c0345db1f1166ea060c0455d299f3dd68..f86a8548636784e0536b0746c31e57f99e5bda3a 100644 (file)
             <ref name="featurestate"/>
           </element>
         </optional>
+        <optional>
+          <element name="poll-control">
+            <ref name="featurestate"/>
+          </element>
+        </optional>
       </interleave>
     </element>
   </define>
index bf97e0505d17faa7dbc74e200eb8ac01f4b9f102..498a8b6ef08a2b6f1a2aeecc6d55e87b4cd5f604 100644 (file)
@@ -208,6 +208,7 @@ VIR_ENUM_IMPL(virDomainKVM,
               VIR_DOMAIN_KVM_LAST,
               "hidden",
               "hint-dedicated",
+              "poll-control",
 );
 
 VIR_ENUM_IMPL(virDomainXen,
@@ -19823,6 +19824,7 @@ virDomainFeaturesDefParse(virDomainDefPtr def,
             switch ((virDomainKVM) feature) {
                 case VIR_DOMAIN_KVM_HIDDEN:
                 case VIR_DOMAIN_KVM_DEDICATED:
+                case VIR_DOMAIN_KVM_POLLCONTROL:
                     if (!(tmp = virXMLPropString(nodes[i], "state"))) {
                         virReportError(VIR_ERR_XML_ERROR,
                                        _("missing 'state' attribute for "
@@ -23982,6 +23984,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
             switch ((virDomainKVM) i) {
             case VIR_DOMAIN_KVM_HIDDEN:
             case VIR_DOMAIN_KVM_DEDICATED:
+            case VIR_DOMAIN_KVM_POLLCONTROL:
                 if (src->kvm_features[i] != dst->kvm_features[i]) {
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                    _("State of KVM feature '%s' differs: "
@@ -29691,6 +29694,7 @@ virDomainDefFormatFeatures(virBufferPtr buf,
                 switch ((virDomainKVM) j) {
                 case VIR_DOMAIN_KVM_HIDDEN:
                 case VIR_DOMAIN_KVM_DEDICATED:
+                case VIR_DOMAIN_KVM_POLLCONTROL:
                     if (def->kvm_features[j])
                         virBufferAsprintf(&childBuf, "<%s state='%s'/>\n",
                                           virDomainKVMTypeToString(j),
index 16c050a3eaedf3ec83dd203291b775558e93744e..3e3d4bd0023549d66a8c0c27eb95df49c8cd2d75 100644 (file)
@@ -1912,6 +1912,7 @@ typedef enum {
 typedef enum {
     VIR_DOMAIN_KVM_HIDDEN = 0,
     VIR_DOMAIN_KVM_DEDICATED,
+    VIR_DOMAIN_KVM_POLLCONTROL,
 
     VIR_DOMAIN_KVM_LAST
 } virDomainKVM;
index 0eec35da1608baa5eb9748620eeeaab46d2b2fc4..34b5746c1a3683c856af41e8f8c735138e76d359 100644 (file)
@@ -6464,6 +6464,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
                     virBufferAddLit(&buf, ",kvm-hint-dedicated=on");
                 break;
 
+            case VIR_DOMAIN_KVM_POLLCONTROL:
+                if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_ON)
+                    virBufferAddLit(&buf, ",kvm-poll-control=on");
+                break;
+
             /* coverity[dead_error_begin] */
             case VIR_DOMAIN_KVM_LAST:
                 break;