[PATCH 3/3] domain_conf: add SCHED_DEADLINE support in the XML configuration

Sasha Algisi sasha.algisi at edu.unito.it
Mon Aug 1 17:11:46 UTC 2022


Users can set SCHED_DEADLINE as a scheduling policy.

For example, for setting runtime = 10000000, deadline = 15000000
and period = 20000000 for vcpus 0-2:

<cputune>
  ...
  <vcpusched vcpus="0-2" scheduler="deadline" runtime="10000000"
   deadline="15000000" period="20000000"/>
  ...
</cputune>

Update release notes accordingly.

Signed-off-by: Sasha Algisi <sasha.algisi at edu.unito.it>
Signed-off-by: Dario Faggioli <dfaggioli at suse.com>
---
 NEWS.rst                          |  5 +++
 docs/formatdomain.rst             | 16 +++++++---
 src/conf/domain_conf.c            | 52 ++++++++++++++++++++++++++++---
 src/conf/schemas/domaincommon.rng | 16 ++++++++++
 4 files changed, 80 insertions(+), 9 deletions(-)

diff --git a/NEWS.rst b/NEWS.rst
index ef298da539..23484afdc2 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -17,6 +17,11 @@ v8.7.0 (unreleased)
 
 * **New features**
 
+  * qemu: support for SCHED_DEADLINE scheduling
+
+    Users can now use the SCHED_DEADLINE scheduling policy for tasks
+    associated to virtual CPUs, IO Threads and Emulator processes.
+
 * **Improvements**
 
 * **Bug fixes**
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 1ed969ac3e..216262b79d 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -910,10 +910,11 @@ CPU Tuning
    support since 2.1.0`
 ``vcpusched``, ``iothreadsched`` and ``emulatorsched``
    The optional ``vcpusched``, ``iothreadsched`` and ``emulatorsched`` elements
-   specify the scheduler type (values ``batch``, ``idle``, ``fifo``, ``rr``) for
-   particular vCPU, IOThread and emulator threads respectively. For ``vcpusched``
-   and ``iothreadsched`` the attributes ``vcpus`` and ``iothreads`` select which
-   vCPUs/IOThreads this setting applies to, leaving them out sets the default.
+   specify the scheduler type (values ``batch``, ``idle``, ``fifo``, ``rr``,
+   ``deadline`` :since:`Since 8.7.0`) for particular vCPU, IOThread and emulator
+   threads respectively. For ``vcpusched`` and ``iothreadsched`` the attributes
+   ``vcpus`` and ``iothreads`` select which vCPUs/IOThreads this setting applies
+   to, leaving them out sets the default.
    The element ``emulatorsched`` does not have that attribute. Valid ``vcpus``
    values start at 0 through one less than the number of vCPU's defined for the
    domain. Valid ``iothreads`` values are described in the `IOThreads Allocation`_
@@ -923,6 +924,13 @@ CPU Tuning
    priority must be specified as well (and is ignored for non-real-time ones).
    The value range for the priority depends on the host kernel (usually 1-99).
    :since:`Since 1.2.13` ``emulatorsched`` :since:`since 5.3.0`
+   For SCHED_DEADLINE (``deadline``), runtime , deadline and period must also
+   be specified (they are ignored in other schedulers). It must always be true
+   that: runtime <= deadline <= period.
+   The values are specified in nanoseconds. The valid range for the parameters
+   is [1024, 2^63-1] (but a smaller one can be put in place via sysctl). The
+   period can be set to 0, in which case, a period equal to the deadline is
+   used.
 ``cachetune`` :since:`Since 4.1.0`
    Optional ``cachetune`` element can control allocations for CPU caches using
    the resctrl on the host. Whether or not is this supported can be gathered
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e85cc1f809..86ada8f147 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16693,7 +16693,10 @@ virDomainLoaderDefParseXML(virDomainLoaderDef *loader,
 static int
 virDomainSchedulerParseCommonAttrs(xmlNodePtr node,
                                    virProcessSchedPolicy *policy,
-                                   int *priority)
+                                   int *priority,
+                                   uint64_t *runtime,
+                                   uint64_t *deadline,
+                                   uint64_t *period)
 {
     if (virXMLPropEnum(node, "scheduler", virProcessSchedPolicyTypeFromString,
                        VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
@@ -16706,6 +16709,20 @@ virDomainSchedulerParseCommonAttrs(xmlNodePtr node,
             return -1;
     }
 
+    if (*policy == VIR_PROC_POLICY_DEADLINE) {
+        if (virXMLPropULongLong(node, "runtime", 10, VIR_XML_PROP_REQUIRED,
+                                (unsigned long long *) runtime) < 0)
+            return -1;
+
+        if (virXMLPropULongLong(node, "deadline", 10, VIR_XML_PROP_REQUIRED,
+                                (unsigned long long *) deadline) < 0)
+            return -1;
+
+        if (virXMLPropULongLong(node, "period", 10, VIR_XML_PROP_REQUIRED,
+                                (unsigned long long *) period) < 0)
+            return -1;
+    }
+
     return 0;
 }
 
@@ -16720,7 +16737,10 @@ virDomainEmulatorSchedParse(xmlNodePtr node,
 
     if (virDomainSchedulerParseCommonAttrs(node,
                                            &sched->policy,
-                                           &sched->priority) < 0)
+                                           &sched->priority,
+                                           &sched->runtime,
+                                           &sched->deadline,
+                                           &sched->period) < 0)
         return -1;
 
     def->cputune.emulatorsched = g_steal_pointer(&sched);
@@ -16733,7 +16753,10 @@ virDomainSchedulerParse(xmlNodePtr node,
                         const char *elementName,
                         const char *attributeName,
                         virProcessSchedPolicy *policy,
-                        int *priority)
+                        int *priority,
+                        uint64_t *runtime,
+                        uint64_t *deadline,
+                        uint64_t *period)
 {
     g_autoptr(virBitmap) ret = NULL;
     g_autofree char *tmp = NULL;
@@ -16755,7 +16778,8 @@ virDomainSchedulerParse(xmlNodePtr node,
         return NULL;
     }
 
-    if (virDomainSchedulerParseCommonAttrs(node, policy, priority) < 0)
+    if (virDomainSchedulerParseCommonAttrs(node, policy, priority,
+                                           runtime, deadline, period) < 0)
         return NULL;
 
     return g_steal_pointer(&ret);
@@ -16773,10 +16797,14 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
     virDomainThreadSchedParam *sched = NULL;
     virProcessSchedPolicy policy = 0;
     int priority = 0;
+    uint64_t runtime = 0;
+    uint64_t deadline = 0;
+    uint64_t period = 0;
     g_autoptr(virBitmap) map = NULL;
 
     if (!(map = virDomainSchedulerParse(node, elementName, attributeName,
-                                        &policy, &priority)))
+                                        &policy, &priority, &runtime,
+                                        &deadline, &period)))
         return -1;
 
     while ((next = virBitmapNextSetBit(map, next)) > -1) {
@@ -16792,6 +16820,9 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
 
         sched->policy = policy;
         sched->priority = priority;
+        sched->runtime = runtime;
+        sched->deadline = deadline;
+        sched->period = period;
     }
 
     return 0;
@@ -26029,6 +26060,17 @@ virDomainSchedulerFormat(virBuffer *buf,
                               sched->priority);
             break;
 
+        case VIR_PROC_POLICY_DEADLINE:
+            virBufferAsprintf(buf, "<%ssched", name);
+            if (multiple_threads)
+                virBufferAsprintf(buf, " %ss='%zu'", name, id);
+            virBufferAsprintf(buf, " scheduler='%s' runtime='%llu' deadline='%llu' period='%llu'/>\n",
+                              virProcessSchedPolicyTypeToString(sched->policy),
+                              (unsigned long long) sched->runtime,
+                              (unsigned long long) sched->deadline,
+                              (unsigned long long) sched->period);
+            break;
+
         case VIR_PROC_POLICY_NONE:
         case VIR_PROC_POLICY_LAST:
             break;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index c4f293a4c3..86daffab8c 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -1168,6 +1168,22 @@
           <ref name="unsignedShort"/>
         </attribute>
       </group>
+      <group>
+        <attribute name="scheduler">
+          <choice>
+            <value>deadline</value>
+          </choice>
+        </attribute>
+        <attribute name="runtime">
+          <ref name="unsignedLong"/>
+        </attribute>
+        <attribute name="deadline">
+          <ref name="unsignedLong"/>
+        </attribute>
+        <attribute name="period">
+          <ref name="unsignedLong"/>
+        </attribute>
+      </group>
     </choice>
   </define>
 
-- 
2.37.1


-- 
------------------------


Indirizzo istituzionale di posta elettronica 
degli studenti e dei laureati dell'Università di TorinoOfficial University 
of Turin email address for students and graduates 



More information about the libvir-list mailing list