xen/sched: rtds: add per-cpupool admission control
cover xen/sched: rtds: add per-cpupool admission control
RTDS currently has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, the global-EDF deadline guarantees the scheduler is built around no longer hold for any unit sharing that pool.
This series adds admission control to prevent that, tracks and report utilization, and makes the check toggleable per cpupool so an operator can disable it if they intentionally want to overcommit.
Patch 1 introduces the core mechanism: a running utilization total per cpupool, a fixed-point representation of a unit's (budget/period), and a capacity check enforced in rt_alloc_udata()/rt_free_udata() - the lifecycle hooks that catch every new unit's default reservation.
Patch 2 extends the same check to domctl, so growing an existing reservation via xl sched-rtds is checked too.
Patch 3 reports a cpupool's admitted utilization agains its capacity via the 'r' debug key.
Patch 4 makes admission control itself toggleable per cpupool (enabled by default) via sysctl.
Patch 5 wires that toggle through libxl and adds -s/-a to xl sched-rtds, and documents it.
Furkan Caliskan (5):
xen/sched: rtds: add global-EDF utilization admission control xen/sched: rtds: enforce admission control in xl sched-rtds xen/sched: rtds: report utilization and cap via debug key xen/sched: rtds: make admission control cpupool-wide toggleable
tools: expose admission control toggle via xl sched-rtds
docs/man/xl.1.pod.in | 20 +++ tools/golang/xenlight/helpers.gen.go | 23 +++ tools/golang/xenlight/types.gen.go | 4 + tools/include/libxl.h | 4 + tools/include/xenctrl.h | 6 + tools/libs/ctrl/xc_rt.c | 40 ++++++ tools/libs/light/libxl_sched.c | 46 ++++++ tools/libs/light/libxl_types.idl | 5 + tools/xl/xl_cmdtable.c | 8 +- tools/xl/xl_sched.c | 103 +++++++++++++- xen/common/sched/rt.c | 205 ++++++++++++++++++++++++++- xen/include/public/sysctl.h | 5 + 12 files changed, 463 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/5 xen/sched: rtds: add global-EDF utilization admission control
RTDS has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, none of the EDF deadline guarantees this scheduler is built around still hold for the units sharing that pool.
Introduce admission control to prevent this: reject a reservation whenever admitting it would push a cpupool's units over its capacity. Track a running utilization total per cpupool, and enforce it in rt_alloc_udata()/rt_free_udata(), the paired lifecycle hooks for a unit's creation and destruction. This catches the default period/budget every new unit gets.
Utilization is represented as a fixed-point value: budget is left shifted by RTDS_UTIL_SHIFT (20 bits) and divided by period. A plain "(budget << RTDS_UTIL_SHIFT) / period" risks overflowing the multiply for large enough budgets. Rather than widen the arithmetic to tolerate any input, the input itself is bounded:rt_validate_params() rejects any budget above RTDS_MAX_BUDGET, chosen as the largest value that can be left-shifted by RTDS_UTIL_SHIFT without overflowing 64 bits, so the shift in rt_unit_utilization() can never overflow.
A cpupool's capacity rt_utilization_cap() scales with the number of scheduling resources in it. It is calculated as:
(number of sched_resources * RTDS_UTIL_SCALE * RTDS_UTIL_CAP_PCT / 100), where RTDS_UTIL_CAP_PCT controls how much of that capacity can actually be reserved; at 100% (its current value), all of it can be.
--- xen/common/sched/rt.c | 105 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-)
xen/common/sched/rt.c +104 -1
@@ -114,6 +114,24 @@*/ #define RTDS_MAX_PRIORITY_LEVEL (~0U) +/* +* Fixed-point scale for utilization (budget/period) +*/ +#define RTDS_UTIL_SHIFT 20 +#define RTDS_UTIL_SCALE (1ULL << RTDS_UTIL_SHIFT) + +/* +* Largest budget safe to left-shift by RTDS_UTIL_SHIFT without +* overflowing 64 bits. Enforced in rt_validate_params(). +*/ +#define RTDS_MAX_BUDGET_BITS (64 - RTDS_UTIL_SHIFT) +#define RTDS_MAX_BUDGET ((1ULL << RTDS_MAX_BUDGET_BITS) - 1) + +/* +* % of a cpupool's sched_resource capacity admitted units may sum up to. +*/ +#define RTDS_UTIL_CAP_PCT 100 +/* * UPDATE_LIMIT_SHIFT: a constant used in rt_update_deadline(). When finding * the next deadline, performing addition could be faster if the difference
@@ -195,6 +213,9 @@ struct rt_private {struct list_head replq;/* ordered list of units that need replenishment */ cpumask_t tickled;/* cpus been tickled */ + +/* Sum of admitted units' (budget/period), scaled by RTDS_UTIL_SCALE */ +uint64_t utilization; };/*
@@ -635,6 +656,54 @@ replq_reinsert(const struct scheduler *ops, struct rt_unit *svc)set_timer (&rt_priv (ops)->repl_timer, rearm_svc->cur_deadline); } +/* +* budget << RTDS_UTIL_SHIFT can't overflow: rt_validate_params() +* caps budget at RTDS_MAX_BUDGET. period == 0 means "no +* reservation" (a unit being removed), not an error. +*/ +static uint64_t +rt_unit_utilization (s_time_t period,s_time_t budget) +{ +if ( period <=0 ) +return 0 ; + +return ((uint64_t )budget <<RTDS_UTIL_SHIFT ) / (uint64_t )period; +} + +/* +* Utilization capacity of the cpupool domain d resides in. +*/ +static uint64_t +rt_utilization_cap (const struct domain *d) +{ +unsigned int cpus =cpumask_weight (cpupool_domain_master_cpumask (d)); + +return (uint64_t )cpus *RTDS_UTIL_SCALE *RTDS_UTIL_CAP_PCT /100 ; +} + +/* +* Replaces a unit's reservation and updates prv->utilization +* to match. Growth that would push utilization over the +* cpupool's cap is refused. Removing a unit or shrinking +* a unit's reservation always succeed. +*/ +static int +rt_admission_test (struct rt_private *prv,const struct domain *d, +s_time_t old_period,s_time_t old_budget, +s_time_t new_period,s_time_t new_budget) +{ +uint64_t old_util =rt_unit_utilization (old_period, old_budget); +uint64_t new_util =rt_unit_utilization (new_period, new_budget); +uint64_t total = prv->utilization - old_util + new_util; + +if ( new_util > old_util && total >rt_utilization_cap (d) ) +return -EINVAL ; + + prv->utilization = total; + +return 0 ; +} +/* * Pick a valid resource for the unit vc * Valid resource of an unit is intesection of unit's affinity
@@ -864,6 +933,7 @@ rt_free_domdata(const struct scheduler *ops, void *data) static void * cf_checkrt_alloc_udata (const struct scheduler *ops,struct sched_unit *unit,void *dd) { +struct rt_private *prv =rt_priv (ops);struct rt_unit *svc;/* Allocate per-UNIT info */
@@ -881,9 +951,30 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd)__set_bit (__RTDS_extratime, &svc->flags); svc->priority_level =0 ; svc->period =RTDS_DEFAULT_PERIOD ; +if ( !is_idle_unit (unit) ) + { +unsigned long flags; +int rc; + svc->budget =RTDS_DEFAULT_BUDGET ; +spin_lock_irqsave (&prv->lock, flags); + rc =rt_admission_test (prv, unit->domain,0 ,0 , + svc->period, svc->budget); +spin_unlock_irqrestore (&prv->lock, flags); + +if ( rc ) + { +printk (XENLOG_WARNING +"RTDS: ADMISSION CONTROL: refusing unit %u of d%d," +" would exceed utilization capacity of the cpupool\n" , + unit->unit_id, unit->domain->domain_id); +xfree (svc); +return NULL ; + } + } +SCHED_STAT_CRANK (unit_alloc);return svc;
@@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) static void cf_checkrt_free_udata (const struct scheduler *ops,void *priv) { +struct rt_private *prv =rt_priv (ops);struct rt_unit *svc = priv; +if ( svc && !is_idle_unit (svc->unit) ) + { +unsigned long flags; + +spin_lock_irqsave (&prv->lock, flags); +rt_admission_test (prv, svc->unit->domain, + svc->period, svc->budget,0 ,0 ); +spin_unlock_irqrestore (&prv->lock, flags); + } +xfree (svc); }
@@ -1389,7 +1491,8 @@ rt_validate_params(const struct xen_domctl_sched_rtds *rtds,s_time_t b =MICROSECS (rtds->budget);if ( p <RTDS_MIN_PERIOD || p >RTDS_MAX_PERIOD || - b <RTDS_MIN_BUDGET || b > p ) + b <RTDS_MIN_BUDGET || b > p || + b > (s_time_t )RTDS_MAX_BUDGET )return -EINVAL ; *period = p;
Signature · 1 line
2.34.1
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
Quoted 102 lines · Furkan Caliskan
RTDS has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, none of the EDF deadline guarantees this scheduler is built around still hold for the units sharing that pool.
Introduce admission control to prevent this: reject a reservation whenever admitting it would push a cpupool's units over its capacity. Track a running utilization total per cpupool, and enforce it in rt_alloc_udata()/rt_free_udata(), the paired lifecycle hooks for a unit's creation and destruction. This catches the default period/budget every new unit gets.
Utilization is represented as a fixed-point value: budget is left shifted by
RTDS_UTIL_SHIFT(20 bits) and divided by period. A plain "(budget <<RTDS_UTIL_SHIFT) / period" risks overflowing the multiply for large enough budgets. Rather than widen the arithmetic to tolerate any input, the input itself is bounded:rt_validate_params()rejects any budget aboveRTDS_MAX_BUDGET, chosen as the largest value that can be left-shifted byRTDS_UTIL_SHIFTwithout overflowing 64 bits, so the shift inrt_unit_utilization()can never overflow.A cpupool's capacity
rt_utilization_cap()scales with the number of scheduling resources in it. It is calculated as:
(number ofsched_resources*RTDS_UTIL_SCALE*RTDS_UTIL_CAP_PCT/ 100), whereRTDS_UTIL_CAP_PCTcontrols how much of that capacity can actually be reserved; at 100% (its current value), all of it can be.Signed-off-by Furkan Caliskan <[email protected]>--- xen/common/sched/rt.c | 105 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-)xen/common/sched/rt.c +46
-0@@ -114,6 +114,24 @@*/ #define RTDS_MAX_PRIORITY_LEVEL (~0U) +/* +* Fixed-point scale for utilization (budget/period) +*/ +#define RTDS_UTIL_SHIFT 20 +#define RTDS_UTIL_SCALE (1ULL << RTDS_UTIL_SHIFT) + +/* +* Largest budget safe to left-shift by RTDS_UTIL_SHIFT without +* overflowing 64 bits. Enforced in rt_validate_params(). +*/ +#define RTDS_MAX_BUDGET_BITS (64 - RTDS_UTIL_SHIFT) +#define RTDS_MAX_BUDGET ((1ULL << RTDS_MAX_BUDGET_BITS) - 1) + +/* +* % of a cpupool's sched_resource capacity admitted units may sum up to. +*/ +#define RTDS_UTIL_CAP_PCT 100 +/* * UPDATE_LIMIT_SHIFT: a constant used in rt_update_deadline(). When finding * the next deadline, performing addition could be faster if the difference @@ -195,6 +213,9 @@ struct rt_private {struct list_head replq;/* ordered list of units that need replenishment */ cpumask_t tickled;/* cpus been tickled */ + +/* Sum of admitted units' (budget/period), scaled by RTDS_UTIL_SCALE */ +uint64_t utilization; };/* @@ -635,6 +656,54 @@ replq_reinsert(const struct scheduler *ops, struct rt_unit *svc)set_timer (&rt_priv (ops)->repl_timer, rearm_svc->cur_deadline); } +/* +* budget << RTDS_UTIL_SHIFT can't overflow: rt_validate_params() +* caps budget at RTDS_MAX_BUDGET. period == 0 means "no +* reservation" (a unit being removed), not an error. +*/ +static uint64_t +rt_unit_utilization (s_time_t period,s_time_t budget) +{ +if ( period <=0 ) +return 0 ; + +return ((uint64_t )budget <<RTDS_UTIL_SHIFT ) / (uint64_t )period; +} + +/* +* Utilization capacity of the cpupool domain d resides in. +*/ +static uint64_t +rt_utilization_cap (const struct domain *d) +{ +unsigned int cpus =cpumask_weight (cpupool_domain_master_cpumask (d)); + +return (uint64_t )cpus *RTDS_UTIL_SCALE *RTDS_UTIL_CAP_PCT /100 ; +} +
xen/common/sched/rt.c replq_reinsert(const struct scheduler *ops, struct rt_unit *svc) · line 693
Quoted 10 lines
xen/common/sched/rt.c +10
-0+/* +* Replaces a unit's reservation and updates prv->utilization +* to match. Growth that would push utilization over the +* cpupool's cap is refused. Removing a unit or shrinking +* a unit's reservation always succeed. +*/ +static int +rt_admission_test (struct rt_private *prv,const struct domain *d, +s_time_t old_period,s_time_t old_budget, +s_time_t new_period,s_time_t new_budget)
I think the function name isn't appropriate. The function doesn't test only, it is setting the utilization, too.
What about rt_try_set_utilization() instead? And make the return type bool (true on success).
Quoted 59 lines
xen/common/sched/rt.c +35
-0+{ +uint64_t old_util =rt_unit_utilization (old_period, old_budget); +uint64_t new_util =rt_unit_utilization (new_period, new_budget); +uint64_t total = prv->utilization - old_util + new_util; + +if ( new_util > old_util && total >rt_utilization_cap (d) ) +return -EINVAL ; + + prv->utilization = total; + +return 0 ; +} +/* * Pick a valid resource for the unit vc * Valid resource of an unit is intesection of unit's affinity @@ -864,6 +933,7 @@ rt_free_domdata(const struct scheduler *ops, void *data) static void * cf_checkrt_alloc_udata (const struct scheduler *ops,struct sched_unit *unit,void *dd) { +struct rt_private *prv =rt_priv (ops);struct rt_unit *svc;/* Allocate per-UNIT info */ @@ -881,9 +951,30 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd)__set_bit (__RTDS_extratime, &svc->flags); svc->priority_level =0 ; svc->period =RTDS_DEFAULT_PERIOD ; +if ( !is_idle_unit (unit) ) + { +unsigned long flags; +int rc; + svc->budget =RTDS_DEFAULT_BUDGET ; +spin_lock_irqsave (&prv->lock, flags); + rc =rt_admission_test (prv, unit->domain,0 ,0 , + svc->period, svc->budget); +spin_unlock_irqrestore (&prv->lock, flags); + +if ( rc ) + { +printk (XENLOG_WARNING +"RTDS: ADMISSION CONTROL: refusing unit %u of d%d," +" would exceed utilization capacity of the cpupool\n" , + unit->unit_id, unit->domain->domain_id); +xfree (svc); +return NULL ; + } + } +SCHED_STAT_CRANK (unit_alloc);return svc;@@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) static void cf_checkrt_free_udata (const struct scheduler *ops,void *priv) {
xen/common/sched/rt.c rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) · line 995
Quoted 10 lines
xen/common/sched/rt.c +8
-0+struct rt_private *prv =rt_priv (ops);struct rt_unit *svc = priv; +if ( svc && !is_idle_unit (svc->unit) ) + { +unsigned long flags; + +spin_lock_irqsave (&prv->lock, flags); +rt_admission_test (prv, svc->unit->domain, + svc->period, svc->budget,0 ,0 );
This use case clearly shows you are not only testing. :-)
Quoted 7 lines
xen/common/sched/rt.c +3
-0+spin_unlock_irqrestore (&prv->lock, flags); + } +xfree (svc); }
xen/common/sched/rt.c rt_validate_params(const struct xen_domctl_sched_rtds *rtds, · line 1498
Quoted 9 lines
xen/common/sched/rt.c +2
-1@@ -1389,7 +1491,8 @@ rt_validate_params(const struct xen_domctl_sched_rtds *rtds,s_time_t b =MICROSECS (rtds->budget);if ( p <RTDS_MIN_PERIOD || p >RTDS_MAX_PERIOD || - b <RTDS_MIN_BUDGET || b > p ) + b <RTDS_MIN_BUDGET || b > p || + b > (s_time_t )RTDS_MAX_BUDGET )return -EINVAL ; *period = p;
Juergen
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
Quoted 70 lines · Juergen Gross
Quoted 29 lines · Furkan Caliskan
xen/common/sched/rt.c +25
-0@@ -635,6 +656,54 @@ replq_reinsert(const struct scheduler *ops, struct rt_unit *svc)set_timer (&rt_priv (ops)->repl_timer, rearm_svc->cur_deadline); } +/* +* budget << RTDS_UTIL_SHIFT can't overflow: rt_validate_params() +* caps budget at RTDS_MAX_BUDGET. period == 0 means "no +* reservation" (a unit being removed), not an error. +*/ +static uint64_t +rt_unit_utilization (s_time_t period,s_time_t budget) +{ +if ( period <=0 ) +return 0 ; + +return ((uint64_t )budget <<RTDS_UTIL_SHIFT ) / (uint64_t )period; +} + +/* +* Utilization capacity of the cpupool domain d resides in. +*/ +static uint64_t +rt_utilization_cap (const struct domain *d) +{ +unsigned int cpus =cpumask_weight (cpupool_domain_master_cpumask (d)); + +return (uint64_t )cpus *RTDS_UTIL_SCALE *RTDS_UTIL_CAP_PCT /100 ; +} +xen/common/sched/rt.c replq_reinsert(const struct scheduler *ops, struct rt_unit *svc) · line 693
Quoted 10 lines
xen/common/sched/rt.c +10
-0+/* +* Replaces a unit's reservation and updates prv->utilization +* to match. Growth that would push utilization over the +* cpupool's cap is refused. Removing a unit or shrinking +* a unit's reservation always succeed. +*/ +static int +rt_admission_test (struct rt_private *prv,const struct domain *d, +s_time_t old_period,s_time_t old_budget, +s_time_t new_period,s_time_t new_budget)I think the function name isn't appropriate. The function doesn't test only, it is setting the utilization, too.
What about
rt_try_set_utilization()instead? And make the return type bool (true on success).Quoted 23 lines
xen/common/sched/rt.c +14
-0+{ +uint64_t old_util =rt_unit_utilization (old_period, old_budget); +uint64_t new_util =rt_unit_utilization (new_period, new_budget); +uint64_t total = prv->utilization - old_util + new_util; + +if ( new_util > old_util && total >rt_utilization_cap (d) ) +return -EINVAL ; + + prv->utilization = total; + +return 0 ; +} +/* * Pick a valid resource for the unit vc * Valid resource of an unit is intesection of unit's affinity @@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) static void cf_checkrt_free_udata (const struct scheduler *ops,void *priv) { +struct rt_private *prv =rt_priv (ops);struct rt_unit *svc = priv;
Quoted 9 lines
xen/common/sched/rt.c rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) · line 995
Quoted 7 lines
xen/common/sched/rt.c +7
-0+if ( svc && !is_idle_unit (svc->unit) ) + { +unsigned long flags; + +spin_lock_irqsave (&prv->lock, flags); +rt_admission_test (prv, svc->unit->domain, + svc->period, svc->budget,0 ,0 );This use case clearly shows you are not only testing. :-)
Yet at the same time ignoring possible errors.
Jan
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
Quoted 81 lines · Jan Beulich
Quoted 70 lines · Juergen Gross
Quoted 29 lines · Furkan Caliskan
xen/common/sched/rt.c +25
-0@@ -635,6 +656,54 @@ replq_reinsert(const struct scheduler *ops, struct rt_unit *svc)set_timer (&rt_priv (ops)->repl_timer, rearm_svc->cur_deadline); } +/* +* budget << RTDS_UTIL_SHIFT can't overflow: rt_validate_params() +* caps budget at RTDS_MAX_BUDGET. period == 0 means "no +* reservation" (a unit being removed), not an error. +*/ +static uint64_t +rt_unit_utilization (s_time_t period,s_time_t budget) +{ +if ( period <=0 ) +return 0 ; + +return ((uint64_t )budget <<RTDS_UTIL_SHIFT ) / (uint64_t )period; +} + +/* +* Utilization capacity of the cpupool domain d resides in. +*/ +static uint64_t +rt_utilization_cap (const struct domain *d) +{ +unsigned int cpus =cpumask_weight (cpupool_domain_master_cpumask (d)); + +return (uint64_t )cpus *RTDS_UTIL_SCALE *RTDS_UTIL_CAP_PCT /100 ; +} +xen/common/sched/rt.c replq_reinsert(const struct scheduler *ops, struct rt_unit *svc) · line 693
Quoted 10 lines
xen/common/sched/rt.c +10
-0+/* +* Replaces a unit's reservation and updates prv->utilization +* to match. Growth that would push utilization over the +* cpupool's cap is refused. Removing a unit or shrinking +* a unit's reservation always succeed. +*/ +static int +rt_admission_test (struct rt_private *prv,const struct domain *d, +s_time_t old_period,s_time_t old_budget, +s_time_t new_period,s_time_t new_budget)I think the function name isn't appropriate. The function doesn't test only, it is setting the utilization, too.
What about
rt_try_set_utilization()instead? And make the return type bool (true on success).Quoted 23 lines
xen/common/sched/rt.c +14
-0+{ +uint64_t old_util =rt_unit_utilization (old_period, old_budget); +uint64_t new_util =rt_unit_utilization (new_period, new_budget); +uint64_t total = prv->utilization - old_util + new_util; + +if ( new_util > old_util && total >rt_utilization_cap (d) ) +return -EINVAL ; + + prv->utilization = total; + +return 0 ; +} +/* * Pick a valid resource for the unit vc * Valid resource of an unit is intesection of unit's affinity @@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) static void cf_checkrt_free_udata (const struct scheduler *ops,void *priv) { +struct rt_private *prv =rt_priv (ops);struct rt_unit *svc = priv;Quoted 9 lines
xen/common/sched/rt.c rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) · line 995
Quoted 7 lines
xen/common/sched/rt.c +7
-0+if ( svc && !is_idle_unit (svc->unit) ) + { +unsigned long flags; + +spin_lock_irqsave (&prv->lock, flags); +rt_admission_test (prv, svc->unit->domain, + svc->period, svc->budget,0 ,0 );This use case clearly shows you are not only testing. :-)
Quoted 1 line
Yet at the same time ignoring possible errors.
I don't see how this could happen, as new_period and new_budget are both 0 here.
Juergen
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
Quoted 20 lines · Jürgen Groß
Quoted 19 lines · Jan Beulich
Quoted 17 lines · Juergen Gross
Quoted 4 lines · Furkan Caliskan
xen/common/sched/rt.c +0
-0@@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) static void cf_checkrt_free_udata (const struct scheduler *ops,void *priv) {xen/common/sched/rt.c rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) · line 995
Quoted 10 lines
xen/common/sched/rt.c +8
-0+struct rt_private *prv =rt_priv (ops);struct rt_unit *svc = priv; +if ( svc && !is_idle_unit (svc->unit) ) + { +unsigned long flags; + +spin_lock_irqsave (&prv->lock, flags); +rt_admission_test (prv, svc->unit->domain, + svc->period, svc->budget,0 ,0 );This use case clearly shows you are not only testing. :-)
Quoted 3 lines
Quoted 1 line
Yet at the same time ignoring possible errors.
I don't see how this could happen, as
new_periodandnew_budgetare both 0 here.
Okay, that's simply entirely invisible here. So before freeing the two items are somehow zeroed?
Jan
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Jürgen Groß
Quoted 19 lines · Jan Beulich
Quoted 17 lines · Juergen Gross
Quoted 4 lines · Furkan Caliskan
xen/common/sched/rt.c +0
-0@@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) static void cf_checkrt_free_udata (const struct scheduler *ops,void *priv) {xen/common/sched/rt.c rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) · line 995
Quoted 10 lines
xen/common/sched/rt.c +8
-0+struct rt_private *prv =rt_priv (ops);struct rt_unit *svc = priv; +if ( svc && !is_idle_unit (svc->unit) ) + { +unsigned long flags; + +spin_lock_irqsave (&prv->lock, flags); +rt_admission_test (prv, svc->unit->domain, + svc->period, svc->budget,0 ,0 );This use case clearly shows you are not only testing. :-)
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Yet at the same time ignoring possible errors.
I don't see how this could happen, as
new_periodandnew_budgetare both 0 here.Okay, that's simply entirely invisible here. So before freeing the two items are somehow zeroed?
Jan
Can you please clarify what do you mean here?
Furkan
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
Quoted 23 lines · Furkan Çalışkan
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Jürgen Groß
Quoted 19 lines · Jan Beulich
Quoted 17 lines · Juergen Gross
Quoted 4 lines · Furkan Caliskan
xen/common/sched/rt.c +0
-0@@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) static void cf_checkrt_free_udata (const struct scheduler *ops,void *priv) {xen/common/sched/rt.c rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) · line 995
Quoted 10 lines
xen/common/sched/rt.c +8
-0+struct rt_private *prv =rt_priv (ops);struct rt_unit *svc = priv; +if ( svc && !is_idle_unit (svc->unit) ) + { +unsigned long flags; + +spin_lock_irqsave (&prv->lock, flags); +rt_admission_test (prv, svc->unit->domain, + svc->period, svc->budget,0 ,0 );This use case clearly shows you are not only testing. :-)
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Yet at the same time ignoring possible errors.
I don't see how this could happen, as
new_periodandnew_budgetare both 0 here.Okay, that's simply entirely invisible here. So before freeing the two items are somehow zeroed?
Can you please clarify what do you mean here?
Confusion on my part: I assumed talk was of the two svc-> values being passed, but those are "old". "new" are the two uncommented literal zeroes. Leaving them uncommented may be okay here; to me that's almost like uncommented literal "true" / "false" somewhere.
Jan
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
In reply to Juergen GrossQuoted 113 lines · Juergen Gross
Quoted 98 lines · Furkan Caliskan
RTDS has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, none of the EDF deadline guarantees this scheduler is built around still hold for the units sharing that pool.
Introduce admission control to prevent this: reject a reservation whenever admitting it would push a cpupool's units over its capacity. Track a running utilization total per cpupool, and enforce it in rt_alloc_udata()/rt_free_udata(), the paired lifecycle hooks for a unit's creation and destruction. This catches the default period/budget every new unit gets.
Utilization is represented as a fixed-point value: budget is left shifted by
RTDS_UTIL_SHIFT(20 bits) and divided by period. A plain "(budget <<RTDS_UTIL_SHIFT) / period" risks overflowing the multiply for large enough budgets. Rather than widen the arithmetic to tolerate any input, the input itself is bounded:rt_validate_params()rejects any budget aboveRTDS_MAX_BUDGET, chosen as the largest value that can be left-shifted byRTDS_UTIL_SHIFTwithout overflowing 64 bits, so the shift inrt_unit_utilization()can never overflow.A cpupool's capacity
rt_utilization_cap()scales with the number of scheduling resources in it. It is calculated as:
(number ofsched_resources*RTDS_UTIL_SCALE*RTDS_UTIL_CAP_PCT/ 100), whereRTDS_UTIL_CAP_PCTcontrols how much of that capacity can actually be reserved; at 100% (its current value), all of it can be.Signed-off-by Furkan Caliskan <[email protected]>---
xen/common/sched/rt.c| 105 +++++++++++++++++++++++++++++++++++++++++-1 file changed, 104 insertions(+), 1 deletion(-)xen/common/sched/rt.c +0
-0@@ -114,6 +114,24 @@*/ #define RTDS_MAX_PRIORITY_LEVEL (~0U)+/*
+ * Fixed-point scale for utilization (budget/period)
+ */xen/common/sched/rt.c +15
-0+#define RTDS_UTIL_SHIFT 20 +#define RTDS_UTIL_SCALE (1ULL << RTDS_UTIL_SHIFT) + +/* +* Largest budget safe to left-shift by RTDS_UTIL_SHIFT without +* overflowing 64 bits. Enforced in rt_validate_params(). +*/ +#define RTDS_MAX_BUDGET_BITS (64 - RTDS_UTIL_SHIFT) +#define RTDS_MAX_BUDGET ((1ULL << RTDS_MAX_BUDGET_BITS) - 1) + +/* +* % of a cpupool's sched_resource capacity admitted units may sum up to. +*/ +#define RTDS_UTIL_CAP_PCT 100 +/*
*UPDATE_LIMIT_SHIFT: a constant used inrt_update_deadline(). When finding
* the next deadline, performing addition could be faster if the differencexen/common/sched/rt.c +0
-0@@ -195,6 +213,9 @@ struct rt_private {struct
list_headreplq; /* ordered list of units that need replenishment */cpumask_ttickled; /* cpus been tickled */
+
+ /* Sum of admitted units' (budget/period), scaled byRTDS_UTIL_SCALE*/ +uint64_tutilization;
};
/*xen/common/sched/rt.c +0
-0@@ -635,6 +656,54 @@ replq_reinsert(const struct scheduler *ops, struct rt_unit *svc) set_timer(&rt_priv(ops)->repl_timer, rearm_svc->cur_deadline); }+/*
+ * budget <<RTDS_UTIL_SHIFTcan't overflow:rt_validate_params()
+ * caps budget atRTDS_MAX_BUDGET. period == 0 means "no
+ * reservation" (a unit being removed), not an error.
+ */xen/common/sched/rt.c +20
-0+static uint64_t +rt_unit_utilization (s_time_t period,s_time_t budget) +{ + if ( period <= 0 ) + return 0; + + return ((uint64_t)budget << RTDS_UTIL_SHIFT) / (uint64_t)period; +} + +/* +* Utilization capacity of the cpupool domain d resides in. +*/ +static uint64_t +rt_utilization_cap (const struct domain *d) +{ + unsigned int cpus = cpumask_weight(cpupool_domain_master_cpumask(d)); + + return (uint64_t)cpus * RTDS_UTIL_SCALE * RTDS_UTIL_CAP_PCT / 100; +} +xen/common/sched/rt.c replq_reinsert(const struct scheduler *ops, struct rt_unit *svc) · line 693
Quoted 10 lines
xen/common/sched/rt.c +10
-0+/* +* Replaces a unit's reservation and updates prv->utilization +* to match. Growth that would push utilization over the +* cpupool's cap is refused. Removing a unit or shrinking +* a unit's reservation always succeed. +*/ +static int +rt_admission_test (struct rt_private *prv,const struct domain *d, + s_time_t old_period, s_time_t old_budget, + s_time_t new_period, s_time_t new_budget)I think the function name isn't appropriate. The function doesn't test only, it is setting the utilization, too.
Quoted 3 lines
What about
rt_try_set_utilization()instead? And make the return type bool (true on success).
Okay, I'll change the name in v2. And the return type too.
Quoted 83 lines
Quoted 57 lines
xen/common/sched/rt.c +13
-0+{ + uint64_t old_util = rt_unit_utilization(old_period, old_budget); + uint64_t new_util = rt_unit_utilization(new_period, new_budget); + uint64_t total = prv->utilization - old_util + new_util; + + if ( new_util > old_util && total > rt_utilization_cap(d) ) + return -EINVAL; + + prv->utilization = total; + + return 0; +} +/*
* Pick a valid resource for the unit vc
* Valid resource of an unit is intesection of unit's affinityxen/common/sched/rt.c +0
-0@@ -864,6 +933,7 @@ rt_free_domdata(const struct scheduler *ops, void *data)static void *
cf_check
rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd){
+ structrt_private*prv =rt_priv(ops);
structrt_unit*svc;
/* Allocate per-UNIT info */xen/common/sched/rt.c +20
-0@@ -881,9 +951,30 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) __set_bit(__RTDS_extratime, &svc->flags); svc->priority_level = 0; svc->period = RTDS_DEFAULT_PERIOD; + if ( !is_idle_unit(unit) ) + { + unsigned long flags; + int rc; + svc->budget = RTDS_DEFAULT_BUDGET; + spin_lock_irqsave(&prv->lock, flags); + rc = rt_admission_test(prv, unit->domain, 0, 0, + svc->period, svc->budget); + spin_unlock_irqrestore(&prv->lock, flags); + + if ( rc ) + { + printk(XENLOG_WARNING + "RTDS: ADMISSION CONTROL: refusing unit %u of d%d," + " would exceed utilization capacity of the cpupool\n", + unit->unit_id, unit->domain->domain_id); + xfree(svc); + return NULL; + } + } + SCHED_STAT_CRANK(unit_alloc); return svc;@@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd)static void
cf_check
rt_free_udata(const struct scheduler *ops, void *priv){
+ structrt_private*prv =rt_priv(ops);Quoted 8 lines
struct
rt_unit*svc = priv;
+ if ( svc && !is_idle_unit(svc->unit) )
+ {
+ unsigned long flags;
+
+spin_lock_irqsave(&prv->lock, flags);
+ rt_admission_test(prv,svc->unit->domain, +svc->period,svc->budget, 0, 0);This use case clearly shows you are not only testing. :-)
Quoted 7 lines
+
spin_unlock_irqrestore(&prv->lock, flags);
+ }
+
xfree(svc);
}
@@ -1389,7 +1491,8 @@ rt_validate_params(const structxen_domctl_sched_rtds*rtds,s_time_tb =MICROSECS(rtds->budget);Quoted 6 lines
if ( p < RTDS_MIN_PERIOD || p > RTDS_MAX_PERIOD || - b < RTDS_MIN_BUDGET || b > p ) + b < RTDS_MIN_BUDGET || b > p ||+ b > (s_time_t)RTDS_MAX_BUDGET )
return-EINVAL;
*period = p;
Quoted 2 lines
Juergen
Thanks,
Furkan
Re: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control
In reply to Juergen GrossQuoted 199 lines · Juergen Gross
Quoted 98 lines · Furkan Caliskan
RTDS has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, none of the EDF deadline guarantees this scheduler is built around still hold for the units sharing that pool.
Introduce admission control to prevent this: reject a reservation whenever admitting it would push a cpupool's units over its capacity. Track a running utilization total per cpupool, and enforce it in rt_alloc_udata()/rt_free_udata(), the paired lifecycle hooks for a unit's creation and destruction. This catches the default period/budget every new unit gets.
Utilization is represented as a fixed-point value: budget is left shifted by
RTDS_UTIL_SHIFT(20 bits) and divided by period. A plain "(budget <<RTDS_UTIL_SHIFT) / period" risks overflowing the multiply for large enough budgets. Rather than widen the arithmetic to tolerate any input, the input itself is bounded:rt_validate_params()rejects any budget aboveRTDS_MAX_BUDGET, chosen as the largest value that can be left-shifted byRTDS_UTIL_SHIFTwithout overflowing 64 bits, so the shift inrt_unit_utilization()can never overflow.A cpupool's capacity
rt_utilization_cap()scales with the number of scheduling resources in it. It is calculated as:
(number ofsched_resources*RTDS_UTIL_SCALE*RTDS_UTIL_CAP_PCT/ 100), whereRTDS_UTIL_CAP_PCTcontrols how much of that capacity can actually be reserved; at 100% (its current value), all of it can be.Signed-off-by Furkan Caliskan <[email protected]>---
xen/common/sched/rt.c| 105 +++++++++++++++++++++++++++++++++++++++++-1 file changed, 104 insertions(+), 1 deletion(-)xen/common/sched/rt.c +0
-0@@ -114,6 +114,24 @@*/ #define RTDS_MAX_PRIORITY_LEVEL (~0U)+/*
+ * Fixed-point scale for utilization (budget/period)
+ */xen/common/sched/rt.c +15
-0+#define RTDS_UTIL_SHIFT 20 +#define RTDS_UTIL_SCALE (1ULL << RTDS_UTIL_SHIFT) + +/* +* Largest budget safe to left-shift by RTDS_UTIL_SHIFT without +* overflowing 64 bits. Enforced in rt_validate_params(). +*/ +#define RTDS_MAX_BUDGET_BITS (64 - RTDS_UTIL_SHIFT) +#define RTDS_MAX_BUDGET ((1ULL << RTDS_MAX_BUDGET_BITS) - 1) + +/* +* % of a cpupool's sched_resource capacity admitted units may sum up to. +*/ +#define RTDS_UTIL_CAP_PCT 100 +/*
*UPDATE_LIMIT_SHIFT: a constant used inrt_update_deadline(). When finding
* the next deadline, performing addition could be faster if the differencexen/common/sched/rt.c +0
-0@@ -195,6 +213,9 @@ struct rt_private {struct
list_headreplq; /* ordered list of units that need replenishment */cpumask_ttickled; /* cpus been tickled */
+
+ /* Sum of admitted units' (budget/period), scaled byRTDS_UTIL_SCALE*/ +uint64_tutilization;
};
/*xen/common/sched/rt.c +0
-0@@ -635,6 +656,54 @@ replq_reinsert(const struct scheduler *ops, struct rt_unit *svc) set_timer(&rt_priv(ops)->repl_timer, rearm_svc->cur_deadline); }+/*
+ * budget <<RTDS_UTIL_SHIFTcan't overflow:rt_validate_params()
+ * caps budget atRTDS_MAX_BUDGET. period == 0 means "no
+ * reservation" (a unit being removed), not an error.
+ */xen/common/sched/rt.c +20
-0+static uint64_t +rt_unit_utilization (s_time_t period,s_time_t budget) +{ + if ( period <= 0 ) + return 0; + + return ((uint64_t)budget << RTDS_UTIL_SHIFT) / (uint64_t)period; +} + +/* +* Utilization capacity of the cpupool domain d resides in. +*/ +static uint64_t +rt_utilization_cap (const struct domain *d) +{ + unsigned int cpus = cpumask_weight(cpupool_domain_master_cpumask(d)); + + return (uint64_t)cpus * RTDS_UTIL_SCALE * RTDS_UTIL_CAP_PCT / 100; +} +xen/common/sched/rt.c replq_reinsert(const struct scheduler *ops, struct rt_unit *svc) · line 693
Quoted 10 lines
xen/common/sched/rt.c +10
-0+/* +* Replaces a unit's reservation and updates prv->utilization +* to match. Growth that would push utilization over the +* cpupool's cap is refused. Removing a unit or shrinking +* a unit's reservation always succeed. +*/ +static int +rt_admission_test (struct rt_private *prv,const struct domain *d, + s_time_t old_period, s_time_t old_budget, + s_time_t new_period, s_time_t new_budget)I think the function name isn't appropriate. The function doesn't test only, it is setting the utilization, too.
What about
rt_try_set_utilization()instead? And make the return type bool (true on success).Quoted 57 lines
xen/common/sched/rt.c +13
-0+{ + uint64_t old_util = rt_unit_utilization(old_period, old_budget); + uint64_t new_util = rt_unit_utilization(new_period, new_budget); + uint64_t total = prv->utilization - old_util + new_util; + + if ( new_util > old_util && total > rt_utilization_cap(d) ) + return -EINVAL; + + prv->utilization = total; + + return 0; +} +/*
* Pick a valid resource for the unit vc
* Valid resource of an unit is intesection of unit's affinityxen/common/sched/rt.c +0
-0@@ -864,6 +933,7 @@ rt_free_domdata(const struct scheduler *ops, void *data)static void *
cf_check
rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd){
+ structrt_private*prv =rt_priv(ops);
structrt_unit*svc;
/* Allocate per-UNIT info */xen/common/sched/rt.c +20
-0@@ -881,9 +951,30 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd) __set_bit(__RTDS_extratime, &svc->flags); svc->priority_level = 0; svc->period = RTDS_DEFAULT_PERIOD; + if ( !is_idle_unit(unit) ) + { + unsigned long flags; + int rc; + svc->budget = RTDS_DEFAULT_BUDGET; + spin_lock_irqsave(&prv->lock, flags); + rc = rt_admission_test(prv, unit->domain, 0, 0, + svc->period, svc->budget); + spin_unlock_irqrestore(&prv->lock, flags); + + if ( rc ) + { + printk(XENLOG_WARNING + "RTDS: ADMISSION CONTROL: refusing unit %u of d%d," + " would exceed utilization capacity of the cpupool\n", + unit->unit_id, unit->domain->domain_id); + xfree(svc); + return NULL; + } + } + SCHED_STAT_CRANK(unit_alloc); return svc;@@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void *dd)static void
cf_check
rt_free_udata(const struct scheduler *ops, void *priv){
+ structrt_private*prv =rt_priv(ops);Quoted 8 lines
struct
rt_unit*svc = priv;
+ if ( svc && !is_idle_unit(svc->unit) )
+ {
+ unsigned long flags;
+
+spin_lock_irqsave(&prv->lock, flags);
+ rt_admission_test(prv,svc->unit->domain, +svc->period,svc->budget, 0, 0);This use case clearly shows you are not only testing. :-)
Quoted 7 lines
+
spin_unlock_irqrestore(&prv->lock, flags);
+ }
+
xfree(svc);
}
@@ -1389,7 +1491,8 @@ rt_validate_params(const structxen_domctl_sched_rtds*rtds,s_time_tb =MICROSECS(rtds->budget);Quoted 6 lines
if ( p < RTDS_MIN_PERIOD || p > RTDS_MAX_PERIOD || - b < RTDS_MIN_BUDGET || b > p ) + b < RTDS_MIN_BUDGET || b > p ||+ b > (s_time_t)RTDS_MAX_BUDGET )
return-EINVAL;
*period = p;
Quoted 2 lines
Juergen
BTW, if the rt_admission_test() returns false in rt_alloc_udata(), vcpu_create() will fail too. This will cause the d->vcpu[i] to become null, and it will crash in sched_move_domain().
So to avoid the crash, this patch needs the v2 of my fix for that.
https://lore.kernel.org/xen-devel/[email protected]/
Juergen, what do you say to acking that v2 fix?
Furkan
PATCH 2/5 xen/sched: rtds: enforce admission control in xl sched-rtds
In reply to Furkan CaliskanNow 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_admission_test() directly.
--- xen/common/sched/rt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
xen/common/sched/rt.c +42 -0
@@ -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) ) + { + rc = -EINVAL ; +spin_unlock_irqrestore (&prv->lock, flags); +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); + + rc =rt_admission_test (prv, d, svc->period, svc->budget, + period, budget); +if ( rc ) + { +spin_unlock_irqrestore (&prv->lock, flags); +break ; + } + svc->period = period; svc->budget = budget;if ( local_sched.u.rtds.flags & XEN_DOMCTL_SCHEDRT_extra )
Signature · 1 line
2.34.1
Re: [PATCH 2/5] xen/sched: rtds: enforce admission control in xl sched-rtds
Quoted 48 lines · Furkan Caliskan
Now that we have introduced admission control for new and removed units. Extend it to
XEN_DOMCTL_SCHEDOP_putinfoand 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_admission_test()directly.Signed-off-by Furkan Caliskan <[email protected]>--- xen/common/sched/rt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)xen/common/sched/rt.c +16
-0@@ -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);
xen/common/sched/rt.c rt_dom_cntl( · line 1560
Quoted 10 lines
xen/common/sched/rt.c +10
-0+ 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) ) + { + rc = -EINVAL ;
Is EINVAL a good choice here? I think a different error code might be wanted.
Quoted 23 lines
xen/common/sched/rt.c +9
-0+spin_unlock_irqrestore (&prv->lock, flags); +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); + + rc = rt_admission_test(prv, d, svc->period, svc->budget,
xen/common/sched/rt.c rt_dom_cntl( · line 1631
Quoted 10 lines
xen/common/sched/rt.c +7
-0+ period, budget); +if ( rc ) + { +spin_unlock_irqrestore (&prv->lock, flags); +break ; + } + svc->period = period; svc->budget = budget;if ( local_sched.u.rtds.flags & XEN_DOMCTL_SCHEDRT_extra )
Juergen
Re: [PATCH 2/5] xen/sched: rtds: enforce admission control in xl sched-rtds
Quoted 32 lines · Juergen Gross
Quoted 31 lines · Furkan Caliskan
xen/common/sched/rt.c +20
-0@@ -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++; + } +
Quoted 12 lines
xen/common/sched/rt.c rt_dom_cntl( · line 1560
Quoted 6 lines
xen/common/sched/rt.c +6
-0+ new_total = prv->utilization - dom_old_util + + (uint64_t )nr_units * new_util; + +if ( new_total > prv->utilization && new_total >rt_utilization_cap (d) ) + { + rc = -EINVAL ;Is EINVAL a good choice here? I think a different error code might be wanted.
Quoted 3 lines
xen/common/sched/rt.c +3
-0+spin_unlock_irqrestore (&prv->lock, flags); +break ; + }
Additionally please unlock first, then set rc. The compiler may do such a rearrangement, but it also may not.
Jan
Re: [PATCH 2/5] xen/sched: rtds: enforce admission control in xl sched-rtds
In reply to Juergen GrossQuoted 52 lines · Juergen Gross
Quoted 51 lines · Furkan Caliskan
Now that we have introduced admission control for new and removed units. Extend it to
XEN_DOMCTL_SCHEDOP_putinfoand 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_admission_test()directly.Signed-off-by Furkan Caliskan <[email protected]>---
xen/common/sched/rt.c| 42 ++++++++++++++++++++++++++++++++++++++++++1 file changed, 42 insertions(+)xen/common/sched/rt.c +0
-0@@ -1527,11 +1527,43 @@ rt_dom_cntl( op->u.rtds.budget = RTDS_DEFAULT_BUDGET / MICROSECS(1); break;case
XEN_DOMCTL_SCHEDOP_putinfo:
+ {
+uint64_tdom_old_util= 0,new_util,new_total; + unsigned intnr_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);xen/common/sched/rt.c +14
-0+ + /* + * 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++; + } +
Quoted 8 lines
Quoted 6 lines
+
new_total=prv->utilization-dom_old_util+
+ (uint64_t)nr_units *new_util;
+
+ if (new_total>prv->utilization&&new_total>rt_utilization_cap(d)) + {
+ rc =-EINVAL;Is EINVAL a good choice here? I think a different error code might be wanted.
Would EBUSY be okay here? Or what else would you suggest?
Quoted 28 lines
Quoted 28 lines
+
spin_unlock_irqrestore(&prv->lock, flags); + break;
+ }xen/common/sched/rt.c +3
-0+ + prv->utilization = new_total; +
for_each_sched_unit( d, unit )
{
svc =rt_unit(unit);xen/common/sched/rt.c +1
-0@@ -1540,6 +1572,7 @@ rt_dom_cntl( } spin_unlock_irqrestore(&prv->lock, flags); break; + }case
XEN_DOMCTL_SCHEDOP_getvcpuinfo:
caseXEN_DOMCTL_SCHEDOP_putvcpuinfo:
while ( index <op->u.v.nr_vcpus)xen/common/sched/rt.c +7
-0@@ -1584,6 +1617,15 @@ rt_dom_cntl( spin_lock_irqsave(&prv->lock, flags); svc = rt_unit(d->vcpu[local_sched.vcpuid]->sched_unit); + + rc = rt_admission_test(prv, d, svc->period, svc->budget, + period, budget); + if ( rc ) + { + spin_unlock_irqrestore(&prv->lock, flags); + break;
Quoted 8 lines
xen/common/sched/rt.c rt_dom_cntl( · line 1631
Quoted 5 lines
xen/common/sched/rt.c +2
-0+ } + svc->period = period; svc->budget = budget; if ( local_sched.u.rtds.flags & XEN_DOMCTL_SCHEDRT_extra )Juergen
Furkan
Re: [PATCH 2/5] xen/sched: rtds: enforce admission control in xl sched-rtds
Quoted 63 lines · Furkan Çalışkan
Quoted 52 lines · Juergen Gross
Quoted 51 lines · Furkan Caliskan
Now that we have introduced admission control for new and removed units. Extend it to
XEN_DOMCTL_SCHEDOP_putinfoand 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_admission_test()directly.Signed-off-by Furkan Caliskan <[email protected]>--- xen/common/sched/rt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)xen/common/sched/rt.c +19
-0@@ -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++; + } +Quoted 8 lines
xen/common/sched/rt.c rt_dom_cntl( · line 1560
Quoted 6 lines
xen/common/sched/rt.c +6
-0+ new_total = prv->utilization - dom_old_util + + (uint64_t)nr_units * new_util; + + if ( new_total > prv->utilization && new_total > rt_utilization_cap(d) ) + { + rc = -EINVAL;Is EINVAL a good choice here? I think a different error code might be wanted.
Quoted 1 line
Would EBUSY be okay here? Or what else would you suggest?
EBUSY is a liitle bit better. What do you think about ENOSPC?
Juergen
Re: [PATCH 2/5] xen/sched: rtds: enforce admission control in xl sched-rtds
Quoted 64 lines · Jürgen Groß
Quoted 63 lines · Furkan Çalışkan
Quoted 60 lines · Juergen Gross
Quoted 47 lines · Furkan Caliskan
Now that we have introduced admission control for new and removed units. Extend it to
XEN_DOMCTL_SCHEDOP_putinfoand 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_admission_test()directly.Signed-off-by Furkan Caliskan <[email protected]>---
xen/common/sched/rt.c| 42 ++++++++++++++++++++++++++++++++++++++++++1 file changed, 42 insertions(+)xen/common/sched/rt.c +0
-0@@ -1527,11 +1527,43 @@ rt_dom_cntl( op->u.rtds.budget = RTDS_DEFAULT_BUDGET / MICROSECS(1); break;case
XEN_DOMCTL_SCHEDOP_putinfo:
+ {
+uint64_tdom_old_util= 0,new_util,new_total; + unsigned intnr_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);xen/common/sched/rt.c +10
-0+ + /* + * 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);xen/common/sched/rt.c rt_dom_cntl( · line 1560
Quoted 10 lines
xen/common/sched/rt.c +10
-0+ 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) ) + { + rc = -EINVAL;Is EINVAL a good choice here? I think a different error code might be wanted.
Quoted 6 lines
Quoted 1 line
Would EBUSY be okay here? Or what else would you suggest?
EBUSY is a liitle bit better. What do you think about ENOSPC?
Juergen
ENOSPC sounds good to me, I'll go with that.
Thanks,
Furkan
PATCH 3/5 xen/sched: rtds: report utilization and cap via debug key
In reply to Furkan CaliskanPrint a cpupool's admitted utilization against its capacity in the 'r' debug ky (xl debug-keys r), so an operator can see the total usage of a cpupool.
--- xen/common/sched/rt.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
xen/common/sched/rt.c +10 -0
@@ -399,12 +399,22 @@ rt_dump(const struct scheduler *ops)const struct rt_unit *svc;const struct rt_dom *sdom;unsigned long flags; +uint64_t cap;spin_lock_irqsave (&prv->lock, flags);if (list_empty (&prv->sdom) ) goto out; + cap = (uint64_t )cpumask_weight (ops->cpupool->res_valid) * +RTDS_UTIL_SCALE *RTDS_UTIL_CAP_PCT /100 ; + +if ( cap ) +printk ("Utilization: %llu%% of capacity\n" , + (unsigned long long )(prv->utilization *100 / cap)); +else +printk ("Utilization: cpupool has no capacity\n" ); + runq =rt_runq (ops); depletedq =rt_depletedq (ops); replq =rt_replq (ops);
Signature · 1 line
2.34.1
Re: [PATCH 3/5] xen/sched: rtds: report utilization and cap via debug key
Quoted 26 lines · Furkan Caliskan
Print a cpupool's admitted utilization against its capacity in the 'r' debug ky (xl debug-keys r), so an operator can see the total usage of a cpupool.
Signed-off-by Furkan Caliskan <[email protected]>--- xen/common/sched/rt.c | 10 ++++++++++ 1 file changed, 10 insertions(+)xen/common/sched/rt.c +3
-0@@ -399,12 +399,22 @@ rt_dump(const struct scheduler *ops)const struct rt_unit *svc;const struct rt_dom *sdom;unsigned long flags; +uint64_t cap;spin_lock_irqsave (&prv->lock, flags);if (list_empty (&prv->sdom) ) goto out; + cap = (uint64_t )cpumask_weight (ops->cpupool->res_valid) * +RTDS_UTIL_SCALE *RTDS_UTIL_CAP_PCT /100 ;
xen/common/sched/rt.c rt_dump(const struct scheduler *ops) · line 420
Quoted 10 lines
xen/common/sched/rt.c +7
-0+ +if ( cap ) +printk ("Utilization: %llu%% of capacity\n" , + (unsigned long long )(prv->utilization *100 / cap)); +else +printk ("Utilization: cpupool has no capacity\n" ); + runq =rt_runq (ops); depletedq =rt_depletedq (ops); replq =rt_replq (ops);
Juergen
PATCH 4/5 xen/sched: rtds: make admission control cpupool-wide toggleable
In reply to Furkan CaliskanAdd a per-cpupool on/off switch for RTDS admission control via XEN_SYSCTL_scheduler_op, enabled by default, so an operator can disable/enable enforcement for a pool.
--- xen/common/sched/rt.c | 56 ++++++++++++++++++++++++++++++++++--- xen/include/public/sysctl.h | 5 ++++ 2 files changed, 57 insertions(+), 4 deletions(-)
xen/common/sched/rt.c +52 -4
@@ -216,6 +216,8 @@ struct rt_private {/* Sum of admitted units' (budget/period), scaled by RTDS_UTIL_SCALE */ uint64_t utilization; + +bool admission_control_enabled;/* on/off flag for admission control. */ };/*
@@ -409,6 +411,9 @@ rt_dump(const struct scheduler *ops) cap = (uint64_t )cpumask_weight (ops->cpupool->res_valid) *RTDS_UTIL_SCALE *RTDS_UTIL_CAP_PCT /100 ; +printk ("Admission control: %s\n" , + prv->admission_control_enabled ?"enabled" :"disabled" ); +if ( cap )printk ("Utilization: %llu%% of capacity\n" , (unsigned long long )(prv->utilization *100 / cap));
@@ -694,8 +699,8 @@ rt_utilization_cap(const struct domain *d)/* * Replaces a unit's reservation and updates prv->utilization * to match. Growth that would push utilization over the -* cpupool's cap is refused. Removing a unit or shrinking -* a unit's reservation always succeed. +* cpupool's cap is refused if admission control is enabled. +* Removing a unit or shrinking a unit's reservation always succeed. */ static int rt_admission_test(struct rt_private *prv, const struct domain *d,
@@ -706,7 +711,8 @@ rt_admission_test(struct rt_private *prv, const struct domain *d,uint64_t new_util =rt_unit_utilization (new_period, new_budget);uint64_t total = prv->utilization - old_util + new_util; -if ( new_util > old_util && total >rt_utilization_cap (d) ) +if ( prv->admission_control_enabled && + new_util > old_util && total >rt_utilization_cap (d) )return -EINVAL ; prv->utilization = total;
@@ -773,6 +779,7 @@ rt_init(struct scheduler *ops)INIT_LIST_HEAD (&prv->runq);INIT_LIST_HEAD (&prv->depletedq);INIT_LIST_HEAD (&prv->replq); + prv->admission_control_enabled = true; ops->sched_data = prv; rc =0 ;
@@ -1565,8 +1572,14 @@ rt_dom_cntl( new_total = prv->utilization - dom_old_util + (uint64_t )nr_units * new_util; -if ( new_total > prv->utilization && new_total >rt_utilization_cap (d) ) +if ( prv->admission_control_enabled && + new_total > prv->utilization && new_total >rt_utilization_cap (d) ) { +printk (XENLOG_WARNING +"RTDS: ADMISSION CONTROL: refusing d%d," +" would exceed utilization capacity of the cpupool\n" , + d->domain_id); + rc = -EINVAL ;spin_unlock_irqrestore (&prv->lock, flags);break ;
@@ -1632,6 +1645,11 @@ rt_dom_cntl( period, budget);if ( rc ) { +printk (XENLOG_WARNING +"RTDS: ADMISSION CONTROL: refusing vcpu %u of d%d," +" would exceed utilization capacity of the cpupool\n" , + local_sched.vcpuid, d->domain_id); +spin_unlock_irqrestore (&prv->lock, flags);break ; }
@@ -1691,6 +1709,33 @@ rt_dom_cntl(return rc; } +#ifdef CONFIG_SYSCTL +static int cf_check +rt_sys_cntl (const struct scheduler *ops, +struct xen_sysctl_scheduler_op *sc) +{ +struct xen_sysctl_rtds_schedule *params = &sc->u.sched_rtds; +struct rt_private *prv =rt_priv (ops); +unsigned long flags; + +switch ( sc->cmd ) + { +case XEN_SYSCTL_SCHEDOP_putinfo: +spin_lock_irqsave (&prv->lock, flags); + prv->admission_control_enabled = params->admission_control_enabled; +spin_unlock_irqrestore (&prv->lock, flags); +break ; +case XEN_SYSCTL_SCHEDOP_getinfo: +spin_lock_irqsave (&prv->lock, flags); + params->admission_control_enabled = prv->admission_control_enabled; +spin_unlock_irqrestore (&prv->lock, flags); +break ; + } + +return 0 ; +} +#endif +/* * The replenishment timer handler picks units * from the replq and does the actual replenishment.
@@ -1791,6 +1836,9 @@ static const struct sched_ops sched_rtds_def = { .remove_unit = rt_unit_remove, .adjust = rt_dom_cntl, +#ifdef CONFIG_SYSCTL + .adjust_global = rt_sys_cntl, +#endif .pick_resource = rt_res_pick, .do_schedule = rt_schedule,
xen/include/public/sysctl.h +5 -0
@@ -814,6 +814,10 @@ struct xen_sysctl_credit2_schedule {uint32_t ratelimit_us; }; +struct xen_sysctl_rtds_schedule { +bool admission_control_enabled; +}; +/* XEN_SYSCTL_scheduler_op */ /* Set or get info? */ #define XEN_SYSCTL_SCHEDOP_putinfo 0
@@ -828,6 +832,7 @@ struct xen_sysctl_scheduler_op { } sched_arinc653;struct xen_sysctl_credit_schedule sched_credit;struct xen_sysctl_credit2_schedule sched_credit2; +struct xen_sysctl_rtds_schedule sched_rtds; } u; };
Signature · 1 line
2.34.1
Re: [PATCH 4/5] xen/sched: rtds: make admission control cpupool-wide toggleable
Quoted 16 lines · Furkan Caliskan
xen/common/sched/rt.c +12
-0@@ -1691,6 +1709,33 @@ rt_dom_cntl(return rc; } +#ifdef CONFIG_SYSCTL +static int cf_check +rt_sys_cntl (const struct scheduler *ops, +struct xen_sysctl_scheduler_op *sc) +{ +struct xen_sysctl_rtds_schedule *params = &sc->u.sched_rtds; +struct rt_private *prv =rt_priv (ops); +unsigned long flags; + +switch ( sc->cmd ) + { +case XEN_SYSCTL_SCHEDOP_putinfo:
xen/common/sched/rt.c rt_dom_cntl( · line 1733
Quoted 10 lines
xen/common/sched/rt.c +10
-0+spin_lock_irqsave (&prv->lock, flags); + prv->admission_control_enabled = params->admission_control_enabled; +spin_unlock_irqrestore (&prv->lock, flags); +break ; +case XEN_SYSCTL_SCHEDOP_getinfo: +spin_lock_irqsave (&prv->lock, flags); + params->admission_control_enabled = prv->admission_control_enabled; +spin_unlock_irqrestore (&prv->lock, flags); +break ; + }
Blank line please between non-fall-through case blocks.
xen/include/public/sysctl.h struct xen_sysctl_credit2_schedule { · line 819
Quoted 9 lines
xen/include/public/sysctl.h +3
-0@@ -814,6 +814,10 @@ struct xen_sysctl_credit2_schedule {uint32_t ratelimit_us; }; +struct xen_sysctl_rtds_schedule { +bool admission_control_enabled; +};
In the public headers only fixed-width types may be used. The width of bool is ABI-dependent (no matter that it's exceedingly unlikely to ever be other than the same size as char).
Jan
Re: [PATCH 4/5] xen/sched: rtds: make admission control cpupool-wide toggleable
Quoted 44 lines · Jan Beulich
Quoted 16 lines · Furkan Caliskan
xen/common/sched/rt.c +12
-0@@ -1691,6 +1709,33 @@ rt_dom_cntl(return rc; } +#ifdef CONFIG_SYSCTL +static int cf_check +rt_sys_cntl (const struct scheduler *ops, +struct xen_sysctl_scheduler_op *sc) +{ +struct xen_sysctl_rtds_schedule *params = &sc->u.sched_rtds; +struct rt_private *prv =rt_priv (ops); +unsigned long flags; + +switch ( sc->cmd ) + { +case XEN_SYSCTL_SCHEDOP_putinfo:xen/common/sched/rt.c rt_dom_cntl( · line 1733
Quoted 10 lines
xen/common/sched/rt.c +10
-0+spin_lock_irqsave (&prv->lock, flags); + prv->admission_control_enabled = params->admission_control_enabled; +spin_unlock_irqrestore (&prv->lock, flags); +break ; +case XEN_SYSCTL_SCHEDOP_getinfo: +spin_lock_irqsave (&prv->lock, flags); + params->admission_control_enabled = prv->admission_control_enabled; +spin_unlock_irqrestore (&prv->lock, flags); +break ; + }Blank line please between non-fall-through case blocks.
xen/include/public/sysctl.h struct xen_sysctl_credit2_schedule { · line 819
Quoted 9 lines
xen/include/public/sysctl.h +3
-0@@ -814,6 +814,10 @@ struct xen_sysctl_credit2_schedule {uint32_t ratelimit_us; }; +struct xen_sysctl_rtds_schedule { +bool admission_control_enabled; +};In the public headers only fixed-width types may be used. The width of bool is ABI-dependent (no matter that it's exceedingly unlikely to ever be other than the same size as char).
Quoted 1 line
Jan
Thanks, I'll fix these in v2.
Furkan
Re: [PATCH 4/5] xen/sched: rtds: make admission control cpupool-wide toggleable
In reply to Furkan CaliskanQuoted 5 lines · Furkan Caliskan
Add a per-cpupool on/off switch for RTDS admission control via
XEN_SYSCTL_scheduler_op, enabled by default, so an operator can disable/enable enforcement for a pool.Signed-off-by Furkan Caliskan <[email protected]>
No remarks from me additional to Jan's.
Juergen
PATCH 5/5 tools: expose admission control toggle via xl sched-rtds
In reply to Furkan CaliskanWire the per-cpupool admission-control switch through libxl to xl sched-rtds, and document it.
Add -s/--schedparam to list or set pool-wide RTDS scheduler parameters, and -a/--admission to enable or disable admission control for a cpupool ("-c pool -s -a 0/1").
--- docs/man/xl.1.pod.in | 20 ++++++ tools/golang/xenlight/helpers.gen.go | 23 ++++++ tools/golang/xenlight/types.gen.go | 4 ++ tools/include/libxl.h | 4 ++ tools/include/xenctrl.h | 6 ++ tools/libs/ctrl/xc_rt.c | 40 +++++++++++ tools/libs/light/libxl_sched.c | 46 ++++++++++++ tools/libs/light/libxl_types.idl | 5 ++ tools/xl/xl_cmdtable.c | 8 ++- tools/xl/xl_sched.c | 103 +++++++++++++++++++++++++-- 10 files changed, 254 insertions(+), 5 deletions(-)
docs/man/xl.1.pod.in +20 -0
@@ -1230,6 +1230,16 @@ the unreserved system resource. Restrict output to domains in the specified cpupool. +=item B<-s>, B<--schedparam> + +Specify to list or set pool-wide scheduler parameters. + +=item B<-a ADMISSION_CONTROL>, B<--admission=ADMISSION_CONTROL> + +Binary flag to enable or disable admission control for the cpupool. +When enabled (the default), a reservation is rejected if admitting +it would exceed the cpupool's utilization capacity. + =back B<EXAMPLE>
@@ -1293,6 +1303,16 @@ e.g., "xl sched-rtds -d vm1 -v 0 -p 100 -b 50 -e 1 -v 3 -p 300 -b 150 -e 0". To change the parameters of all the VCPUs of a domain, use B<-v all>, e.g., "xl sched-rtds -d vm1 -v all -p 500 -b 250 -e 1". +4) Use B<-c CPUPOOL -s> to see whether admission control is enabled +for a cpupool, and B<-c CPUPOOL -s -a> to change it: + + xl sched-rtds -c pool-rt -s + Cpupool pool-rt: sched=RTDS admission-control=enabled + + xl sched-rtds -c pool-rt -s -a 0 + xl sched-rtds -c pool-rt -s + Cpupool pool-rt: sched=RTDS admission-control=disabled + =back =back
tools/golang/xenlight/helpers.gen.go +23 -0
@@ -4192,6 +4192,29 @@ func (x *SchedCredit2Params) toC(xc *C.libxl_sched_credit2_params) (err error){x return nil } +// NewSchedRtdsParams returns an instance of SchedRtdsParams initialized with defaults. +func NewSchedRtdsParams() (*SchedRtdsParams, error) { +var ( +x SchedRtdsParams +xc C.libxl_sched_rtds_params) + +C.libxl_sched_rtds_params_init(&xc) + +if err := x.fromC(&xc); err != nil { +return nil, err } + +return &x, nil} + +func (x *SchedRtdsParams) fromC(xc *C.libxl_sched_rtds_params) error { + x.AdmissionControlEnabled = bool(xc.admission_control_enabled) + + return nil} + +func (x *SchedRtdsParams) toC(xc *C.libxl_sched_rtds_params) (err error){xc.admission_control_enabled = C.bool(x.AdmissionControlEnabled) + + return nil + } + // NewDomainRemusInfo returns an instance of DomainRemusInfo initialized with defaults. func NewDomainRemusInfo() (*DomainRemusInfo, error) { var (
tools/golang/xenlight/types.gen.go +4 -0
@@ -1231,6 +1231,10 @@ type SchedCredit2Params struct { RatelimitUs int } +type SchedRtdsParams struct { +AdmissionControlEnabled bool +} + type DomainRemusInfo struct { Interval int AllowUnsafe Defbool
tools/include/libxl.h +4 -0
@@ -2797,6 +2797,10 @@ int libxl_sched_credit2_params_get(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit2_params *scinfo);int libxl_sched_credit2_params_set (libxl_ctx *ctx,uint32_t poolid,libxl_sched_credit2_params *scinfo); +int libxl_sched_rtds_params_get (libxl_ctx *ctx,uint32_t poolid, +libxl_sched_rtds_params *scinfo); +int libxl_sched_rtds_params_set (libxl_ctx *ctx,uint32_t poolid, +libxl_sched_rtds_params *scinfo);/* Scheduler Per-domain parameters */
tools/include/xenctrl.h +6 -0
@@ -897,6 +897,12 @@ int xc_sched_rtds_vcpu_get(xc_interface *xch,uint32_t domid, struct xen_domctl_schedparam_vcpu *vcpus, uint32_t num_vcpus); +int xc_sched_rtds_params_set (xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_rtds_schedule *schedule); +int xc_sched_rtds_params_get (xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_rtds_schedule *schedule);int xc_sched_arinc653_schedule_set(
tools/libs/ctrl/xc_rt.c +40 -0
@@ -130,3 +130,43 @@ int xc_sched_rtds_vcpu_get(xc_interface *xch,return rc; } + +int xc_sched_rtds_params_set (xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_rtds_schedule *schedule) +{ +struct xen_sysctl sysctl = {}; + + sysctl.cmd = XEN_SYSCTL_scheduler_op; + sysctl.u.scheduler_op.cpupool_id = cpupool_id; + sysctl.u.scheduler_op.sched_id =XEN_SCHEDULER_RTDS ; + sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_putinfo; + + sysctl.u.scheduler_op.u.sched_rtds = *schedule; + +if (do_sysctl (xch, &sysctl) ) +return -1 ; + + *schedule = sysctl.u.scheduler_op.u.sched_rtds; + +return 0 ; +} + +int xc_sched_rtds_params_get (xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_rtds_schedule *schedule) +{ +struct xen_sysctl sysctl = {}; + + sysctl.cmd = XEN_SYSCTL_scheduler_op; + sysctl.u.scheduler_op.cpupool_id = cpupool_id; + sysctl.u.scheduler_op.sched_id =XEN_SCHEDULER_RTDS ; + sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_getinfo; + +if (do_sysctl (xch, &sysctl) ) +return -1 ; + + *schedule = sysctl.u.scheduler_op.u.sched_rtds; + +return 0 ; +}
tools/libs/light/libxl_sched.c +46 -0
52 lines not on this page · raw message
tools/libs/light/libxl_types.idl +5 -0
@@ -1286,6 +1286,11 @@ libxl_sched_credit2_params = Struct("sched_credit2_params", [ ("ratelimit_us", integer), ], dispose_fn=None) +libxl_sched_rtds_params = Struct("sched_rtds_params", [ + ("admission_control_enabled", bool), + ], dispose_fn=None) + + libxl_domain_remus_info = Struct("domain_remus_info",[ ("interval", integer), ("allow_unsafe", libxl_defbool),
tools/xl/xl_cmdtable.c +7 -1
@@ -295,13 +295,19 @@ const struct cmd_spec cmd_table[] = { {"sched-rtds" , &main_sched_rtds,0 ,1 ,"Get/set rtds scheduler parameters" , -"[-d <Domain> [-v[=VCPUID/all]] [-p[=PERIOD]] [-b[=BUDGET]] [-e[=Extratime]]]" , +"[-d <Domain> [-v[=VCPUID/all]] [-p[=PERIOD]] [-b[=BUDGET]] [-e[=Extratime]]]\n" +" [-c <Cpupool> -s [-a[=ADMISSION_CONTROL]]]" ,"-d DOMAIN, --domain=DOMAIN Domain to modify\n" "-v VCPUID/all, --vcpuid=VCPUID/all VCPU to modify or output;\n" " Using '-v all' to modify/output all vcpus\n" "-p PERIOD, --period=PERIOD Period (us)\n" "-b BUDGET, --budget=BUDGET Budget (us)\n" "-e Extratime, --extratime=Extratime Extratime (1=yes, 0=no)\n" +"-c CPUPOOL, --cpupool=CPUPOOL Restrict output to domains in CPUPOOL\n" +"-s, --schedparam List or set pool-wide scheduler parameters\n" +"-a ADMISSION_CONTROL, --admission=ADMISSION_CONTROL\n" +" Enable or disable admission control for the cpupool\n" +" (1=enabled, 0=disabled); requires -s\n" }, { "domid", &main_domid, 0, 0,
tools/xl/xl_sched.c +99 -4
156 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 34 lines · Furkan Caliskan
RTDS currently has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, the global-EDF deadline guarantees the scheduler is built around no longer hold for any unit sharing that pool.
This series adds admission control to prevent that, tracks and report utilization, and makes the check toggleable per cpupool so an operator can disable it if they intentionally want to overcommit.
Patch 1 introduces the core mechanism: a running utilization total per cpupool, a fixed-point representation of a unit's (budget/period), and a capacity check enforced in rt_alloc_udata()/rt_free_udata() - the lifecycle hooks that catch every new unit's default reservation.
Patch 2 extends the same check to domctl, so growing an existing reservation via xl sched-rtds is checked too.
Patch 3 reports a cpupool's admitted utilization agains its capacity via the 'r' debug key.
Patch 4 makes admission control itself toggleable per cpupool (enabled by default) via sysctl.
Patch 5 wires that toggle through libxl and adds -s/-a to xl sched-rtds, and documents it.
Furkan Caliskan (5):
xen/sched: rtds: add global-EDF utilization admission control xen/sched: rtds: enforce admission control in xl sched-rtds xen/sched: rtds: report utilization and cap via debug key xen/sched: rtds: make admission control cpupool-wide toggleable
tools: expose admission control toggle via xl sched-rtds
Quoted 14 lines
docs/man/xl.1.pod.in | 20 +++ tools/golang/xenlight/helpers.gen.go | 23 +++ tools/golang/xenlight/types.gen.go | 4 + tools/include/libxl.h | 4 + tools/include/xenctrl.h | 6 + tools/libs/ctrl/xc_rt.c | 40 ++++++ tools/libs/light/libxl_sched.c | 46 ++++++ tools/libs/light/libxl_types.idl | 5 + tools/xl/xl_cmdtable.c | 8 +- tools/xl/xl_sched.c | 103 +++++++++++++- xen/common/sched/rt.c | 205 ++++++++++++++++++++++++++- xen/include/public/sysctl.h | 5 + 12 files changed, 463 insertions(+), 6 deletions(-)
Hi Juergen,
Can I get a review on this series please?
Thanks,
Furkan
Quoted 51 lines · Furkan Çalışkan
Quoted 34 lines · Furkan Caliskan
RTDS currently has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, the global-EDF deadline guarantees the scheduler is built around no longer hold for any unit sharing that pool.
This series adds admission control to prevent that, tracks and report utilization, and makes the check toggleable per cpupool so an operator can disable it if they intentionally want to overcommit.
Patch 1 introduces the core mechanism: a running utilization total per cpupool, a fixed-point representation of a unit's (budget/period), and a capacity check enforced in rt_alloc_udata()/rt_free_udata() - the lifecycle hooks that catch every new unit's default reservation.
Patch 2 extends the same check to domctl, so growing an existing reservation via xl sched-rtds is checked too.
Patch 3 reports a cpupool's admitted utilization agains its capacity via the 'r' debug key.
Patch 4 makes admission control itself toggleable per cpupool (enabled by default) via sysctl.
Patch 5 wires that toggle through libxl and adds -s/-a to xl sched-rtds, and documents it.
Furkan Caliskan (5):
xen/sched: rtds: add global-EDF utilization admission control xen/sched: rtds: enforce admission control in xl sched-rtds xen/sched: rtds: report utilization and cap via debug key xen/sched: rtds: make admission control cpupool-wide toggleable
tools: expose admission control toggle via xl sched-rtdsQuoted 14 lines
docs/man/xl.1.pod.in | 20 +++ tools/golang/xenlight/helpers.gen.go | 23 +++ tools/golang/xenlight/types.gen.go | 4 + tools/include/libxl.h | 4 + tools/include/xenctrl.h | 6 + tools/libs/ctrl/xc_rt.c | 40 ++++++ tools/libs/light/libxl_sched.c | 46 ++++++ tools/libs/light/libxl_types.idl | 5 + tools/xl/xl_cmdtable.c | 8 +- tools/xl/xl_sched.c | 103 +++++++++++++- xen/common/sched/rt.c | 205 ++++++++++++++++++++++++++- xen/include/public/sysctl.h | 5 + 12 files changed, 463 insertions(+), 6 deletions(-)
Quoted 3 lines
Hi Juergen,
Can I get a review on this series please?
I was quite busy preparing for Xen summit. I'm planning to do the review on the train to Munich. :-)
Juergen
Quoted 54 lines · Jürgen Groß
Quoted 53 lines · Furkan Çalışkan
Quoted 46 lines · Furkan Caliskan
RTDS currently has no admission control: nothing stops the sum of all admitted units' (budget/period) reservations in a cpupool from exceeding what its pCPUs can actually provide. Once that happens, the global-EDF deadline guarantees the scheduler is built around no longer hold for any unit sharing that pool.
This series adds admission control to prevent that, tracks and report utilization, and makes the check toggleable per cpupool so an operator can disable it if they intentionally want to overcommit.
Patch 1 introduces the core mechanism: a running utilization total per cpupool, a fixed-point representation of a unit's (budget/period), and a capacity check enforced in rt_alloc_udata()/rt_free_udata() - the lifecycle hooks that catch every new unit's default reservation.
Patch 2 extends the same check to domctl, so growing an existing reservation via xl sched-rtds is checked too.
Patch 3 reports a cpupool's admitted utilization agains its capacity via the 'r' debug key.
Patch 4 makes admission control itself toggleable per cpupool (enabled by default) via sysctl.
Patch 5 wires that toggle through libxl and adds -s/-a to xl sched-rtds, and documents it.
Furkan Caliskan (5):
xen/sched: rtds: add global-EDF utilization admission control xen/sched: rtds: enforce admission control in xl sched-rtds xen/sched: rtds: report utilization and cap via debug key xen/sched: rtds: make admission control cpupool-wide toggleable
tools: expose admission control toggle via xl sched-rtdsdocs/man/xl.1.pod.in | 20 +++
tools/golang/xenlight/helpers.gen.go| 23 +++ tools/golang/xenlight/types.gen.go | 4 + tools/include/libxl.h | 4 + tools/include/xenctrl.h | 6 + tools/libs/ctrl/xc_rt.c | 40 ++++++ tools/libs/light/libxl_sched.c | 46 ++++++ tools/libs/light/libxl_types.idl | 5 + tools/xl/xl_cmdtable.c | 8 +- tools/xl/xl_sched.c | 103 +++++++++++++- xen/common/sched/rt.c | 205 ++++++++++++++++++++++++++- xen/include/public/sysctl.h | 5 +Quoted 2 lines
12 files changed, 463 insertions(+), 6 deletions(-)Hi Juergen,
Quoted 7 lines
Quoted 1 line
Can I get a review on this series please?
I was quite busy preparing for Xen summit. I'm planning to do the review on the train to Munich. :-)
Juergen
Okay, thanks
Furkan