Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7A8B1091902 for ; Thu, 19 Mar 2026 17:49:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1257477.1551862 (Exim 4.92) (envelope-from ) id 1w3HUx-0007Pp-Of; Thu, 19 Mar 2026 17:49:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1257477.1551862; Thu, 19 Mar 2026 17:49:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w3HUx-0007Pi-M2; Thu, 19 Mar 2026 17:49:31 +0000 Received: by outflank-mailman (input) for mailman id 1257477; Thu, 19 Mar 2026 17:49:30 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w3HUv-0007Pc-Jo for xen-devel@lists.xenproject.org; Thu, 19 Mar 2026 17:49:30 +0000 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazlp170120005.outbound.protection.outlook.com [2a01:111:f403:c200::5]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f8f97dd9-23bb-11f1-9ccf-f158ae23cfc8; Thu, 19 Mar 2026 18:49:27 +0100 (CET) Received: from PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) by AM9PR03MB6881.eurprd03.prod.outlook.com (2603:10a6:20b:286::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.19; Thu, 19 Mar 2026 17:49:24 +0000 Received: from PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::98:900e:f8e2:716f]) by PAVPR03MB8946.eurprd03.prod.outlook.com ([fe80::98:900e:f8e2:716f%6]) with mapi id 15.20.9723.018; Thu, 19 Mar 2026 17:49:24 +0000 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" X-Inumbo-ID: f8f97dd9-23bb-11f1-9ccf-f158ae23cfc8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jDtXr+16Z/XhtdCCgCgVJzb4+xbqT/aTm5rxujZIuSaopVI9v1Dj0zqX+kCvOqUR9zObNE1KfMnvV7breV+15kuraJxOW2SFV1p+0GradGojqVI5zBjuSfUGrpE9Hhd7Ly/1EYfQ1awyGV2yWQA5q5hOYshl0AUiCcyW1fbqmOTVOg5ufhoJxnzW08TzJUIV6YXSaZdMWNhNNTR0f4FvIiMsij0IJeDY41MZC/UiPpMqatjrhUbJMRPHVi9see+7tZ+f6rN3UOrpJudv9B7jYgZaZVp0ao0YYD26X7JBBz7phZSAlBCVX8Az3UR1NBO1s17EvQXq95RKW7wbKMY51w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TiV4OJ9RkuDFcSi2lKHDcz1LCfVpgQ9ioLTRJwYNCTs=; b=uJA8yzOpB//TgOQ4UWR2An+6PZygbCTgW8v5wgdYTOrdkkh6tu8kMU0iRqUJLg5tDuzllEcIw9ENPTJa/nZ5Ywoo4XXlB/tcPp5AUEYViGEwwBtP0fDI+NDt/D7eygYJyPcD3c8v/u0LbvkoNlf9dVOC69UoCXPoM5pRaeGwquIUZH/QjwrxcisXNtsPUYrFxAku234HUuNzkhntAsHxHGov7ea3R6MQUxkjTVK5RgShcRclbchMUom0CF/tm5nWpaTgo4fCzckOQ39leUoauL1pMXy2qUGGhNxvsblvVrcocA/lb0dnVRlFSTzK0f2C8SHL6lmRx6ysf23j6KHW9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TiV4OJ9RkuDFcSi2lKHDcz1LCfVpgQ9ioLTRJwYNCTs=; b=TAt4NaLFLjb+UIN7UZ1JW5wpQhHios/8RO7mNN2M3xTURzaS38k3q70qU8x9vL20GdDRR9KI7Pit5lFgJoNPS99cpSdEHGqwD3SMiiutzu21TPcmuduBBItLwYiKuU25Z0k48042Ctm4W/uvG97GRTnWC08G0xkOs0Q5X8NPb3KH3MkMjIaQJMwcrPaMgRhiXWnUnVp3W8hCim6eFkJMPJ38g/+ZnefVsFOBfb/kR1Ia/vcp0ZmWV0/kx6HEtT8t26PcJ52Kk+4ZZabCfAU8kcqHxUoWGGOlPFflgxIr3VfnLId+OjRRmDtxzxV5kn/9Vhq69uAVvi6CkzaO+bJ5sA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; Content-Type: multipart/alternative; boundary="------------ZnOiZ0itnUU4M7pRjwde1saL" Message-ID: <1c0f5bc3-5e04-4043-b950-bf9af10bf720@epam.com> Date: Thu, 19 Mar 2026 19:49:22 +0200 User-Agent: Mozilla Thunderbird Content-Language: en-US To: xen-devel@lists.xenproject.org Cc: dfaggioli@suse.com, mengxu@cis.upenn.edu, gwd@xenproject.org, andrew.cooper3@citrix.com, julien@xen.org, jbeulich@suse.com, tiche@cis.upenn.edu, tiche@seas.upenn.edu, Stefano Stabellini , dario.faggioli@citrix.com, Julien Grall , Volodymyr Babchuk From: Oleksii Moisieiev Subject: [RFC] RTDS scheduler: potential issues found during safety analysis X-ClientProxiedBy: FR4P281CA0280.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e6::16) To PAVPR03MB8946.eurprd03.prod.outlook.com (2603:10a6:102:32e::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAVPR03MB8946:EE_|AM9PR03MB6881:EE_ X-MS-Office365-Filtering-Correlation-Id: 74982772-32e2-4540-af1a-08de85dfdbb4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014|8096899003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: Bb3GsSKhiZC2KJlc1ks9HCU+KIAnX9tdrHnHyaKDlk+/zKdYcvQNEFUr/8wafzS1tlT3rxlB7FJiq0oIULtOYF+G24eozvkUwcE51gNmTkPmlXpgEjdt4LeHVQkb/13UmNm+wyejZYUW1iqd4OMeNPBPj5UBzcG6GPib+HxeutM4NhIwkJNMJ4dL8Ei9pgziW8lArDNpKsN7vOjycfTE2dj6zIpNCLK/TnFbgXp5OhYPVwBDc1l5ptm8EuWdgm43BxBQgzoXJHSc0NLTRBxcIGEup43sj0JU/gjlCVR0N4FoNCMGPW6Q9xc6oilZqG/v+gQIGaN3WTiMqn+tLDYPweG4CMSv5UChqHoO8sKy8gkr7Zu2JoE3vAg4jI0yKR+5fuqjVndo4QWT+CnVhQMRZhPWXRztqB2uqmvQxEck08IY1GecSXTuSBlH1ARlinFcy8nzjGBTZIrBTCbXby+vsn6BEm4uhw1m4ZjGSIupFqdmNnYqwghJceON5pnpyKyqzf5hshJyQ3XzSDW5+8oPbRvwoRRoQ0qeQiwdXRQQHBKNGjpNhOhGvfUgRQT9QabqEkUy2ad+pDvdpw9Yv8pOYNmzi22VIEsreYBCNdwHBzVgXsgs0x1Z5j411t52B47SFNhO3CFs2j4dmX38WIJ51FzmGlq7GjXHQPJo9Trb7yD6jLM6KNmpyhLTCHQpyT5DogFKYTEX2KYfqeiTS6/SfHY8XrKP/+gYcdtURINYDkI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAVPR03MB8946.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7416014)(8096899003)(18002099003)(56012099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TnJhUlFaQzNQNFZlelBlMm0rYWl2MFl3cmhMaENkYmZzOE9RUGZJTk9BbzBw?= =?utf-8?B?ekRIUThaaEMzNkdRQVdkb1F2cURlcEpqMEhSeitTVmdBUG5qUXE0SDlaOEsw?= =?utf-8?B?Y1JJK1pDMFpkeEpwOE55bFg5R2U1N1RiMkQwQi9Cc3NiZmlsb3VNN2IxRjU0?= =?utf-8?B?RW9NSi85VFJMMEIzWGs5VXF2a2tWUVFwSEtCYzBlR2hjTkpScDNnckdUK2Qx?= =?utf-8?B?RHBncmw3VmI3S1RSRjYwUVlFNTMvQ0NtaFR0Vk1WQ3pnWmJmNjFEVS95NERS?= =?utf-8?B?WXh1bHVXbERPYzFYYTdIRjVyZ3ZBcUFlNEZpTjV6SUR4UkNLOURxRDRGYVFr?= =?utf-8?B?a3dYak5Xbk16dEFsUWd4Zy9JZ0N2enV0TDNyOXZxTVJmRng5eEFMcTFZdVp2?= =?utf-8?B?YnhLYWlmZmdwWVFJUUR4SGxxSkhIUDJKSU1qVTMrbUxiSmwvRHZiSCtRZXZ6?= =?utf-8?B?b2c0ODF0Q2J1T2xXRXArTXR0aStmOFNreDAvaDNkRlAxTm41dkVQTmV0eWE3?= =?utf-8?B?bFdFemM2S0VKMXZnWFZiRUNDZT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ginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74982772-32e2-4540-af1a-08de85dfdbb4 X-MS-Exchange-CrossTenant-AuthSource: PAVPR03MB8946.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2026 17:49:24.5058 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: StIX3svKupBA4OYWHiPK/s9JumZRCmr5XLMkMlNsQ+V/hPe4FjkP4TXYlOTC1ydKJIt0nH64fbSFuZZxCpklG5NLjASCW8pC4ng0QxvlTtU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB6881 --------------ZnOiZ0itnUU4M7pRjwde1saL Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi all, We have been performing analysis of the RTDS scheduler code (xen/common/sched/rt.c) and identified several potential issues that we would like to bring to the community's attention. We would appreciate your feedback on whether these issues are considered worth addressing, and if so, what the preferred approach would be. Below is a summary of the findings. All references are to the current upstream code. 1. Inconsistent validation in domain-wide vs per-vCPU parameter update ---------------------------------------------------------------------- In rt_dom_cntl(), the XEN_DOMCTL_SCHEDOP_putinfo path (domain-wide parameter update) only validates: if ( op->u.rtds.period == 0 || op->u.rtds.budget == 0 ) In contrast, the XEN_DOMCTL_SCHEDOP_putvcpuinfo path (per-vCPU update) enforces stricter checks: if ( period > RTDS_MAX_PERIOD || budget < RTDS_MIN_BUDGET || budget > period || period < RTDS_MIN_PERIOD ) This means the domain-wide path accepts configurations where budget exceeds period, or where period/budget fall below the 10 us minimum that the per-vCPU path enforces. Such parameters can lead to scheduling overhead issues (very short periods) or over-allocation (budget > period). Suggested fix: apply identical validation constraints on both paths, i.e. add the same bounds checks (budget <= period, period >= RTDS_MIN_PERIOD, budget >= RTDS_MIN_BUDGET, period <= RTDS_MAX_PERIOD) to the putinfo path. Additionally, the putinfo path does not handle the extratime flag at all, unlike the putvcpuinfo path. 2. Priority level overflow for extratime vCPUs ---------------------------------------------- In burn_budget(), when an extratime vCPU exhausts its budget: svc->priority_level++; svc->cur_budget = svc->budget; The priority_level field is declared as `unsigned` (32-bit) and there is no upper bound check before the increment. While rt_update_deadline() resets priority_level to 0 at each period rollover, for a long-running extratime vCPU that continuously exhausts its budget within a single period, the counter could theoretically wrap from UINT_MAX to 0. Since priority_level 0 represents the highest scheduling priority, a wraparound would cause the extratime vCPU to suddenly preempt vCPUs with active real-time reservations. While this scenario requires an extreme number of budget exhaustion cycles within a single period, it is a concern for long-running embedded or safety systems that operate without reboot for extended durations. Suggested fix: saturate priority_level at a safe maximum value (e.g., UINT_MAX - 1) instead of allowing unbounded increment. 3. Replenishment timer loss during CPU pool reconfiguration ----------------------------------------------------------- When the last pCPU is removed from an RTDS CPU pool, move_repl_timer() kills the replenishment timer via kill_timer(). When a pCPU is later re-added, rt_switch_sched() re-initializes the timer object (if status is TIMER_STATUS_killed) but does not re-arm it from the existing replenishment queue. If the replq already contains pending entries, those replenishments will not fire until some other event explicitly calls set_timer(), potentially stalling all non-extratime vCPUs. We believe this is actually a broader issue that goes beyond the RTDS scheduler: the common cpupool infrastructure probably should not allow a cpupool that has assigned vCPUs to lose all of its pCPUs. Preventing such a state at the cpupool management level would address the root cause for all schedulers, not just RTDS. Suggested fix (RTDS-specific): when timer ownership is re-established in rt_switch_sched(), re-arm the replenishment timer to the earliest deadline in the replq if the queue is non-empty. Suggested fix (common): the cpupool code should refuse to remove the last pCPU from a cpupool that still has domains/vCPUs assigned to it, returning an error instead. This would prevent the problematic state from arising in the first place. 4. Missing scheduling notification on vCPU insertion ---------------------------------------------------- rt_unit_insert() inserts runnable units into the replenishment and run queues but does not call runq_tickle(). In contrast, rt_unit_wake() and rt_context_saved() both call runq_tickle() after runq_insert(). This means a newly inserted vCPU with a higher priority (earlier deadline) than currently running vCPUs will not be considered for execution until the next natural scheduling event (timer, sleep, budget expiry), which can delay scheduling by up to one full period. Suggested fix: add a runq_tickle() call after the runq_insert() in rt_unit_insert(), following the same pattern used in rt_unit_wake(). 5. Stale scheduling flags on vCPU removal during context switch --------------------------------------------------------------- rt_unit_remove() removes queue membership via q_remove()/replq_remove() but does not clear the RTDS_delayed_runq_add or RTDS_scheduled flags. If a vCPU is removed while it is being context-switched off a pCPU (i.e., RTDS_scheduled is set and RTDS_delayed_runq_add may be set), rt_context_saved() will later clear RTDS_scheduled and, finding RTDS_delayed_runq_add set, will re-insert the removed vCPU into the run queue via runq_insert() + runq_tickle(). This results in a stale vCPU reference on the scheduler's run queue, belonging to a domain that may be in the process of destruction or migration. Suggested fix: in rt_unit_remove(), explicitly clear RTDS_delayed_runq_add and RTDS_scheduled flags after removing queue membership, so that rt_context_saved() cannot re-insert a removed vCPU. We would appreciate any feedback on these findings. We are happy to prepare patches for any of the issues the community considers worth fixing. Best regards, Oleksii Moisieiev --------------ZnOiZ0itnUU4M7pRjwde1saL Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
Hi all,
We have been performing analysis of the RTDS
scheduler code (xen/common/sched/rt.c) and identified several potential
issues that we would like to bring to the community's attention. We would
appreciate your feedback on whether these issues are considered worth
addressing, and if so, what the preferred approach would be.
Below is a summary of the findings. All references are to the current
upstream code.
1. Inconsistent validation in domain-wide vs per-vCPU parameter update
----------------------------------------------------------------------
In rt_dom_cntl(), the XEN_DOMCTL_SCHEDOP_putinfo path (domain-wide
parameter update) only validates:
if ( op->u.rtds.period == 0 || op->u.rtds.budget == 0 )
In contrast, the XEN_DOMCTL_SCHEDOP_putvcpuinfo path (per-vCPU update)
enforces stricter checks:
if ( period > RTDS_MAX_PERIOD || budget < RTDS_MIN_BUDGET ||
budget > period || period < RTDS_MIN_PERIOD )
This means the domain-wide path accepts configurations where budget
exceeds period, or where period/budget fall below the 10 us minimum that
the per-vCPU path enforces. Such parameters can lead to scheduling
overhead issues (very short periods) or over-allocation (budget > period).
Suggested fix: apply identical validation constraints on both paths, i.e.
add the same bounds checks (budget <= period, period >= RTDS_MIN_PERIOD,
budget >= RTDS_MIN_BUDGET, period <= RTDS_MAX_PERIOD) to the putinfo path.
Additionally, the putinfo path does not handle the extratime flag at all,
unlike the putvcpuinfo path.
2. Priority level overflow for extratime vCPUs
----------------------------------------------
In burn_budget(), when an extratime vCPU exhausts its budget:
svc->priority_level++;
svc->cur_budget = svc->budget;
The priority_level field is declared as `unsigned` (32-bit) and there is no
upper bound check before the increment. While rt_update_deadline() resets
priority_level to 0 at each period rollover, for a long-running extratime
vCPU that continuously exhausts its budget within a single period, the
counter could theoretically wrap from UINT_MAX to 0. Since priority_level 0
represents the highest scheduling priority, a wraparound would cause the
extratime vCPU to suddenly preempt vCPUs with active real-time reservations.
While this scenario requires an extreme number of budget exhaustion cycles
within a single period, it is a concern for long-running embedded or safety
systems that operate without reboot for extended durations.
Suggested fix: saturate priority_level at a safe maximum value (e.g.,
UINT_MAX - 1) instead of allowing unbounded increment.
3. Replenishment timer loss during CPU pool reconfiguration
-----------------------------------------------------------
When the last pCPU is removed from an RTDS CPU pool, move_repl_timer()
kills the replenishment timer via kill_timer(). When a pCPU is later
re-added, rt_switch_sched() re-initializes the timer object (if status
is TIMER_STATUS_killed) but does not re-arm it from the existing
replenishment queue. If the replq already contains pending entries, those
replenishments will not fire until some other event explicitly calls
set_timer(), potentially stalling all non-extratime vCPUs.
We believe this is actually a broader issue that goes beyond the RTDS
scheduler: the common cpupool infrastructure probably should not allow
a cpupool that has assigned vCPUs to lose all of its pCPUs. Preventing
such a state at the cpupool management level would address the root cause
for all schedulers, not just RTDS.
Suggested fix (RTDS-specific): when timer ownership is re-established
in rt_switch_sched(), re-arm the replenishment timer to the earliest
deadline in the replq if the queue is non-empty.
Suggested fix (common): the cpupool code should refuse to remove the
last pCPU from a cpupool that still has domains/vCPUs assigned to it,
returning an error instead. This would prevent the problematic state
from arising in the first place.
4. Missing scheduling notification on vCPU insertion
----------------------------------------------------
rt_unit_insert() inserts runnable units into the replenishment and run
queues but does not call runq_tickle(). In contrast, rt_unit_wake() and
rt_context_saved() both call runq_tickle() after runq_insert(). This
means a newly inserted vCPU with a higher priority (earlier deadline)
than currently running vCPUs will not be considered for execution until
the next natural scheduling event (timer, sleep, budget expiry), which
can delay scheduling by up to one full period.
Suggested fix: add a runq_tickle() call after the runq_insert() in
rt_unit_insert(), following the same pattern used in rt_unit_wake().
5. Stale scheduling flags on vCPU removal during context switch
---------------------------------------------------------------
rt_unit_remove() removes queue membership via q_remove()/replq_remove()
but does not clear the RTDS_delayed_runq_add or RTDS_scheduled flags.
If a vCPU is removed while it is being context-switched off a pCPU (i.e.,
RTDS_scheduled is set and RTDS_delayed_runq_add may be set),
rt_context_saved() will later clear RTDS_scheduled and, finding
RTDS_delayed_runq_add set, will re-insert the removed vCPU into the run
queue via runq_insert() + runq_tickle(). This results in a stale vCPU
reference on the scheduler's run queue, belonging to a domain that may be
in the process of destruction or migration.
Suggested fix: in rt_unit_remove(), explicitly clear RTDS_delayed_runq_add
and RTDS_scheduled flags after removing queue membership, so that
rt_context_saved() cannot re-insert a removed vCPU.
We would appreciate any feedback on these findings. We are happy to
prepare patches for any of the issues the community considers worth
fixing.
Best regards,
Oleksii Moisieiev


--------------ZnOiZ0itnUU4M7pRjwde1saL--