From nobody Thu Sep 3 07:03:35 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=1787720323; cv=none; d=zohomail.com; s=zohoarc; b=Ez8fpEYmcdsJlB8/TZtTlni50R82POE9xAYVOu2zLZGAiI/CRY15kFg0ZdY9S+AT5i7s0NE3D16Q0qyT05mwsf8ZOMAbawDtWEeFUQw5VKJSwZwrElpEH0LVgdRMmdsOtgjKM92u1wt0lsiW/7TtBDFKwBJSTnFePaPfBFQEPh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787720323; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7in3bnZnBsyVu6luHl4QWHPZitMbNPCAzBx2BqoAsCA=; b=Mk8fMyWhDYxluGUp5j+OmwBvE2lN7XWjQR5bn5wrKl4qjX6euGbSw+1Ez4Yx0t/+z/160UJQ73TTU8wWgEA7qNhg3svR2tRyw9K2Sjts623QTBeKcU9IhkIW/ChGtftPQzANy9l8nt5GYP9bmO8foiZyoGNDnD7uio5b0rc5mWQ= 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 1787720322926889.7562672107213; Tue, 25 Aug 2026 21:58:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1399561.1635566 (Exim 4.92) (envelope-from ) id 1wz5iK-0004RT-Pp; Wed, 26 Aug 2026 04:58:16 +0000 Received: by outflank-mailman (output) from mailman id 1399561.1635566; Wed, 26 Aug 2026 04:58:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5iK-0004RL-M0; Wed, 26 Aug 2026 04:58:16 +0000 Received: by outflank-mailman (input) for mailman id 1399561; Wed, 26 Aug 2026 04:58:15 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5iJ-0004Qy-KG for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 04:58:15 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wz5iI-00758C-7i for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 06:58:14 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a8e7247-e002-0a2a0a5209dd-0a2a450aa3fc-44 for ; Wed, 26 Aug 2026 06:58:14 +0200 Received: from [209.85.208.41] (helo=mail-ed1-f41.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a8e7266-f2d2-0a2a450a0019-d155d029f04b-3 for ; Wed, 26 Aug 2026 06:58:14 +0200 Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-69fc9f25118so508554a12.2 for ; Tue, 25 Aug 2026 21:58:14 -0700 (PDT) Received: from notebook.. ([88.230.44.160]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c250a9b43a0sm278781666b.52.2026.08.25.21.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 21:58:13 -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=1787720294; x=1788325094; 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=7in3bnZnBsyVu6luHl4QWHPZitMbNPCAzBx2BqoAsCA=; b=eoGTwLymht+g5v/LFun8r9HWVMIo5a5fJb9JtOHiQha+hGNjp5QXbU9JRcb5SqtDN2 8BQkPjfwBv2IHJr2JIDc6h2bnsv4hRoJIcuhpMLr7KPspLVLw58QtgEAKIrMhrz+i8R3 qmHLfY1vTyaMXAhw7Z7cbUgs3Wh/E/haN3f7p95M9iI3uGGqguoYBRFhaGFegR74XVqm cSJsxVyBPMNjeKjGmHsbFDqP/zyX6XLpg+cxoxz5n7x6Yeq8g9KqagmvoN44bplRsdDk JKH8WfbGIiw8Zl72qOrB32246lXlzlhLHzYNRnpmuSfRu+mT20+iWfeq6p++3w7gEWFj 02lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787720294; x=1788325094; 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=7in3bnZnBsyVu6luHl4QWHPZitMbNPCAzBx2BqoAsCA=; b=U40MkrIb5xhj7t/YdOF49DNclK4X283RXUKh5zCKxMgerluNBELXthkBVj2dm9LAHA DYHqKfLdtmB+eaTozdYlzE8QrdHC1taHNJ0UnO3JtU0QeUM3UmWe9uvdXKCmAQIZeop6 leOBQf+baiu3LukQ6AdS52jX2COIvK/TIXYvcEVrxcrp1eX3vIGzu4l1pJHuLcNV4jPE /jR1BRvXnI2AvcuZMJTW5/h+GQOTi8wvMECN1HmbiNlBLrB2j8yPCUbSNRPIDmHpDFcL V3BUeLpO0tVGNJEG3y1ulgC29hgQqwF3hmFUozTiLJ/yAMnKTHzx7/pseziH6hBrN+bj KRUQ== X-Gm-Message-State: AFuF++lurlWSsXZA5DeL9bCUqDkme/lpLx5RLPpoSIcp4WQRQgmOmiYP sUDzo67qZrYv85rJ7hM14Gp8Vzsqb2SLklnMZzkCdoDLp9VKAL7hzAXZJvtv9A== X-Gm-Gg: AR+sD11s3GhVpPYA/SSRA5bVAFvoCpf/DjbxQWETRC17rwZ59etL6r44AMrGhtJOJ5z zVHh+G9ov30n/Qi8ZTFuQ6VnF+syQePNqFQBvSf+c+npjzd7cWTiwOBP1g5dPmw72in/QatldEf 7ae2D7ftSixZqMKNfXjc4Q0rQPsNVmXrnCyprdI41r1o4v8drrVCpEsvsSSnoYR4hQwVmRf7cvA SbyKeu42c/5Gsq6Mf75tXmnw/dTQFCsrOlpEDrZIT15VfqQVo0x6yYd5Xu1XhLKh8V61woN3Mgt eeR+c0dwjketmU/2ezTh512OPw3I/nekYloYvEjrYT/JU/wLVc7sX1ZA8oMAfniFzejYJagTgfm 13gilavpV27Zn4Ll93hoXLM4JfroqANiXjphcQFVJJmeyvq5/WNQ29vIIN+qzvn1MpouWkXQo3K 4VMNsBKBPCnNrLKlaLgOVRWjeqReZ6M80kwohbVubnj/SjKWlrYqSvfHoMfTPcxg== X-Received: by 2002:a17:907:d08f:b0:c24:adf4:5c73 with SMTP id a640c23a62f3a-c250baf7e8amr492583166b.1.1787720293656; Tue, 25 Aug 2026 21:58:13 -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, sstabellini@kernel.org, gwd@xenproject.org, enr0n@ubuntu.com, michal.orzel@amd.com, Furkan Caliskan Subject: [PATCH 1/5] xen/sched: rtds: add global-EDF utilization admission control Date: Wed, 26 Aug 2026 07:57:16 +0300 Message-Id: <20260826045720.5779-2-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260826045720.5779-1-frn1furkan10@gmail.com> References: <20260826045720.5779-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1787720294-5A3DCCFC-3BDAB81C/0/0 X-purgate-type: clean X-purgate-size: 7027 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787720324448158500 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 --- 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..9126320801 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 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 =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 -EINVAL; + + prv->utilization =3D 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_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; + int rc; + svc->budget =3D RTDS_DEFAULT_BUDGET; =20 + spin_lock_irqsave(&prv->lock, flags); + rc =3D 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); =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_admission_test(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 3 07:03:35 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=1787720322; cv=none; d=zohomail.com; s=zohoarc; b=lGU2fyfyVP3OBUWbAFQ2OtL4EOinjlP/ZEla2e98BxpV5+PTwUpgmGOcrhyRgTp9U+mLcv3rM1ZtHFLJmDPIonVSFjqOOCTTki7yK6rqOiZqaICfClSooJyUCTeF8e02Qj/oRhfcAuaL6rFIIiLemGuB8RkRUnjMd5bcTbxBeog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787720322; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hmp+WJMlrY3UcNmiM1sdN0nUxrpak314iM4OXbwb3nk=; b=MSAXsm5UFLYIxfFTKwaXqeVvw4PXAsqkDTzmlIBoaHMk/W6JZTLpb2vi0IhptPjkl68Wd6zOLxDypAKh1m1tSUPYgezo95uwvrjVC4V//qqjkWikqWKWauoOZwmw6+D4YYACsI1XAs0KSFfjnqLc348+k51THjH3Dx2baE9IURo= 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 1787720322104945.0787545191217; Tue, 25 Aug 2026 21:58:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1399564.1635576 (Exim 4.92) (envelope-from ) id 1wz5iT-0004iw-4W; Wed, 26 Aug 2026 04:58:25 +0000 Received: by outflank-mailman (output) from mailman id 1399564.1635576; Wed, 26 Aug 2026 04:58:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5iT-0004in-0C; Wed, 26 Aug 2026 04:58:25 +0000 Received: by outflank-mailman (input) for mailman id 1399564; Wed, 26 Aug 2026 04:58:23 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5iR-0004hi-No for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 04:58:23 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wz5iR-00758C-4a for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 06:58:23 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a8e725f-e002-0a2a0a5209dd-0a2a450bdaf6-14 for ; Wed, 26 Aug 2026 06:58:23 +0200 Received: from [209.85.208.43] (helo=mail-ed1-f43.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a8e726e-b7e8-0a2a450b0019-d155d02bd0cf-3 for ; Wed, 26 Aug 2026 06:58:23 +0200 Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-6a1542cdb53so536379a12.2 for ; Tue, 25 Aug 2026 21:58:23 -0700 (PDT) Received: from notebook.. ([88.230.44.160]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c250a9b43a0sm278781666b.52.2026.08.25.21.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 21:58:22 -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=1787720302; x=1788325102; 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=hmp+WJMlrY3UcNmiM1sdN0nUxrpak314iM4OXbwb3nk=; b=hveCGDcj7mvrKOKVTeoqQx6bS+Ff2Iri2qf+c4WElaGQJw4hLZPxV79J5uVpUYqwrw +XyWr682bYGqI9DUWcDqyP7v75merarD4l5xVd/v+sMcwfz8REdzNz/xJFhEl30wQwL/ RNwut8sZTztFN7aKgLC2vQUuE4fmXd9iv6u/+cpUiTwHxmLfO+cJ0KVNJ5d4RuZZsXo6 uzqxe8XvrHgU2yqQqdQ1Iqu8aDK52zp5pdlGOGx/mLt7TbwHE/BJvigBuw5p4Pgr61Si J3lnWqzJWZQ7BRx2KDdF9tD7NbeMexmh9OPA8rgXq2yXZy0uVsGc6qrxLvs6zz0QHJWT sHHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787720302; x=1788325102; 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=hmp+WJMlrY3UcNmiM1sdN0nUxrpak314iM4OXbwb3nk=; b=aEogs4N+OrEh7MFayt1V8NFfzxrvHUmiJ8/mNFPNaiLbx/D1YfVODRpUG2Pbo0Oqsj NkQCi7POXV79YLsuFm8jt/XBulraB5vBPTvZCX5jwEdN7uTJB/NFAt1zuUUgp8diwMFk HBprxO+MptmH3zJ5TuKm3rLDq/bVbtF8MJ2YBEPBHwdQRy80cVHIaZA+wY6SjCx0ezN/ EdYEmG2+Ovw7G1aiPnfbaefBAZHKn0zj9G5d2/0VwwCWGLOg+cvjD61qHOpP41BKyC+x xQvkFZVsEUDleKrVHa8XY9kRzeoMTKqMOyV8MgZV2kMyAJYeu5tCzO/shUh4hGXvmyIX 31SA== X-Gm-Message-State: AFuF++l5iA7T0EHiKMRstoF1SWZixAnaE2EmC2FNMGTSJOComsPeeb34 hchss9ZrNPwLx/R7LbfNJxHddbNjny80nXCNDJPnX+1h+6VjhiZz6PPVLRgbuQ== X-Gm-Gg: AR+sD11Yj/B5nWlTGzW2KHmV/0vSHfclmucvLqEGHTIm6rfjqm+eefpeK1ceTS2+0pT 7lLgzCpn5WgezSc/yyepzJkgkjqsj4WFn+nq1FXdmv2L44rvRUNga99mEIwn3aH+Dob9Inm3X83 kgxoErHoIC0PRYMcXPr664rBr2/4puZNc01qKuqOQZ/w24osDiyXXgR34Q987LDyNttDdb7aNRp iV24AH1vJu9rp5NBmcGEyd1cYqxhlVAuS5Awf+d7UMMleLYl/NK2FnVx/bMn+ePOkqLv4h+pNXJ Ik0w6pQWcQOA3XnD9lYFJp+KlBe82hSx1g2ihATJblB72yIFGkpjIPmHtaegnT7Z/tYG5D5mAMC +YtFof1pQC5Fcka0SGjTqD5pUGkadfvQolByzLozbKDtx0rM3hlKiZYNCTt8h2te79evNWr2/Xb wMRhta0RssmkYAKeiQJB9ed1S89q1SKPgmEXn1u3PQN3MMdh12ocqpO4cK2gLG X-Received: by 2002:a17:906:9fce:b0:c1f:1520:4de5 with SMTP id a640c23a62f3a-c250bb50762mr467606766b.1.1787720302595; Tue, 25 Aug 2026 21:58:22 -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, sstabellini@kernel.org, gwd@xenproject.org, enr0n@ubuntu.com, michal.orzel@amd.com, Furkan Caliskan Subject: [PATCH 2/5] xen/sched: rtds: enforce admission control in xl sched-rtds Date: Wed, 26 Aug 2026 07:57:17 +0300 Message-Id: <20260826045720.5779-3-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260826045720.5779-1-frn1furkan10@gmail.com> References: <20260826045720.5779-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1787720303-190CD9EA-E23DD40F/0/0 X-purgate-type: clean X-purgate-size: 3238 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787720324381158500 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_admission_test() directly. Signed-off-by: Furkan Caliskan --- 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 9126320801..9643a277fe 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) ) + { + rc =3D -EINVAL; + spin_unlock_irqrestore(&prv->lock, flags); + 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); + + rc =3D rt_admission_test(prv, d, svc->period, svc->budget, + period, budget); + if ( rc ) + { + spin_unlock_irqrestore(&prv->lock, flags); + 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 3 07:03:35 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=1787720328; cv=none; d=zohomail.com; s=zohoarc; b=CXJSM1wvyNaxC3TLNjGoO5ah/jQInmypUz8Lqs6TskLtaO4bxITSvOz6hr9nkH55t7HpVfwhldWqRueRW4tj6L9z0rVehqD4kXLQkbp3DWrSet9SlIexVI8lC1+FQdeRugZD5xLJrJP41jnp2ZZ4RF6TY0WteV4QQwXMn5BHqDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787720328; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TQK6s/nICmBYwEM1TUDiv/Axq0E/+KEAZYQp/00aSKg=; b=DmlrMTtcl1XYknb4zUfVRMUh25N97dCAMJEBVdC6Oe6xjILiWVwAfQ+cKAX1HK5E1gtMRHucAGG7yrxSj4e4KXty/JJcaheTO/oyPEy1g0OwmNlnXgKJF9EXBE4B0FJd86HghZo9fstWK36t2+g35H80z6epY9+wA1qZTUH6GJg= 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 1787720328093675.0794977155431; Tue, 25 Aug 2026 21:58:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1399565.1635584 (Exim 4.92) (envelope-from ) id 1wz5iY-0004zU-BX; Wed, 26 Aug 2026 04:58:30 +0000 Received: by outflank-mailman (output) from mailman id 1399565.1635584; Wed, 26 Aug 2026 04:58:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5iY-0004zN-7U; Wed, 26 Aug 2026 04:58:30 +0000 Received: by outflank-mailman (input) for mailman id 1399565; Wed, 26 Aug 2026 04:58:28 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5iW-0004xc-HW for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 04:58:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wz5iV-004T7d-FY for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 06:58:27 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a8e7272-8faa-0a2a0a5109dd-0a2a4509d3da-2 for ; Wed, 26 Aug 2026 06:58:27 +0200 Received: from [209.85.218.49] (helo=mail-ej1-f49.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a8e7273-be1a-0a2a45090019-d155da31dc31-3 for ; Wed, 26 Aug 2026 06:58:27 +0200 Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-c250c6a6a6eso78960966b.0 for ; Tue, 25 Aug 2026 21:58:27 -0700 (PDT) Received: from notebook.. ([88.230.44.160]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c250a9b43a0sm278781666b.52.2026.08.25.21.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 21:58:26 -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=1787720307; x=1788325107; 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=TQK6s/nICmBYwEM1TUDiv/Axq0E/+KEAZYQp/00aSKg=; b=Afzdwf7rtune7IktrggN56ozLtFp69ledyu0hTVhrm0ReVE0o+jTOUYblRpsy45GPs 8EfW0hHvXtbZXsJW0Zmv2jfqA+JnZ1Od2zbpobYpp6KKbIQrLiEmVTMt7RwDwCcgWZ0x g2P9XA/ifVlkxE695ekQ+xYkXT6pkI17QitHgDyASyFGqhk4sdwkiEO/E1crWAmzYM3m PcvzO47VtlHQvSVSVhVL73hAfQ8uI4hCKmZCVJFluMRWiAQTXU6Gx6wyGnq9sFxxiOKV tBSdT9KJu8vxmr8wxIGAU/z6z78WXLk0OVJdFRMoCNkbjBVADZfO7Kcwt9lDqmutZD40 tbKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787720307; x=1788325107; 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=TQK6s/nICmBYwEM1TUDiv/Axq0E/+KEAZYQp/00aSKg=; b=mCxSePc5nSzxL+sPTbzjaj4yT6mtX5zc9M4YjmTdl6CrYven1IZ7AGKRYYhJymmIm9 bTd0BojS/ZVejbNB0HQ2vo40rGkJvnydAhx+NcQIClkDL/7fJE93N4vCR+IsKSEuayu/ nj70vXm9fCesgI4jP0RJIgi0Lhx3xnAk157v8plUD3FP8bufeuQ99hvQnN0hKC/+rp12 6J2OgVMwUA/L7i/QocjmZSXkNPp4Y0CsNDhus0APbUYQUyKcrKt2scHUVbJfX7NrhDny mmEO03YRuwVN5wVz2tSlI7pmbvUyPrX/EYlVrEAOWEKO97b840Me+zhBO5kP8uMgsz5G Y/hw== X-Gm-Message-State: AFuF++nXuoQclnnwcuIY1wmvNTQFClVE/f6m2Gxn9QcerD1InrTu7sHz XpohHa3DnospnD96MLRnRE/1C9CMZV9s488TElMJov9wavXNrct5hMWMb5vpBg== X-Gm-Gg: AR+sD12h7fDzh3Z2X6dLiDh2wv1UD0e3xP/Ise4go3+vveVekZCylOFm67kwIBM4Ua7 5KF9Zihwa5mfHvfHSRIPmv66uzIrHv54wb000lGObc9ES9f8BEsSzs52dU+tWpL3j16V77r4yl4 x5RYoABZ/GQQSG3QK17lZTXhjIbDlMZcrvRkow65RvQ6KIeXBM8amD9k1tvTYsCtHJ91dfEe2Oi YBtZEW12OvhlVxT2bp+Pt7yq7SaWIOjYsXLej9PCGEVyCilS4XQVU/4WyZrIyUdcaqVNMAtrl9G KUWE6TdHRCP58y61Y6VPsiImpyvxuSEJ2/nUxXdHeIzTHJCTrduzxuSnwl/jGaERRIlH2W7vPku kifFL0PkE+K3I6AZwXUa54kPat+ZoLNow+FAP2thFeSAwTW5Wl5TEAjAZ5eXnfU8tIdMOE2mKbE qNWPQsvlrd3LjV/so52YnJmqUs9Hp3yHImiQJDn8EFYiOz5s4BKtfWEEhZNco6 X-Received: by 2002:a17:907:94cb:b0:c20:f913:9337 with SMTP id a640c23a62f3a-c250c30cdddmr394534166b.20.1787720306723; Tue, 25 Aug 2026 21:58:26 -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, sstabellini@kernel.org, gwd@xenproject.org, enr0n@ubuntu.com, michal.orzel@amd.com, Furkan Caliskan Subject: [PATCH 3/5] xen/sched: rtds: report utilization and cap via debug key Date: Wed, 26 Aug 2026 07:57:18 +0300 Message-Id: <20260826045720.5779-4-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260826045720.5779-1-frn1furkan10@gmail.com> References: <20260826045720.5779-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1787720307-BD8C1034-75BD8437/0/0 X-purgate-type: clean X-purgate-size: 1178 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787720328382158500 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 --- 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 9643a277fe..0582c0094d 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 3 07:03:35 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=1787720330; cv=none; d=zohomail.com; s=zohoarc; b=h0H57wYfC6TY5hFMSq/PbEqbmt3ZjZz9H4O+xoYYmze6/lGBgKEYipBjlJJkOL+iKZr9hmJmXi11fRFcszarol6E6XMEry0f0jsXBoszzIK+RoyUIM643d1DZub5GHsKFu8qG3SvMU5KYrQ+TCsLk9g+ccl5qylLDvJn7lGXVqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787720330; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IoJGB6t5A5yVoQBOIDHzvIHt2FzWFgHAlTPuWE7dzHM=; b=WS7sVAzsHmMk0h/hfgxAwqEVc+2Zp3cQ8I6H7QOlZmgPcWwWoXbnvA0VOon6tF773+iC6g3yy3DlTx2c6jIu5ddaELhJGF5p+BnaXN7EbgRG4ShtpvYyOu0dP4fab4PYh2iFu4Ch2brftrQreq3MTq/XGCT8SYuv6/eqdx8aWpE= 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 1787720330083876.0908719679616; Tue, 25 Aug 2026 21:58:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1399567.1635594 (Exim 4.92) (envelope-from ) id 1wz5ic-0005M2-IB; Wed, 26 Aug 2026 04:58:34 +0000 Received: by outflank-mailman (output) from mailman id 1399567.1635594; Wed, 26 Aug 2026 04:58:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5ic-0005Lv-Dv; Wed, 26 Aug 2026 04:58:34 +0000 Received: by outflank-mailman (input) for mailman id 1399567; Wed, 26 Aug 2026 04:58:32 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5ia-0005Ga-Ob for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 04:58:32 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wz5ia-006gp8-5P for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 06:58:32 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a8e726a-2eae-0a2a0a5409dd-0a2a450acf9c-14 for ; Wed, 26 Aug 2026 06:58:32 +0200 Received: from [209.85.218.45] (helo=mail-ej1-f45.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a8e7278-f2d2-0a2a450a0019-d155da2dad13-3 for ; Wed, 26 Aug 2026 06:58:32 +0200 Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-c250c6a6a9aso50214966b.1 for ; Tue, 25 Aug 2026 21:58:32 -0700 (PDT) Received: from notebook.. ([88.230.44.160]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c250a9b43a0sm278781666b.52.2026.08.25.21.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 21:58:31 -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=1787720311; x=1788325111; 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=IoJGB6t5A5yVoQBOIDHzvIHt2FzWFgHAlTPuWE7dzHM=; b=RhrFIf51Ymw/lrj5LwkqCSd5HO6pt4REofbWHiY3pu9crS2n0UwXkx8c5cqkV811ET u0+Lu7zEEwW4xIJdA7Jz1EbCShYKxIxDrN5PyrxHH10jkZyATY9l/rzxfZxqM9Igv6Qu sC0EM5KvxPuVx7geZDZB/n/no6AM7aMGyPFKGk/1SOSqa9IUTjC6aaJX3UlBJJT1YKrT UiW423v4h4/cHeWZWYF5JIJUw3/rVJazXFETnrXY6TYly4C76W2jBPIJOogYii9/EIIX CDVPi93clnVLSpOT36IR6uhoUGs7MSg+FFC8A8yxJ1t+gI4Bp49Wr6T8We0h6OGi0VKB oHEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787720311; x=1788325111; 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=IoJGB6t5A5yVoQBOIDHzvIHt2FzWFgHAlTPuWE7dzHM=; b=A7NDK674FdYjiAorHap0rTGB7dlsIUK/WvkTWRr+X8J6ngFaY/OZqKsPDMKd+79Psy TSM68Slf5oh6MPWnDTvxRCUoQzdf6EjxaOVZRemQXICwhj2iAKTB6rDkugyftiGy9n7H Z4dviOw7IBwvnZbGk+bXRXoWmRs2+E7MR6bjcUSyXLKxyFsASwN6V6+15HsWx5v8w6kl OtE3hwEiUl7sXKk/yRxIAXy2WowAByD4Bb5Hv6A9oE3MgclLOcoJrdvrMD9AsTkgS1bR 3iSHGrMqfmLlHjoH9ZaP/hOZwth3P4Vf32oK+rGGe5Ki0uyX9pyI6fRNrSZswVauQeYt /sBQ== X-Gm-Message-State: AFuF++nzJjRLDssXJK1vm/ICsuFdfPe/AKvwxFIQJ3U9sHhcrcYQtpJ9 uNOPf1onPgXATZODXLOvFlhY6t65jN0ph1ucHmNoEnR/zvTR/Nd4RcOeeuSJRg== X-Gm-Gg: AR+sD11yKTd7d0+lz3MDeP240dC4FOWhwQ9xh6dZ2SIuN8pRFN617qVI8XPZBa+RjKL XX9vo1KusmXjnVY+/rhh5EJ+cg5YaAx2OzN6t0VU1hWgyrNsG/ZzT6z0vQiVrefLwLky4rP8dT6 JuPTq/IKcUlhWt2j67CY54ZHgnCOk9cgP+5v2Q981hVP0g0Ci/HsEm1VcIx2iEIFM8CctPGLGfy wuVFV4unjyKPw1n7VscRfGIfrvD8YuU75aNJ7m/ySamyKZIhFEiunlcWPTFjx9j64rvIeQJFFZM tpgIAqyafqBii6A0FC1BC+n6KT0IwTiHbuyC2nVFNy7Bb5lWuBgyDZQcZOoCqLdraqZmW0dSspH NDrhdOmJQI8VvDNqSN7xIyQePcqiUtOMnY0cIONswY89iKrvsZvy8O8CvnigHLuahKA8+AlgLh7 +xj/cyi9cpbPxw2BUOY5t7ENbP1TcqJuXStb+p5blJoJzNVyj7qj4L/PIq4zSdVw== X-Received: by 2002:a17:907:c08c:b0:c21:752f:c44e with SMTP id a640c23a62f3a-c250bc0f7e6mr524107766b.16.1787720311567; Tue, 25 Aug 2026 21:58:31 -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, sstabellini@kernel.org, gwd@xenproject.org, enr0n@ubuntu.com, michal.orzel@amd.com, Furkan Caliskan Subject: [PATCH 4/5] xen/sched: rtds: make admission control cpupool-wide toggleable Date: Wed, 26 Aug 2026 07:57:19 +0300 Message-Id: <20260826045720.5779-5-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260826045720.5779-1-frn1furkan10@gmail.com> References: <20260826045720.5779-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1787720312-520C1CFC-EA64CAE0/0/0 X-purgate-type: clean X-purgate-size: 5736 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787720332451158500 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 --- xen/common/sched/rt.c | 56 ++++++++++++++++++++++++++++++++++--- xen/include/public/sysctl.h | 5 ++++ 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c index 0582c0094d..b150f84242 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 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 =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 -EINVAL; =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); + rc =3D -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 cpup= ool\n", + local_sched.vcpuid, d->domain_id); + spin_unlock_irqrestore(&prv->lock, flags); break; } @@ -1691,6 +1709,33 @@ 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 +1836,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..f1bf3293e3 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 { + 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; }; =20 --=20 2.34.1 From nobody Thu Sep 3 07:03: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=1787720341; cv=none; d=zohomail.com; s=zohoarc; b=lymEZIeEHn1aW0rVPoxs1SztJhwLogKbpteirtHYtIMFVTpexFRjpPCyDcM6FmUctpXrCVx5JX/NgAYQVAp0FbjmHTtv8q4pqqgcu5vWWfkMxjVe5DAgskLGNL4LukeBI8OmCti9rAg29NXa63SOwyNp6RRbK5fcpPni6Bs8KE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787720341; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FHRsXuEnf7BCXLP3eamT1pJU7X7xpT0JlychFCHzOuM=; b=Dl74P1oH8P5wwqFy4el8QIdYWcgf8fAFO+LMHa3t6FpGsyeEmj9Z0LRQWqwCdHn4GIoFLs8BzrwmxD8IUAahd9jBcPiQAQG2bESZqgVjOLgwMaOGTlgH3HK1+B09XL/c6fymOF/AjK+HQ6Nmm2QSBMahK94t1oJKPlYJsYkYmqw= 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 1787720341674456.6412978402195; Tue, 25 Aug 2026 21:59:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1399572.1635603 (Exim 4.92) (envelope-from ) id 1wz5ih-0005fi-Pq; Wed, 26 Aug 2026 04:58:39 +0000 Received: by outflank-mailman (output) from mailman id 1399572.1635603; Wed, 26 Aug 2026 04:58:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5ih-0005fY-Kt; Wed, 26 Aug 2026 04:58:39 +0000 Received: by outflank-mailman (input) for mailman id 1399572; Wed, 26 Aug 2026 04:58:38 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wz5ig-0005dV-16 for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 04:58:38 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wz5if-00758C-EF for xen-devel@lists.xenproject.org; Wed, 26 Aug 2026 06:58:37 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a8e725f-e002-0a2a0a5209dd-0a2a450bdaf6-24 for ; Wed, 26 Aug 2026 06:58:37 +0200 Received: from [209.85.218.47] (helo=mail-ej1-f47.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a8e727d-b7e8-0a2a450b0019-d155da2ff019-3 for ; Wed, 26 Aug 2026 06:58:37 +0200 Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-c250a2bc3b3so58361166b.2 for ; Tue, 25 Aug 2026 21:58:37 -0700 (PDT) Received: from notebook.. ([88.230.44.160]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c250a9b43a0sm278781666b.52.2026.08.25.21.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 21:58:36 -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=1787720317; x=1788325117; 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=iVPKiUlRX8AAxHG1yp5yA9fUy0Zkw02z6k7Xx6Tf38C3C3DqB+/c/zIp4HkAqSKZC5 pLVV7Fnwujmaui/HZ1fNZzGLyox6O1Pj3DcNRSE3ylqBOPGODAwZbiFvDJS+OOelPHUS h7i3JMa2Zz4Zy8o0Z3WsI4BneZB3trsLQCfVNrTMiv6WsA4HS2eN6+84AJuNxOw94WtM yLzNUwd7uQLEbfNIEQA58fBh9ZaOnIUye6WCpxtIjImkB6EJw+F3AeE42xW3eVWg8MH3 CKPW7a3SuIAYFBFHXwr0Vs/27J2i4uAbURSMuSHugW/5Zb1aqRqxvKqGMSPrrYmcAXxK azWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787720317; x=1788325117; 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=MvFQ1EiIL7eAEKaIfiSqJ5rd/GjOFeDW+cZ5+rSiAgd8JFJ8UDWgkcPy2P3bNrbItT UlDDuPtNzJY6LMhy53qcSxOIlr1iQTJgTug9O8S5PTbKR7WMzx9Kjx0btY+iDDSzQ2GW iGeTfiUJR5/qg8Hrt9och1s9AovnM0W8FkzXZS2jUpZk0PhIZV6W+WCZqKjE/16DlmJk +AmH6aaE+R5WDfkG1BFxLumkic3r+tAHx9A2qZPdfUcrn8O6B7wgia5mQSzFS0Wi8X1x c8qJ/xQDtqkBAfGUh6nP8du4KE+ncAHpMFjYJGwFvETLWUk2fU1WDK3Ej4OngEH14eYb q1xw== X-Gm-Message-State: AFuF++lLlqPih7HAx6iIRWE6JQNRw2CHry3y2cjqjTjL0UFmlg+uCLEi nO4C5in7KFAEgHw33GIqHeH11NdqfxbGEu+bMKkLoezSO1wyWrhYScgh8eXzGg== X-Gm-Gg: AR+sD10ufEkf79cFAnJmafVVlwHGSJKtwwoZ7kVJdxJwSMBXYLzn1GXPqDOQ0UCsWyh QxktJMzcGxo3uUEtam/wvn6k+RoW71rWQ1N0in4MA5Sk8B/79r8An7tIMaNfEU1QSqPkYxrGrq4 cbn5l30JGVi7LPpubZAmUb563Huo+YmZFIB//mZw9jNeu5iPQEezA1LGfRa5iTPVO2Luu+f/XZ1 3xftOjAgQcu7DuCcHus+PiHmmnjftNnQ3XGEksKgXgGJw4WVZ2CZzwP1jVjxOxB+JoVXCTKAqPr 5DofZFurzvVvZLbt3lQk+3SkEyOeXwX4fXN9bu74UVlaFDt6PQT8pBb54ASuWpZPAO8JBPM0SDv F2tx4mvZTUaYxKf7TSn5/AqAFwEnCatAt/9Q9ydrddklVvufMyS5YTMk8jZut8d/me4j2uk5ggp y4s+swAptOyxG85OnLR7WjLFs1iH/7j3ibIXuRW67v0E82Ii6UKQnHF3/nyEPJ X-Received: by 2002:a17:906:ba83:b0:c25:544:3aec with SMTP id a640c23a62f3a-c250baf9b5amr516177966b.5.1787720316767; Tue, 25 Aug 2026 21:58:36 -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, sstabellini@kernel.org, gwd@xenproject.org, enr0n@ubuntu.com, michal.orzel@amd.com, Furkan Caliskan Subject: [PATCH 5/5] tools: expose admission control toggle via xl sched-rtds Date: Wed, 26 Aug 2026 07:57:20 +0300 Message-Id: <20260826045720.5779-6-frn1furkan10@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260826045720.5779-1-frn1furkan10@gmail.com> References: <20260826045720.5779-1-frn1furkan10@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1787720317-1B6D29EA-8C33FBC3/0/0 X-purgate-type: clean X-purgate-size: 16058 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787720342744158500 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