[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/sched: rtds: enforce admission control in xl sched-rtds



commit 38e3acece28600313de92f1ff308cfa71675aa2e
Author:     Furkan Caliskan <frn1furkan10@xxxxxxxxx>
AuthorDate: Mon Sep 21 10:12:58 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Sep 21 10:43:00 2026 +0200

    xen/sched: rtds: enforce admission control in xl sched-rtds
    
    Now that we have introduced admission control for new and
    removed units. Extend it to XEN_DOMCTL_SCHEDOP_putinfo and
    putvcpuinfo, so growing an existing reservation via
    xl sched-rtds is checked too.
    
    putinfo sets the same (period, budget) for every unit of a
    domain at once, so it tests the whole domain's utilization
    delta atomically, rather than unit-by-unit, which could
    spuriously reject an overall-acceptable change depending on
    iteration order.
    
    putvcpuinfo changes one unit at a time, so it just calls
    rt_try_set_utilization() directly.
    
    Signed-off-by: Furkan Caliskan <frn1furkan10@xxxxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/common/sched/rt.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c
index ff561ec1c9..9f7cd1aea7 100644
--- a/xen/common/sched/rt.c
+++ b/xen/common/sched/rt.c
@@ -1527,11 +1527,43 @@ rt_dom_cntl(
         op->u.rtds.budget = RTDS_DEFAULT_BUDGET / MICROSECS(1);
         break;
     case XEN_DOMCTL_SCHEDOP_putinfo:
+    {
+        uint64_t dom_old_util = 0, new_util, new_total;
+        unsigned int nr_units = 0;
+
         rc = rt_validate_params(&op->u.rtds, &period, &budget);
         if ( rc )
             break;
 
+        new_util = rt_unit_utilization(period, budget);
+
         spin_lock_irqsave(&prv->lock, flags);
+
+        /*
+         * Same (period, budget) for every unit of d: test and commit
+         * the domain's whole utilization delta atomically, rather
+         * than unit-by-unit, which could spuriously reject an
+         * overall-acceptable change depending on iteration order.
+         */
+        for_each_sched_unit ( d, unit )
+        {
+            svc = rt_unit(unit);
+            dom_old_util += rt_unit_utilization(svc->period, svc->budget);
+            nr_units++;
+        }
+
+        new_total = prv->utilization - dom_old_util +
+                    (uint64_t)nr_units * new_util;
+
+        if ( new_total > prv->utilization && new_total > rt_utilization_cap(d) 
)
+        {
+            spin_unlock_irqrestore(&prv->lock, flags);
+            rc = -ENOSPC;
+            break;
+        }
+
+        prv->utilization = new_total;
+
         for_each_sched_unit ( d, unit )
         {
             svc = rt_unit(unit);
@@ -1540,6 +1572,7 @@ rt_dom_cntl(
         }
         spin_unlock_irqrestore(&prv->lock, flags);
         break;
+    }
     case XEN_DOMCTL_SCHEDOP_getvcpuinfo:
     case XEN_DOMCTL_SCHEDOP_putvcpuinfo:
         while ( index < op->u.v.nr_vcpus )
@@ -1584,6 +1617,15 @@ rt_dom_cntl(
 
                 spin_lock_irqsave(&prv->lock, flags);
                 svc = rt_unit(d->vcpu[local_sched.vcpuid]->sched_unit);
+
+                if ( !rt_try_set_utilization(prv, d, svc->period, svc->budget,
+                                              period, budget) )
+                {
+                    spin_unlock_irqrestore(&prv->lock, flags);
+                    rc = -ENOSPC;
+                    break;
+                }
+
                 svc->period = period;
                 svc->budget = budget;
                 if ( local_sched.u.rtds.flags & XEN_DOMCTL_SCHEDRT_extra )
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.