From nobody Thu Sep 24 19:04:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1789719010; cv=none; d=zohomail.com; s=zohoarc; b=hl34TSsOUV5sFi7hLZPe3ZCn3mSxZ9WFlQeZF3k8Qy78+PIE8FJYrb9JyA82oWISkJKYRIkw4YBJDtAKd0wiKy3LCYkV6aiXh91grOBNuQxvsRFWT2lD5lQxshyayln3/+Au0oY9Bx0lAQdl7yzq73vOdvt41ktpkjGhY8jrEGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789719010; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+D5EjjhGdVeYfpgBtQwACc7NrGO8erRw97egY4pDHIA=; b=BshytjwGYEom/BAX4A3wEKuqPDXyo0rsSiaD4es+T0rBsgCXdectbHV1ss3xVVk1T8eKmZPY0SWIxBc4YhrjFcFdGpFqfxkI8JE8EGnga/9R4MQmKzwGL1UMnvRh2dCTv33BUHvgqWWntBK6eQ+2YuG5zQOvcGBnPStgkJRS8FY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789719010653125.43544649760531; Fri, 18 Sep 2026 01:10:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1424860.1649078 (Exim 4.92) (envelope-from ) id 1x7TfT-0001ne-8i; Fri, 18 Sep 2026 08:09:59 +0000 Received: by outflank-mailman (output) from mailman id 1424860.1649078; Fri, 18 Sep 2026 08:09:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7TfT-0001nV-5j; Fri, 18 Sep 2026 08:09:59 +0000 Received: by outflank-mailman (input) for mailman id 1424860; Fri, 18 Sep 2026 08:09:58 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7TfS-0001ms-9w for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 08:09:58 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x7TfR-008Sfx-N5 for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 10:09:57 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aacf1ce-e002-0a2a0a5209dd-0a2a45048800-20 for ; Fri, 18 Sep 2026 10:09:57 +0200 Received: from [74.125.225.140] (helo=mail-wm2-f12.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aacf1d5-b57f-0a2a45040019-4a7de18ca119-3 for ; Fri, 18 Sep 2026 10:09:57 +0200 Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49b912d3920so3128395e9.1 for ; Fri, 18 Sep 2026 01:09:57 -0700 (PDT) Received: from notebook.. ([88.230.43.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48720083c19sm2174133f8f.31.2026.09.18.01.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:09:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789718997; x=1790323797; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+D5EjjhGdVeYfpgBtQwACc7NrGO8erRw97egY4pDHIA=; b=MdnVsE9jDsItahxS0hAy6S6ILGz7hm2Sv8F+uFBZQaCGk3b7KFwETLGeldGlCzHCu7 0I/LsSYJRQ8SDzmExPDvPlHxDF0/sPKwTSZcCbjSP+bLDEDoI8EmbwBK0qNYlrv9oM3X rjw8h1IxCUv2X58+1k7LN825omub+rATNR9kTs9jL334sz3+dhwOraErjW3PoIWIBxd5 9gu8VDPsuULe+IxQBWlfXFr1ZMDcgt8QfRFpcbQhfCdzs+0LF4qfb/Jr1pA73rUugar6 qCa7Loz0bpLNRyTwbjU+WNWwkQ1qs8S/+H4evFMPQnZEEaRZXMXqB/rFmaVjkNwAvGVI rP/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789718997; x=1790323797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=+D5EjjhGdVeYfpgBtQwACc7NrGO8erRw97egY4pDHIA=; b=UJ5BYTEP/bFbnqGANGMP18qaMd7WYfdD8R2k4lG0KhJGSjV/prAeQudh4/6pIjR1ch DWq74eQA+wj9oDm9L2E6xbgiiwj+IJiNaRsgPEbJecCa7O1M+e/bLgAhpipPFihvrX4r OrDoTXzrEw9m3wy8CaYrA3j1gCFBC3MOxbglhKmord9VkQZ13roJBBOWDeZPBgoO/FYp DoJIUNvp/FXrmOBvLrX1JTn8tWPXIUeIoBHv1bNCy7stHKbee0QDfJibPdudCCMaRYOS qY6jdytPcUHgplONNO+kspbnzymI6P7NnK6LzK4+P571XrjlKucksPTN+ZNzXjO94Sx5 u6YA== X-Gm-Message-State: AFuF++mRJMFjFJmcFCKIhOnAcZqtaQ6BhgH89OmEreao8PDU4F9Lnnp4 10mFAeItQmPHsxJZdeX+X4XrcF35exIabdhYjN88c7OPdzxbJBUcF5VJ5RvIjA== X-Gm-Gg: AYBFou2Tj1JGCiU88njb7LqLWphqd36treL4iasEjAt0OCTWb+8DufXY8S2lLRLHAgO zyfDX6IWMeKJ/uQKLLMNcybID3HJcKKhSScbJY1s1J16cTjoAuOTHiEu+ffo/P+TXAP8k1wqApZ N8ZhrczZAdgR28KvrFNNSuA+N6cQpwagZ6qs+vsDdVWGyTkyRFDWel0l6ChNubERHOjJev1yIX2 ruzEwvlMh5U2KQaum4aPRkXYvlj9twScvYJdwu3iyE5NkkKFUzCtxwwgBHlbDtEszKWj7zkoco6 Z6kWIYYqKhzX9MWgLUI6YF9gFoHG6L66mXB7X1AcOeGnm0PiiNur9xZ84aYYBbfwbPwrFgOwSlI EiecgJ69FKFbXIsJU3llLHxmNc37RzdJCkc5BQCpGJtAivbQl++ebdIP76/TYQzG5SDjisFFZPv 0YIERdzIw2G93dYnYU5mDPTKCjTAxSJmt5qBMwT4uWl/MtXMHEU3614qIlDpsby7Dv/BQ/K6y08 MwU3AXsWw== X-Received: by 2002:a05:600c:138c:b0:49e:799a:8969 with SMTP id 5b1f17b1804b1-49fc574af20mr17055175e9.30.1789718996990; Fri, 18 Sep 2026 01:09:56 -0700 (PDT) From: Furkan Caliskan To: xen-devel@lists.xenproject.org Cc: jgross@suse.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger@xenproject.org, dfaggioli@suse.com, anthony.perard@vates.tech, julien@xen.org, Furkan Caliskan Subject: [PATCH v2 1/5] xen/sched: rtds: add global-EDF utilization admission control Date: Fri, 18 Sep 2026 11:09:31 +0300 Message-Id: <20260918080935.35498-2-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260918080935.35498-1-frn1furkan10@gmail.com> References: <20260918080935.35498-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1789718997-C2AC8B50-8B09FF18/0/0 X-purgate-type: clean X-purgate-size: 7316 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1789719011891158500 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Furkan Caliskan Reviewed-by: Juergen Gross --- v2: - Renamed rt_admission_test() to rt_try_set_utilization() and changed its return type from int to bool, since it doesn't just test but also commits the new utilization on success. --- xen/common/sched/rt.c | 105 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c index 0e9f04ea72..acebbbe57e 100644 --- a/xen/common/sched/rt.c +++ b/xen/common/sched/rt.c @@ -114,6 +114,24 @@ */ #define RTDS_MAX_PRIORITY_LEVEL (~0U) =20 +/* + * 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 findi= ng * 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 repleni= shment */ =20 cpumask_t tickled; /* cpus been tickled */ + + /* Sum of admitted units' (budget/period), scaled by RTDS_UTIL_SCALE */ + uint64_t utilization; }; =20 /* @@ -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); } =20 +/* + * budget << RTDS_UTIL_SHIFT can't overflow: rt_validate_params() + * caps budget at RTDS_MAX_BUDGET. period =3D=3D 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 <=3D 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 =3D 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 bool +rt_try_set_utilization(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 =3D rt_unit_utilization(old_period, old_budget); + uint64_t new_util =3D rt_unit_utilization(new_period, new_budget); + uint64_t total =3D prv->utilization - old_util + new_util; + + if ( new_util > old_util && total > rt_utilization_cap(d) ) + return false; + + prv->utilization =3D total; + + return true; +} + /* * 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_check rt_alloc_udata(const struct scheduler *ops, struct sched_unit *unit, void = *dd) { + struct rt_private *prv =3D rt_priv(ops); struct rt_unit *svc; =20 /* Allocate per-UNIT info */ @@ -881,9 +951,30 @@ rt_alloc_udata(const struct scheduler *ops, struct sch= ed_unit *unit, void *dd) __set_bit(__RTDS_extratime, &svc->flags); svc->priority_level =3D 0; svc->period =3D RTDS_DEFAULT_PERIOD; + if ( !is_idle_unit(unit) ) + { + unsigned long flags; + bool admitted; + svc->budget =3D RTDS_DEFAULT_BUDGET; =20 + spin_lock_irqsave(&prv->lock, flags); + admitted =3D rt_try_set_utilization(prv, unit->domain, 0, 0, + svc->period, svc->budget); + spin_unlock_irqrestore(&prv->lock, flags); + + if ( !admitted ) + { + 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); =20 return svc; @@ -892,8 +983,19 @@ rt_alloc_udata(const struct scheduler *ops, struct sch= ed_unit *unit, void *dd) static void cf_check rt_free_udata(const struct scheduler *ops, void *priv) { + struct rt_private *prv =3D rt_priv(ops); struct rt_unit *svc =3D priv; =20 + if ( svc && !is_idle_unit(svc->unit) ) + { + unsigned long flags; + + spin_lock_irqsave(&prv->lock, flags); + rt_try_set_utilization(prv, svc->unit->domain, + svc->period, svc->budget, 0, 0); + spin_unlock_irqrestore(&prv->lock, flags); + } + xfree(svc); } =20 @@ -1389,7 +1491,8 @@ rt_validate_params(const struct xen_domctl_sched_rtds= *rtds, s_time_t b =3D MICROSECS(rtds->budget); =20 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; =20 *period =3D p; --=20 2.34.1 From nobody Thu Sep 24 19:04:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1789719026; cv=none; d=zohomail.com; s=zohoarc; b=W9NpthDhhhNjDZ0BfBV74Epz7lSo8jhv/nwDrpM9LBu9I/Bv06zg+9LxgwTBP5aA3c/wy8sIB2OCPIEsq1uuf/zSMxEbjSOeG2vlaySMTy+P31KTw+XuOKO9b6QJHgbXSstMf0Tcp/q53LW6G67LYVDP/v8eV2A5V4ZL2T6ameE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789719026; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iQ/UHhRs/oHG8h8cgbtjbUFCoCrSiy2F1gF60N4pmIY=; b=ZY6BGHy+AjRX5pbT8ol/1BH/iGlYR+tAwNMqJTlzxesscMm/E0sBywUeMvIANFcLU4ERrWGbP6rgqqOnpM4KZTzWebK8imaVCjeQdgdXn2s+9qXPzKrRsnmOqAVHNHMNAhUrhk+7X7aJGs4L7YoQemrjGoSQhYb6XnuDAQCOmYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789719026631645.7612887350779; Fri, 18 Sep 2026 01:10:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1424862.1649088 (Exim 4.92) (envelope-from ) id 1x7TfX-0002Nw-IA; Fri, 18 Sep 2026 08:10:03 +0000 Received: by outflank-mailman (output) from mailman id 1424862.1649088; Fri, 18 Sep 2026 08:10:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7TfX-0002NW-Cd; Fri, 18 Sep 2026 08:10:03 +0000 Received: by outflank-mailman (input) for mailman id 1424862; Fri, 18 Sep 2026 08:10:02 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7TfW-00027S-KP for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 08:10:02 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x7TfV-003rgf-Hi for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 10:10:01 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aacf1cb-8faa-0a2a0a5109dd-0a2a450288be-40 for ; Fri, 18 Sep 2026 10:10:01 +0200 Received: from [74.125.225.76] (helo=mail-wr2-f12.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aacf1d9-6ca4-0a2a45020019-4a7de14cbc85-3 for ; Fri, 18 Sep 2026 10:10:01 +0200 Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-482f6350faaso225108f8f.0 for ; Fri, 18 Sep 2026 01:10:01 -0700 (PDT) Received: from notebook.. ([88.230.43.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48720083c19sm2174133f8f.31.2026.09.18.01.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:10:00 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789719001; x=1790323801; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iQ/UHhRs/oHG8h8cgbtjbUFCoCrSiy2F1gF60N4pmIY=; b=sfLLBW/R8y0at93WFhcddCN1BliksEKbbK2IkJDR8KCP8cyd8j1Jcveoa/eHfJJDGI EmW6nbnlbPPW72Wc0wjhO3lobxsV8KT/kUGnwFapfJx2PZn9xP8eZlw336ybqwrezYUA BJzl7zvroRS7g6ihfOMrP2TlvKa1xYzDhDcvLlwHUBPup1Ls7LjG9PUgfrXoDVpAAKy8 zuZ90Qnevzbj/07rldV5bvTCho192J+CUFGanuDuaO9r1YKiJ0JRRsL+bAspr2VJp51k eoyw3alZiIidzjpvDzt3frG8np/ucEBMMMHvLXayReFE8skrplPOSyXDmlK2la8DJoQC x/dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789719001; x=1790323801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=iQ/UHhRs/oHG8h8cgbtjbUFCoCrSiy2F1gF60N4pmIY=; b=ddJVuKENdV1+73egEWyDtCo+u2VKk/7nC9AVozScOuzbrGRjJF0QQnM07fQDqfRosn JsN8e3EAn98Zfqb7yloSWqbS3uIATDlOGD9n6i9UHiMRwemv5JF5o2b3E/D9HKvkCNow bu6eHqqwBZOWDG3ylwFn2oWDzs4of5RHI5JfW1y4zIEAtvzzCupVLCr2+QAWaTLYl+Bk SsAvrH3l7oQ1mhVUzY+c85lEDApWARrdnAsJz/ps3X/QZLGyNHfIzxcrWDA/B8HdvlzR +k4s3KU0uRQQMoJjDp62WebfJUDtJFyd29FEyTLtkXOi+CS38ymN8xEXw5Mlhw5ppI4w /R7w== X-Gm-Message-State: AFuF++kuuXDAL277wtCz4yTZH+xGU2ssGixQ/Q4oSAHcYRPpGzUZTSZm iwdi3Oc8IKoeYFnpAeIug/3HLNEd1VgmSNmLZ54h+qaHTM517+hPJzifUlQ6tw== X-Gm-Gg: AYBFou0k2U3QUMYutNCsuA5VNAgFFP58lSAn2JzDU3BeT+cwQtT54Fr1+Xdg6mUYDZ5 hAgMP3lv5NcdHILv2lEh1mliymWZn0D7MH+Zu8m7FEWAgWZH3x0BGIMwKdQwAkz0eGEj/WFKzfm ShTxj9Z2/HVkGYzKpjV7bHaztCtPqEVyjzLnrYd6atf2/JZYi1cojCRQf7OrWQxK3Kd13wutbVW xpNcj2YiNuxiEh9p/OL3sQTDbQBSEgzaf/al/wEpFyG/8jrVHNxVF2KRbye7he6vO3w8RLNJCB7 YlNrJESkjh05+sr5I1T6qDsg1ilDG0TQlI8FvfaIfDBZgnNY6lPpQLDchJi/DG25J9/7R5/1Q2R EUX0TutLDI5WO9/W6xLA5eN2Oq7cboR8W0pR/qsGDxXJACkeDOYbObWpXb/Q0SN4709/69cjOsT BEyJqJy6+NtbDmJe230NHtEn7dsSUVl48LBu2RKcSOMyTbKDKU2RQdEPKpUEuieRuSpoXugUo= X-Received: by 2002:a5d:64c8:0:b0:487:fb0:9ff with SMTP id ffacd0b85a97d-4871e2177a0mr2376821f8f.22.1789719000677; Fri, 18 Sep 2026 01:10:00 -0700 (PDT) From: Furkan Caliskan To: xen-devel@lists.xenproject.org Cc: jgross@suse.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger@xenproject.org, dfaggioli@suse.com, anthony.perard@vates.tech, julien@xen.org, Furkan Caliskan Subject: [PATCH v2 2/5] xen/sched: rtds: enforce admission control in xl sched-rtds Date: Fri, 18 Sep 2026 11:09:32 +0300 Message-Id: <20260918080935.35498-3-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260918080935.35498-1-frn1furkan10@gmail.com> References: <20260918080935.35498-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1789719001-67EBB2AC-C9E7D528/0/0 X-purgate-type: clean X-purgate-size: 3359 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1789719027932158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Juergen Gross --- v2: - Use ENOSPC instead of EINVAL. - Unlock prv->lock before setting rc, not after. --- 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 acebbbe57e..fbebd82c78 100644 --- a/xen/common/sched/rt.c +++ b/xen/common/sched/rt.c @@ -1527,11 +1527,43 @@ rt_dom_cntl( op->u.rtds.budget =3D RTDS_DEFAULT_BUDGET / MICROSECS(1); break; case XEN_DOMCTL_SCHEDOP_putinfo: + { + uint64_t dom_old_util =3D 0, new_util, new_total; + unsigned int nr_units =3D 0; + rc =3D rt_validate_params(&op->u.rtds, &period, &budget); if ( rc ) break; =20 + new_util =3D 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 =3D rt_unit(unit); + dom_old_util +=3D rt_unit_utilization(svc->period, svc->budget= ); + nr_units++; + } + + new_total =3D prv->utilization - dom_old_util + + (uint64_t)nr_units * new_util; + + if ( new_total > prv->utilization && new_total > rt_utilization_ca= p(d) ) + { + spin_unlock_irqrestore(&prv->lock, flags); + rc =3D -ENOSPC; + break; + } + + prv->utilization =3D new_total; + for_each_sched_unit ( d, unit ) { svc =3D 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( =20 spin_lock_irqsave(&prv->lock, flags); svc =3D rt_unit(d->vcpu[local_sched.vcpuid]->sched_unit); + + if ( !rt_try_set_utilization(prv, d, svc->period, svc->bud= get, + period, budget) ) + { + spin_unlock_irqrestore(&prv->lock, flags); + rc =3D -ENOSPC; + break; + } + svc->period =3D period; svc->budget =3D budget; if ( local_sched.u.rtds.flags & XEN_DOMCTL_SCHEDRT_extra ) --=20 2.34.1 From nobody Thu Sep 24 19:04:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1789719018; cv=none; d=zohomail.com; s=zohoarc; b=RSTdXDemkB6vhCUWr9Ug6NF3cEgvDltxgIGWRiMNpfBOC/v1FyPE7raPGCIlndIEKIfwbtcbEfQwj0QNYSFu4TBs+1u3qT4oIFkgRpckgfN5oNucaE5Hoi4l78m1LuOcBfhXFaPZrxkw+UQaYe6iLTMH7AS4Lg/WBCc11apYoIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789719018; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vuTMyyL/j+Gx6XXHaxE1E56hGhzahr3nj7I37fciPF4=; b=Y4M3BPiYwNGYgjR1qD/komDw5X1l9kQWXiENzMaHgFWJjE9M97MRUodBmtq8tYhIt89ezQ2HEbP+zj1MWw2XlqG1epig/rUQ5Ow/RY/rnWaDROYh8WFnxfwpTIdi8feFeh5szxUWoHrSQKL7wa+exKWB67++D3Aqq+4nuCHT7gA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789719018035647.6954675749412; Fri, 18 Sep 2026 01:10:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1424863.1649096 (Exim 4.92) (envelope-from ) id 1x7Tfa-00036L-Ns; Fri, 18 Sep 2026 08:10:06 +0000 Received: by outflank-mailman (output) from mailman id 1424863.1649096; Fri, 18 Sep 2026 08:10:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7Tfa-00036B-KN; Fri, 18 Sep 2026 08:10:06 +0000 Received: by outflank-mailman (input) for mailman id 1424863; Fri, 18 Sep 2026 08:10:05 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7TfY-0002oA-W8 for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 08:10:05 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x7TfY-003rpJ-Cm for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 10:10:04 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aacf1d5-8faa-0a2a0a5109dd-0a2a4505aa90-26 for ; Fri, 18 Sep 2026 10:10:04 +0200 Received: from [74.125.225.76] (helo=mail-wr2-f12.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aacf1dc-4cb1-0a2a45050019-4a7de14cad4f-3 for ; Fri, 18 Sep 2026 10:10:04 +0200 Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-485ac898fa4so340638f8f.0 for ; Fri, 18 Sep 2026 01:10:04 -0700 (PDT) Received: from notebook.. ([88.230.43.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48720083c19sm2174133f8f.31.2026.09.18.01.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:10:03 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789719004; x=1790323804; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=vuTMyyL/j+Gx6XXHaxE1E56hGhzahr3nj7I37fciPF4=; b=BPn3lU5V6hCjNbI3xSkqgCdensJJpQQbT2iguZiHMzvo6vzaidPevcKnJ7TmsuBroh pPLkiY8IgBm8pgyHCEdec9+MAgvPakc4w5B881EmJpRX7Fh8opmzeX0YoMaLkGQU9Xj+ J67wPoHAFyj0Nl3Y49yV8psJHg9xd+o0F2cF2yMKTG89SgsZXN496t3WwpezrjI/NIDw e5DNAaIDWSzLjH23xMWS08K2Z+VtyNNJE43b7a3W2XGk5VkiCEbktOnyxwpXsMKXbUOc Eq2zCA2ONk8G0QBkSGrviIi9wN5OK4mu+2I3q2vjWsaEqDsiLy4UXweJZcZRMWTzH2PD j9rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789719004; x=1790323804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vuTMyyL/j+Gx6XXHaxE1E56hGhzahr3nj7I37fciPF4=; b=D8mo0yc2ZB7ItwSSK38TdiLq0qiThjskXfPwH+TACtIvPp0e6CM0a2IH3QUWgC11N7 1aYyq9CJlmo3tnuVxrt27j6+10EvbnYxWwjh416LLv7vymzk+ejS6gynvAkyLwD4VN3U /8U5DR4EJr5LXf4InGEf6E9E7+zF5oAAPjK09Ysu9huwVqe7dJbsXjBFJiI0RA359hP5 y0BbWWHQW0DQv0thDdaD1eGIVU9UsgwnW8jbX/AfaUJKAkcAXZk3vt+qHarlgkjYH0Nl ScD4IXLs3HkhEEJ75fNbJzPV0jNfLqGP7+U7yNGjUDOmDHae8c7ezzoPrx/13EumDVmJ JNVQ== X-Gm-Message-State: AFuF++mIEZEl0CLN2xmJXKDoUvI05S4ZhtJjzSjHE3RPr4gKiRTDH5Of y9h0t0IYrg5qSnJTacf+bSt6BJTI1CHmjAImULlVOlDd/Zb1ZACttNJXEbAzMQ== X-Gm-Gg: AYBFou0jT5dlfpHN90zuuWWhVSzZjP0t7KdgFUqdD8t1vW5nPQFAn65EoLtW+6wjSIo zCXCRE3LAlCvw7KYu1TxhupxhoktmqohfhQKLjeE69gqmVdYe6G2ElGBuOt0RzaapAUW8ss5YDA VY4jqZgrX/ZnHDRXMM9/D5ACQuQEYe+46rzcl5bE5cj3/LFBsIG5BFpsstm0IC75h+0Q/UdnZFu O9R3g8xg1ksm28W6x+VVcJuaZ0sM9M6ZGiiRJbHA1MfaO4kQ/VdkL5MXGlUvQsHtldizV9LoakN cICW1BS07KyDfcqn6adc4rV/x2RW7yCYmSdu/LPULmX/93YZFxDkfzMh9Ff+L9jt0eip8he5kPu 8n3epiFNNlq6puAqgmTQ+aru6+g6Ks5LvYjQ/1MBctlFxnTBJbxF/Zi5sBHFd2CPhRtuwl30Hne UyASG5ux7r1YIPUwicxTRvpEKPN1Og8LFZdXbT3DmHnjCLAK54BvFObmovRHvceYr6AIMejzOmG 1MAzXULgQw= X-Received: by 2002:a05:6000:178a:b0:487:1266:5be7 with SMTP id ffacd0b85a97d-4871e26674emr2167416f8f.26.1789719003772; Fri, 18 Sep 2026 01:10:03 -0700 (PDT) From: Furkan Caliskan To: xen-devel@lists.xenproject.org Cc: jgross@suse.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger@xenproject.org, dfaggioli@suse.com, anthony.perard@vates.tech, julien@xen.org, Furkan Caliskan Subject: [PATCH v2 3/5] xen/sched: rtds: report utilization and cap via debug key Date: Fri, 18 Sep 2026 11:09:33 +0300 Message-Id: <20260918080935.35498-4-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260918080935.35498-1-frn1furkan10@gmail.com> References: <20260918080935.35498-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1789719004-F52A32A1-AA1690FC/0/0 X-purgate-type: clean X-purgate-size: 1224 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1789719019880158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Juergen Gross --- xen/common/sched/rt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c index fbebd82c78..342f9b3a51 100644 --- a/xen/common/sched/rt.c +++ b/xen/common/sched/rt.c @@ -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; =20 spin_lock_irqsave(&prv->lock, flags); =20 if ( list_empty(&prv->sdom) ) goto out; =20 + cap =3D (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 =3D rt_runq(ops); depletedq =3D rt_depletedq(ops); replq =3D rt_replq(ops); --=20 2.34.1 From nobody Thu Sep 24 19:04:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1789719027; cv=none; d=zohomail.com; s=zohoarc; b=G7znkSElVQJ2KCRAPnj7yJGM5fzMjmwQIn7XMc9/YDCjkFoxc72eF3sf9QDWESOhgZucsoIad15v/f03UpP+bqGAjKVwztMXzJ1sqtf6Wj1LPyLLbyLdgiUeTMQ7tTpSUd0iZPr7Qcd/ws38SRsHxr4g6uTRheTTlskFFy78yI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789719027; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Oy/dbkoBMnHERlUH5IsXUjgHEA7CUR5ZyPf4nBEOh8U=; b=TPPTYd+CnG6EGbKTZSdp+sCqOBNUO5lYxfH4eQG1MZWPUoVo45gS+WaGoOkkz2kXE83Q1fH7gmhcMaQ6Jg1m/tdIQzI/YYvhr3XmCXCHq5Yn9GT205TIdy4tkSWxnEOm49Yw8l+5+Crwnt8dgahBGjr7/PbIb7dBvfje1TMOtes= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789719027692430.9597857177316; Fri, 18 Sep 2026 01:10:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1424864.1649105 (Exim 4.92) (envelope-from ) id 1x7Tfc-0003SP-Vf; Fri, 18 Sep 2026 08:10:08 +0000 Received: by outflank-mailman (output) from mailman id 1424864.1649105; Fri, 18 Sep 2026 08:10:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7Tfc-0003S0-RH; Fri, 18 Sep 2026 08:10:08 +0000 Received: by outflank-mailman (input) for mailman id 1424864; Fri, 18 Sep 2026 08:10:07 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7Tfb-0003I6-FI for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 08:10:07 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x7Tfa-00AVDl-RW for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 10:10:06 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aacf1db-2eae-0a2a0a5409dd-0a2a450ae71c-36 for ; Fri, 18 Sep 2026 10:10:06 +0200 Received: from [74.125.225.76] (helo=mail-wr2-f12.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aacf1de-f2d2-0a2a450a0019-4a7de14cddc8-3 for ; Fri, 18 Sep 2026 10:10:06 +0200 Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-48583cc7ab1so183992f8f.2 for ; Fri, 18 Sep 2026 01:10:06 -0700 (PDT) Received: from notebook.. ([88.230.43.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48720083c19sm2174133f8f.31.2026.09.18.01.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:10:05 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789719006; x=1790323806; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Oy/dbkoBMnHERlUH5IsXUjgHEA7CUR5ZyPf4nBEOh8U=; b=PSIuIZyfWVsMX8HhApYfOCQ0f4VlMMmbm6mQiQoig7p/yFbchSsWSs/vRsgD2P8BNt JUtbRY+Bdl7EWHCDjP5Q7XFMTYPYN6gLx1dENQUC7FBWobj5/iw8ce2bXmTQ7u5mJv9P xRms9f6PbJJrsRmCRfzja+wt2FhyoZk11jWTFbplWnT7pxtZn2hrj0vSFrdIjzsrZHDQ c6DMlqZ6vBS8b6zM1KIrG57LJAf7zrLUg1ip5+Z/8NB3EX7yh8WnoH9rE8OnaMiC+rfK F8+1Jb5yBhkzdzD7qElF05JGCHvJCcvFepvqsjQNOSFUw7KZRAbskFvqU9SE1147PF+J 69tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789719006; x=1790323806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Oy/dbkoBMnHERlUH5IsXUjgHEA7CUR5ZyPf4nBEOh8U=; b=U9Jb7MakEZJiv2033e6a7pPsqwgoU6Fb34SrKFRn7K/xJHImdr6wTmh84nYsOiE5tA nh1MkNMMAFAMdOHFTNmoX3GQ0tBxR3+F+JX7F9fOXl7NvEmk50gY9iL5EGk2cJsWV95C uLGhk6J2chBZZXoc/Zy3jGycPZTogAOraZQ5zYN7kpn4JIUWVwZHTEhYT9l6loQhMWrA i+PBLhFeqlRQnfqlHgYM6yfVt9zeskf+d7qUfT5pF8pycQcgFVKFoHkW4yexZztfCeAM nkVYaLH8gX0OMeeCNNqm5aDHRGVAEJB+gajFPcqw/CvlKAjA7QwT53iJqlx0hr0G8TmD nXfA== X-Gm-Message-State: AFuF++nPHklu17pKmWwB3hZlP+3chrw8VsW+hwh+23thJ4NpUUUt4DiY 1/Oq/N61CwSTnieUve15n4ZV+ZQq2Va1yrZe5rqF1TqvBPHahHxkU95xUerXew== X-Gm-Gg: AYBFou1WpQVrPgY7LR18rPzfVCvjg9LoWm1Gsigu3iILFNfVOMY5Zz6HX6DgyBc4Ezg /Z4J9cw9gnzPtt7bY1mfrJGDDU4kWHMIvSejZXjQMZMmCtTQUYtfFp0SjyKrMj3Wg9L8trtW3gH 3e92s1hDaClx2yukpJk9hzItxhYSNqDuZ3kKx2d3T2uvd9dQ+MNfPhOTTDY+P98LLKaZaUwz9/Q myL2hJDrbZzW4bouSuAIVON2ovkFZR+8DBt9kxpDF8g7OgSFUPuqvB4oEg+AgRbwalUH0y4mh0j iislvQqSl+tVTeaHt8ELhuNONi2g8W7RvPJCqenULRyn+FSOmQUpWs+NkGzwMEOHQpNb2teW7eC Qp5CLRngEHYV2ZmOgmO5jlXWSw66d1kMEpYhNbAzYtMQFFpU8O4xYD04uoGmnLz71swWu2UTOVD LwyA7TLqsu37DlCj0p3qwdETu4Wjp8cgHN2xa/1u+ijmFQ2/oi94WaypEnVq+XSxp2ruwP7O7c X-Received: by 2002:a05:6000:2f88:b0:486:f18b:3cf8 with SMTP id ffacd0b85a97d-4871e220ad4mr1998089f8f.22.1789719006031; Fri, 18 Sep 2026 01:10:06 -0700 (PDT) From: Furkan Caliskan To: xen-devel@lists.xenproject.org Cc: jgross@suse.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger@xenproject.org, dfaggioli@suse.com, anthony.perard@vates.tech, julien@xen.org, Furkan Caliskan Subject: [PATCH v2 4/5] xen/sched: rtds: make admission control cpupool-wide toggleable Date: Fri, 18 Sep 2026 11:09:34 +0300 Message-Id: <20260918080935.35498-5-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260918080935.35498-1-frn1furkan10@gmail.com> References: <20260918080935.35498-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1789719006-536D6CFC-5B9311D6/0/0 X-purgate-type: clean X-purgate-size: 6019 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1789719029926158501 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Juergen Gross --- v2: - Insert a blank line between the two non-fall-through case blocks. - Use uint8_t instead of bool for admission_control_enabled in the public xen_sysctl_rtds_schedule struct. --- xen/common/sched/rt.c | 57 ++++++++++++++++++++++++++++++++++--- xen/include/public/sysctl.h | 5 ++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c index 342f9b3a51..1c317919ca 100644 --- a/xen/common/sched/rt.c +++ b/xen/common/sched/rt.c @@ -216,6 +216,8 @@ struct rt_private { =20 /* Sum of admitted units' (budget/period), scaled by RTDS_UTIL_SCALE */ uint64_t utilization; + + bool admission_control_enabled; /* on/off flag for admission control. = */ }; =20 /* @@ -409,6 +411,9 @@ rt_dump(const struct scheduler *ops) cap =3D (uint64_t)cpumask_weight(ops->cpupool->res_valid) * RTDS_UTIL_SCALE * RTDS_UTIL_CAP_PCT / 100; =20 + 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 bool rt_try_set_utilization(struct rt_private *prv, const struct domain *d, @@ -706,7 +711,8 @@ rt_try_set_utilization(struct rt_private *prv, const st= ruct domain *d, uint64_t new_util =3D rt_unit_utilization(new_period, new_budget); uint64_t total =3D prv->utilization - old_util + new_util; =20 - 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 false; =20 prv->utilization =3D 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 =3D true; =20 ops->sched_data =3D prv; rc =3D 0; @@ -1565,8 +1572,14 @@ rt_dom_cntl( new_total =3D prv->utilization - dom_old_util + (uint64_t)nr_units * new_util; =20 - if ( new_total > prv->utilization && new_total > rt_utilization_ca= p(d) ) + if ( prv->admission_control_enabled && + new_total > prv->utilization && new_total > rt_utilization_ca= p(d) ) { + printk(XENLOG_WARNING + "RTDS: ADMISSION CONTROL: refusing d%d," + " would exceed utilization capacity of the cpupool\n", + d->domain_id); + spin_unlock_irqrestore(&prv->lock, flags); rc =3D -ENOSPC; break; @@ -1631,6 +1644,11 @@ rt_dom_cntl( if ( !rt_try_set_utilization(prv, d, svc->period, svc->bud= get, period, budget) ) { + printk(XENLOG_WARNING + "RTDS: ADMISSION CONTROL: refusing vcpu %u of d= %d," + " would exceed utilization capacity of the cpup= ool\n", + local_sched.vcpuid, d->domain_id); + spin_unlock_irqrestore(&prv->lock, flags); rc =3D -ENOSPC; break; @@ -1691,6 +1709,34 @@ rt_dom_cntl( return rc; } =20 +#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 =3D &sc->u.sched_rtds; + struct rt_private *prv =3D rt_priv(ops); + unsigned long flags; + + switch ( sc->cmd ) + { + case XEN_SYSCTL_SCHEDOP_putinfo: + spin_lock_irqsave(&prv->lock, flags); + prv->admission_control_enabled =3D params->admission_control_enabl= ed; + spin_unlock_irqrestore(&prv->lock, flags); + break; + + case XEN_SYSCTL_SCHEDOP_getinfo: + spin_lock_irqsave(&prv->lock, flags); + params->admission_control_enabled =3D prv->admission_control_enabl= ed; + 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 +1837,9 @@ static const struct sched_ops sched_rtds_def =3D { .remove_unit =3D rt_unit_remove, =20 .adjust =3D rt_dom_cntl, +#ifdef CONFIG_SYSCTL + .adjust_global =3D rt_sys_cntl, +#endif =20 .pick_resource =3D rt_res_pick, .do_schedule =3D rt_schedule, diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index c7cd9b4eb0..63d0ee062b 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -814,6 +814,10 @@ struct xen_sysctl_credit2_schedule { uint32_t ratelimit_us; }; =20 +struct xen_sysctl_rtds_schedule { + uint8_t 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; }; =20 --=20 2.34.1 From nobody Thu Sep 24 19:04:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1789719028; cv=none; d=zohomail.com; s=zohoarc; b=DCFNkxBGR6bE1USOVq1jgnhDIG6PbmusNt67bbs0FV952dt1HEvaUo+vhmzIcEbX2yHKHuExi26Xl3LhuvEPvpkfsB0XAeH7jzyn+jH1C8+NX+tew1AVT4SXhATDRXaW1gN/daTg1VgywVN6e8uQs4EEHhnpwf3Q8QG7GoPevcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789719028; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FHRsXuEnf7BCXLP3eamT1pJU7X7xpT0JlychFCHzOuM=; b=QW4amO0Bf/2juGmJuHv6GpQTU8ss1r6ZH1RiazRIyiqc3aKN6Sim5X3W+q1cI52Viv8bDcGKC06Qr287gHhpVE01c8+6RXiAbY05+DICYhWK4gfofh1T7nSW/1BHjRXkMx+IwfI3hVc/yPmkTvuhYCKEUAgKrZKIv3nv139qomA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789719028748564.2489352926731; Fri, 18 Sep 2026 01:10:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1424867.1649115 (Exim 4.92) (envelope-from ) id 1x7Tfg-0003ry-FJ; Fri, 18 Sep 2026 08:10:12 +0000 Received: by outflank-mailman (output) from mailman id 1424867.1649115; Fri, 18 Sep 2026 08:10:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7Tfg-0003rl-Ar; Fri, 18 Sep 2026 08:10:12 +0000 Received: by outflank-mailman (input) for mailman id 1424867; Fri, 18 Sep 2026 08:10:11 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x7Tff-0003pZ-Ia for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 08:10:11 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x7Tfe-00G512-VD for xen-devel@lists.xenproject.org; Fri, 18 Sep 2026 10:10:10 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aacf1e2-bab6-0a2a0a5309dd-0a2a450ae726-4 for ; Fri, 18 Sep 2026 10:10:10 +0200 Received: from [74.125.225.76] (helo=mail-wr2-f12.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aacf1e2-f2d2-0a2a450a0019-4a7de14cf5ae-3 for ; Fri, 18 Sep 2026 10:10:10 +0200 Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-4843cedd129so242736f8f.0 for ; Fri, 18 Sep 2026 01:10:10 -0700 (PDT) Received: from notebook.. ([88.230.43.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48720083c19sm2174133f8f.31.2026.09.18.01.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:10:09 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789719010; x=1790323810; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FHRsXuEnf7BCXLP3eamT1pJU7X7xpT0JlychFCHzOuM=; b=kH8A1dMV3DSmYf7vMFMIhA9Xc+cjJk0NOJvpiZdk03aMOfZuyjK1NDIy9nY/2GDLWT j1vY5CFDiKMKSc02beHBlT1h7pwsl5m7ZRdWaPKLF6wISGTe9o8SbT9PENHoB6BjemGV E/nM9Vl+Q8EkGytUQFNFE68q6RkEq0UQD2UnUXVWDFNP49evvvbqND4v80wFXeDGzCUO znD4sp00M0x8S0f0G9YvOg0dlCOW4mfIfIxJO7pesnCFBY6IlPmYc8DoHBsbxPpGAI10 75XUb/PV7qsqw7N//p33ZlFL1RNGRcKIy3fRIykyn21o7uXkmhpePDlYk0712h9hCHoM wasA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789719010; x=1790323810; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=FHRsXuEnf7BCXLP3eamT1pJU7X7xpT0JlychFCHzOuM=; b=Uc4gRZwidlbwASscGGVLPF0q5QY+k7tWkOe28/n70MkQgJ4Wzf/WCjmjUI9PiQ1G5H il4iuZM7hPscm902TiiiLDQBM7KQuWcVe49mOy1Dv1T89/rMoNG5YYIGfSufM7C1cP5s +Ybj2raMde2gUQi2IQk/LFuzSjoParsbgOwYH39hIqizEpWH6pb2lFLPEFbYkGGJvt2S 8F5TKSkHe2CBGNQSBnhbxlmMsGzpfl0LJ9YaEZwKYEpSZz5rKzAG9xITWeQaM4WN70SM GqCAVo3xfVyTKTlFOgvjCwmoxoJax+MsyB0fwtcPQvjbTXxn8ZM1VmkWI9boX6y3+XaF X+dQ== X-Gm-Message-State: AFuF++kKdgq+8M5beczm8q2v5KhRJkaF2FDnQ+BWwJt5QifbnFalLsYg 2xpuMwDGVRs0BBNiNG/Bk4HhgCPdrpv63MKEb+uq+NhDye336ms9k9foBebTLw== X-Gm-Gg: AYBFou3lCB18iNspFq0f4xwd88YL2QWcRRuALogpXKs5fsYm7hXnq4ZnMZ3Zt5plQvf 9dIZEhsoDSQcecU61/r39H/Pw8LS40lLVA2j5DrAxWHddsv6RL3N/qfhrPiQRPnKAykIoCVG3RR OSU2Xzv8PBNmKPpZXqXf++e7gCrH2a89cbx0D1RYrHXLwIdHf2mtZtvzW0RSOe2Ss1y7LWVMCnu Y97orzXVbc9vF+V9B7vegFKTkrzeqNEJNcapqdNORabLL2KhVBspLtdtNbIeJAIj+FR4pC+WJUr 8OOGfr52ziQdPPBDkPUtwTpl9iADXwgkKfFEz8Vru8N4mhqE+QezSICaqythqIdjeT40LIrFo1P 11no8K9iAZHi96PaBUjCJlF6M6XL7r0axjVm8kanmTO4WdPc6QdFFXEZww0EkGABDAG533DwS0X 6aK2Ihmatl/x+RRImMGWw7AhBkoFgLKgS0hGeN2k375nP3NqlcvgZoDlAuDNUVVpx53kfWZpM= X-Received: by 2002:a05:6000:4b06:b0:487:931:946c with SMTP id ffacd0b85a97d-4871e20cef1mr4744995f8f.1.1789719010064; Fri, 18 Sep 2026 01:10:10 -0700 (PDT) From: Furkan Caliskan To: xen-devel@lists.xenproject.org Cc: jgross@suse.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger@xenproject.org, dfaggioli@suse.com, anthony.perard@vates.tech, julien@xen.org, Furkan Caliskan Subject: [PATCH v2 5/5] tools: expose admission control toggle via xl sched-rtds Date: Fri, 18 Sep 2026 11:09:35 +0300 Message-Id: <20260918080935.35498-6-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260918080935.35498-1-frn1furkan10@gmail.com> References: <20260918080935.35498-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1789719010-52ADCCFC-781E7EAD/0/0 X-purgate-type: clean X-purgate-size: 16058 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1789719029967158500 Content-Type: text/plain; charset="utf-8" Wire 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"). Signed-off-by: Furkan Caliskan --- 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(-) diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in index 88ccf7ad82..51405f4e33 100644 --- a/docs/man/xl.1.pod.in +++ b/docs/man/xl.1.pod.in @@ -1230,6 +1230,16 @@ the unreserved system resource. =20 Restrict output to domains in the specified cpupool. =20 +=3Ditem B<-s>, B<--schedparam> + +Specify to list or set pool-wide scheduler parameters. + +=3Ditem B<-a ADMISSION_CONTROL>, B<--admission=3DADMISSION_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. + =3Dback =20 B @@ -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". =20 +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=3DRTDS admission-control=3Denabled + + xl sched-rtds -c pool-rt -s -a 0 + xl sched-rtds -c pool-rt -s + Cpupool pool-rt: sched=3DRTDS admission-control=3Ddisabled + =3Dback =20 =3Dback diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index b0c09da910..18ab0731ef 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -4192,6 +4192,29 @@ func (x *SchedCredit2Params) toC(xc *C.libxl_sched_c= redit2_params) (err error){x return nil } =20 +// NewSchedRtdsParams returns an instance of SchedRtdsParams initialized w= ith defaults. +func NewSchedRtdsParams() (*SchedRtdsParams, error) { +var ( +x SchedRtdsParams +xc C.libxl_sched_rtds_params) + +C.libxl_sched_rtds_params_init(&xc) + +if err :=3D x.fromC(&xc); err !=3D nil { +return nil, err } + +return &x, nil} + +func (x *SchedRtdsParams) fromC(xc *C.libxl_sched_rtds_params) error { + x.AdmissionControlEnabled =3D bool(xc.admission_control_enabled) + + return nil} + +func (x *SchedRtdsParams) toC(xc *C.libxl_sched_rtds_params) (err error){x= c.admission_control_enabled =3D C.bool(x.AdmissionControlEnabled) + + return nil + } + // NewDomainRemusInfo returns an instance of DomainRemusInfo initialized w= ith defaults. func NewDomainRemusInfo() (*DomainRemusInfo, error) { var ( diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index e0fd78ec03..897100d9b6 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -1231,6 +1231,10 @@ type SchedCredit2Params struct { RatelimitUs int } =20 +type SchedRtdsParams struct { +AdmissionControlEnabled bool +} + type DomainRemusInfo struct { Interval int AllowUnsafe Defbool diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 7c098edab6..ff993c38b7 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -2797,6 +2797,10 @@ int libxl_sched_credit2_params_get(libxl_ctx *ctx, u= int32_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); =20 /* Scheduler Per-domain parameters */ =20 diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 9f00d4a19d..6f4ea7ca62 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -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); =20 int xc_sched_arinc653_schedule_set( diff --git a/tools/libs/ctrl/xc_rt.c b/tools/libs/ctrl/xc_rt.c index 3cb3fbb923..fb3f567d4f 100644 --- a/tools/libs/ctrl/xc_rt.c +++ b/tools/libs/ctrl/xc_rt.c @@ -130,3 +130,43 @@ int xc_sched_rtds_vcpu_get(xc_interface *xch, =20 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 =3D {}; + + sysctl.cmd =3D XEN_SYSCTL_scheduler_op; + sysctl.u.scheduler_op.cpupool_id =3D cpupool_id; + sysctl.u.scheduler_op.sched_id =3D XEN_SCHEDULER_RTDS; + sysctl.u.scheduler_op.cmd =3D XEN_SYSCTL_SCHEDOP_putinfo; + + sysctl.u.scheduler_op.u.sched_rtds =3D *schedule; + + if ( do_sysctl(xch, &sysctl) ) + return -1; + + *schedule =3D 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 =3D {}; + + sysctl.cmd =3D XEN_SYSCTL_scheduler_op; + sysctl.u.scheduler_op.cpupool_id =3D cpupool_id; + sysctl.u.scheduler_op.sched_id =3D XEN_SCHEDULER_RTDS; + sysctl.u.scheduler_op.cmd =3D XEN_SYSCTL_SCHEDOP_getinfo; + + if ( do_sysctl(xch, &sysctl) ) + return -1; + + *schedule =3D sysctl.u.scheduler_op.u.sched_rtds; + + return 0; +} diff --git a/tools/libs/light/libxl_sched.c b/tools/libs/light/libxl_sched.c index 2d6635dae7..ae4379cf09 100644 --- a/tools/libs/light/libxl_sched.c +++ b/tools/libs/light/libxl_sched.c @@ -397,6 +397,52 @@ int libxl_sched_credit2_params_set(libxl_ctx *ctx, uin= t32_t poolid, return rc; } =20 +int libxl_sched_rtds_params_get(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_rtds_params *scinfo) +{ + struct xen_sysctl_rtds_schedule sparam; + int r, rc; + GC_INIT(ctx); + + r =3D xc_sched_rtds_params_get(ctx->xch, poolid, &sparam); + if (r < 0) { + LOGE(ERROR, "getting RTDS scheduler parameters"); + rc =3D ERROR_FAIL; + goto out; + } + + scinfo->admission_control_enabled =3D sparam.admission_control_enabled; + + rc =3D 0; +out: + GC_FREE; + return rc; +} + +int libxl_sched_rtds_params_set(libxl_ctx *ctx, uint32_t poolid, + libxl_sched_rtds_params *scinfo) +{ + struct xen_sysctl_rtds_schedule sparam; + int r, rc; + GC_INIT(ctx); + + sparam.admission_control_enabled =3D scinfo->admission_control_enabled; + + r =3D xc_sched_rtds_params_set(ctx->xch, poolid, &sparam); + if (r < 0) { + LOGE(ERROR, "Setting RTDS scheduler parameters"); + rc =3D ERROR_FAIL; + goto out; + } + + scinfo->admission_control_enabled =3D sparam.admission_control_enabled; + + rc =3D 0; +out: + GC_FREE; + return rc; +} + static int sched_credit2_domain_get(libxl__gc *gc, uint32_t domid, libxl_domain_sched_params *scinfo) { diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index a7893460f0..d3121ea277 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -1286,6 +1286,11 @@ libxl_sched_credit2_params =3D Struct("sched_credit2= _params", [ ("ratelimit_us", integer), ], dispose_fn=3DNone) =20 +libxl_sched_rtds_params =3D Struct("sched_rtds_params", [ + ("admission_control_enabled", bool), + ], dispose_fn=3DNone) + + libxl_domain_remus_info =3D Struct("domain_remus_info",[ ("interval", integer), ("allow_unsafe", libxl_defbool), diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 502244f683..e48d5c5edc 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -295,13 +295,19 @@ const struct cmd_spec cmd_table[] =3D { { "sched-rtds", &main_sched_rtds, 0, 1, "Get/set rtds scheduler parameters", - "[-d [-v[=3DVCPUID/all]] [-p[=3DPERIOD]] [-b[=3DBUDGET]] [-= e[=3DExtratime]]]", + "[-d [-v[=3DVCPUID/all]] [-p[=3DPERIOD]] [-b[=3DBUDGET]] [-= e[=3DExtratime]]]\n" + " [-c -s [-a[=3DADMISSION_CONTROL]]]", "-d DOMAIN, --domain=3DDOMAIN Domain to modify\n" "-v VCPUID/all, --vcpuid=3DVCPUID/all VCPU to modify or output;\n" " Using '-v all' to modify/output all vcpus\n" "-p PERIOD, --period=3DPERIOD Period (us)\n" "-b BUDGET, --budget=3DBUDGET Budget (us)\n" "-e Extratime, --extratime=3DExtratime Extratime (1=3Dyes, 0=3Dno)\n" + "-c CPUPOOL, --cpupool=3DCPUPOOL Restrict output to domains in CPUP= OOL\n" + "-s, --schedparam List or set pool-wide scheduler para= meters\n" + "-a ADMISSION_CONTROL, --admission=3DADMISSION_CONTROL\n" + " Enable or disable admission control for the cpupool\= n" + " (1=3Denabled, 0=3Ddisabled); requires -s\n" }, { "domid", &main_domid, 0, 0, diff --git a/tools/xl/xl_sched.c b/tools/xl/xl_sched.c index 73cd7040cd..7257d1854b 100644 --- a/tools/xl/xl_sched.c +++ b/tools/xl/xl_sched.c @@ -246,6 +246,28 @@ static int sched_credit2_pool_output(uint32_t poolid) return 0; } =20 +static int sched_rtds_params_set(int poolid, + libxl_sched_rtds_params *scinfo) +{ + if (libxl_sched_rtds_params_set(ctx, poolid, scinfo)) { + fprintf(stderr, "libxl_sched_rtds_params_set failed.\n"); + return 1; + } + + return 0; +} + +static int sched_rtds_params_get(int poolid, + libxl_sched_rtds_params *scinfo) +{ + if (libxl_sched_rtds_params_get(ctx, poolid, scinfo)) { + fprintf(stderr, "libxl_sched_rtds_params_get failed.\n"); + return 1; + } + + return 0; +} + static int sched_rtds_domain_output( int domid) { @@ -339,10 +361,15 @@ static int sched_rtds_vcpu_output_all(int domid, =20 static int sched_rtds_pool_output(uint32_t poolid) { - char *poolname; + libxl_sched_rtds_params scparam; + char *poolname =3D libxl_cpupoolid_to_name(ctx, poolid); =20 - poolname =3D libxl_cpupoolid_to_name(ctx, poolid); - printf("Cpupool %s: sched=3DRTDS\n", poolname); + if (sched_rtds_params_get(poolid, &scparam)) + printf("Cpupool %s: [sched params unavailable]\n", poolname); + else + printf("Cpupool %s: sched=3DRTDS admission-control=3D%s\n", + poolname, + scparam.admission_control_enabled ? "enabled" : "disabled"= ); =20 free(poolname); return 0; @@ -715,6 +742,8 @@ int main_sched_credit2(int argc, char **argv) * -d [domid] -v [vcpuid 1] [params] -v [vcpuid 2] [params] ... : * Set per-VCPU params for domain * -d [domid] -v all [params] : Set all per-VCPU params for domain + * -c [cpupool] -s : List pool-wide scheduling parameters for cpupool + * -c [cpupool] -s -a [0|1] : Set admission control for cpupool */ int main_sched_rtds(int argc, char **argv) { @@ -736,7 +765,10 @@ int main_sched_rtds(int argc, char **argv) bool opt_b =3D false; bool opt_e =3D false; bool opt_v =3D false; + bool opt_s =3D false; + bool opt_a =3D false; bool opt_all =3D false; /* output per-dom parameters */ + bool admission_control =3D false; int opt, i, rc, r; static struct option opts[] =3D { {"domain", 1, 0, 'd'}, @@ -745,10 +777,12 @@ int main_sched_rtds(int argc, char **argv) {"extratime", 1, 0, 'e'}, {"vcpuid",1, 0, 'v'}, {"cpupool", 1, 0, 'c'}, + {"schedparam", 0, 0, 's'}, + {"admission", 1, 0, 'a'}, COMMON_LONG_OPTS }; =20 - SWITCH_FOREACH_OPT(opt, "d:p:b:e:v:c", opts, "sched-rtds", 0) { + SWITCH_FOREACH_OPT(opt, "d:p:b:e:v:c:a:s", opts, "sched-rtds", 0) { case 'd': dom =3D optarg; break; @@ -801,6 +835,19 @@ int main_sched_rtds(int argc, char **argv) case 'c': cpupool =3D optarg; break; + case 's': + opt_s =3D true; + break; + case 'a': + if (strcmp(optarg, "0") && strcmp(optarg, "1")) + { + fprintf(stderr, "Invalid admission_control value.\n"); + r =3D EXIT_FAILURE; + goto out; + } + admission_control =3D strtol(optarg, NULL, 10); + opt_a =3D true; + break; } =20 if (cpupool && (dom || opt_p || opt_b || opt_e || opt_v || opt_all)) { @@ -809,6 +856,11 @@ int main_sched_rtds(int argc, char **argv) r =3D EXIT_FAILURE; goto out; } + if (opt_s && (dom || opt_p || opt_b || opt_e || opt_v || opt_all)) { + fprintf(stderr, "-s cannot be combined with domain/VCPU options.\n= "); + r =3D EXIT_FAILURE; + goto out; + } if (!dom && (opt_p || opt_b || opt_e || opt_v)) { fprintf(stderr, "Missing parameters.\n"); r =3D EXIT_FAILURE; @@ -831,6 +883,49 @@ int main_sched_rtds(int argc, char **argv) r =3D EXIT_FAILURE; goto out; } + if (opt_a && !opt_s) { + fprintf(stderr, "-a/--admission requires -s/--schedparam.\n"); + r =3D EXIT_FAILURE; + goto out; + } + + if (opt_s) + { + libxl_sched_rtds_params scparam; + uint32_t poolid =3D 0; + + if (cpupool) { + if (libxl_cpupool_qualifier_to_cpupoolid(ctx, cpupool, + &poolid, NULL) || + !libxl_cpupoolid_is_valid(ctx, poolid)) { + fprintf(stderr, "Unknown cpupool \'%s\'\n", cpupool); + r =3D EXIT_FAILURE; + goto out; + } + } + + if (!opt_a) { /* output pool-wide scheduling parameters */ + if (sched_rtds_pool_output(poolid)) { + r =3D EXIT_FAILURE; + goto out; + } + } else { /* set pool-wide scheduling parameters */ + if (sched_rtds_params_get(poolid, &scparam)) { + r =3D EXIT_FAILURE; + goto out; + } + + scparam.admission_control_enabled =3D admission_control; + + if (sched_rtds_params_set(poolid, &scparam)) { + r =3D EXIT_FAILURE; + goto out; + } + } + + r =3D EXIT_SUCCESS; + goto out; + } =20 if ((!dom) && opt_all) { /* get all domain's per-vcpu rtds scheduler parameters */ --=20 2.34.1