From nobody Thu Oct 30 22:41:37 2025 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=reject dis=none) header.from=boeing.com ARC-Seal: i=1; a=rsa-sha256; t=1752549465; cv=none; d=zohomail.com; s=zohoarc; b=iACt/i6Mz5rCdubImx9gigpcG/eV2zEAr61FzsRCW/WnYJ8XxpIZIjnAL4Ix8fSsKckztTq4j8dAa9ZsgkkeT6txhDvms3oZS1RDqetkvm0vxNOjDtvh8F6e0r2HJ1etg+v9oJInPgIGEXx3lb8u+rAk+53K1ilDDZ+HodhpP/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752549465; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EhlZL5UlKrzAVQK6QAoPGjZSmmgUghjXHqKNFw8hJZs=; b=nElFDbOD+2HoiKi+E+4gAcFBA+X1X3xUA2S3cOAXnP+SWC4ysmgAQVDaIFxo23YOU+o7P+IVLvuOpnPXtkNBs42Db+GUND2YIh0ORV9LMa8WZ4PWpnARbkGvkD41CBZAZyanXz56miQ0ecIHtLCdauNcyKFho8YklUBBRKZf7b8= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1752549465202692.0676136478887; Mon, 14 Jul 2025 20:17:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1043329.1413447 (Exim 4.92) (envelope-from ) id 1ubWAM-0001qx-1N; Tue, 15 Jul 2025 03:17:14 +0000 Received: by outflank-mailman (output) from mailman id 1043329.1413447; Tue, 15 Jul 2025 03:17:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubWAL-0001qq-Ug; Tue, 15 Jul 2025 03:17:13 +0000 Received: by outflank-mailman (input) for mailman id 1043329; Tue, 15 Jul 2025 03:17:13 +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 1ubWAK-0001qk-Q0 for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 03:17:12 +0000 Received: from ewa-mbsout-02.mbs.boeing.net (ewa-mbsout-02.mbs.boeing.net [130.76.20.195]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2df25187-612a-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 05:17:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ewa-mbsout-02.mbs.boeing.net (8.15.2/8.15.2/DOWNSTREAM_MBSOUT) with SMTP id 56F3H1SP046669; Mon, 14 Jul 2025 20:17:01 -0700 Received: from phx-av-01.mbs.boeing.net (phx-av-01.mbs.boeing.net [137.136.102.153]) by ewa-mbsout-02.mbs.boeing.net (8.15.2/8.15.2/8.15.2/UPSTREAM_MBSOUT) with ESMTPS id 56F3Gote046621 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Jul 2025 20:16:51 -0700 Received: from localhost (localhost [127.0.0.1]) by phx-av-01.mbs.boeing.net (8.15.2/8.15.2/DOWNSTREAM_RELAY) with SMTP id 56F3GnjZ037633; Mon, 14 Jul 2025 20:16:49 -0700 Received: from A6509144.boeing.com ([144.112.84.15]) by phx-av-01.mbs.boeing.net (8.15.2/8.15.2/UPSTREAM_RELAY) with ESMTP id 56F3Ge82037165; Mon, 14 Jul 2025 20:16:41 -0700 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" X-Inumbo-ID: 2df25187-612a-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boeing.com; s=boeing-s1912; t=1752549422; bh=EhlZL5UlKrzAVQK6QAoPGjZSmmgUghjXHqKNFw8hJZs=; h=From:To:Cc:Subject:Date:From; b=Ga11ReIU45daJCyH56jNZ+wTyDDKKkwmCbkkahe7RLDRTODgPCufhLA8hEEjHjwio OQJSUTkAw4VjpNCUHep30bUuGXpv99vIy/4oocihYQHSa5HmKApihHRjG25RCU+7wd baQgTt3fCq0uK7kakbYoufWFZzzdvlx6F4IEescCUPzaTODe4d9hH9q8fy2DElfe8e RiRN+nsJOGE2nZ4lVLXl2efVTS7Qfq0UFFj4PwUV5Oek3HR+K71mwWYLj1Jw8XbUwa cQSBtcxgRpbgOe64vWBt1KuXiWwAgAI+t5QmF4B7x//g235ILHl29RjkMRk/BjrMkj qOzB8n7K5wUfA== From: Anderson Choi To: xen-devel@lists.xenproject.org Cc: matthew.l.weber3@boeing.com, joshua.c.whitehead@boeing.com, Anderson Choi , Nathan Studer , Stewart Hildebrand , Dario Faggioli , Juergen Gross , George Dunlap , xen-devel@dornerworks.com Subject: [XEN PATCH v2] xen/arinc653: fix delay in the start of major frame Date: Tue, 15 Jul 2025 12:16:38 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-ZohoMail-DKIM: pass (identity @boeing.com) X-ZM-MESSAGEID: 1752549467793116600 Content-Type: text/plain; charset="utf-8" ARINC653 specificaion requires partition scheduling to be deterministic and periodic over time. However, the use of current timestamp (now) as the baseline to calculate next_major_frame and next_switch_time introduces a delay in the start of major frame at every period, which breaks determinism and periodicity in partition scheduling. For example, we observe 3.5 msec of accumulated delay at the 21st major frame with the following configuration. Target : qemuarm64 xen version : 4.19 (43aeacff86, x86/IRQ: constrain creator-domain-ID assert= ion) dom1 : 10 msec runtime dom2 : 10 msec runtime $ a653_sched -p Pool-arinc dom1:10 dom2:10 0.014553536 ---x d?v? runstate_change d1v0 runnable->running //1st major frame 0.034629712 ---x d?v? runstate_change d1v0 runnable->running //2nd major frame 0.397747008 |||x d?v? runstate_change d1v0 runnable->running //20th major frame 0.418066096 -||x d?v? runstate_change d1v0 runnable->running //21st major frame This is due to an inherent delta between the time value the scheduler timer is programmed to be fired with and the time value the schedule function is executed. Another observation that breaks the deterministic behavior of partition scheduling is a delayed execution of schedule(); It was called 14 msec later than programmed. 1.530603952 ---x d?v? runstate_change d1v0 runnable->running 1.564956784 --|x d?v? runstate_change d1v0 runnable->running Enforce the periodic behavior of partition scheduling by using the value next_major_frame as the base to calculate the start of major frame and the next domain switch time. Per discussion with Nathan Studer, there are odd cases the first minor frame can be also missed. In that sceanario, iterate through the schedule a= fter resyncing the expected next major frame. Signed-off-by: Anderson Choi Suggested-by: Nathan Studer --- Changes in v2: - Changed the logic to resync major frame and to find correct minor frame after a miss suggested by Nathan --- xen/common/sched/arinc653.c | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/xen/common/sched/arinc653.c b/xen/common/sched/arinc653.c index 930361fa5c..a7937ed2fd 100644 --- a/xen/common/sched/arinc653.c +++ b/xen/common/sched/arinc653.c @@ -526,27 +526,31 @@ a653sched_do_schedule( =20 spin_lock_irqsave(&sched_priv->lock, flags); =20 - if ( sched_priv->num_schedule_entries < 1 ) - sched_priv->next_major_frame =3D now + DEFAULT_TIMESLICE; - else if ( now >=3D sched_priv->next_major_frame ) + /* Switch to next major frame while handling potentially missed frames= */ + while ( now >=3D sched_priv->next_major_frame ) { - /* time to enter a new major frame - * the first time this function is called, this will be true */ - /* start with the first domain in the schedule */ sched_priv->sched_index =3D 0; - sched_priv->next_major_frame =3D now + sched_priv->major_frame; - sched_priv->next_switch_time =3D now + sched_priv->schedule[0].run= time; - } - else - { - while ( (now >=3D sched_priv->next_switch_time) && - (sched_priv->sched_index < sched_priv->num_schedule_entrie= s) ) + + if ( sched_priv->num_schedule_entries < 1 ) { - /* time to switch to the next domain in this major frame */ - sched_priv->sched_index++; - sched_priv->next_switch_time +=3D - sched_priv->schedule[sched_priv->sched_index].runtime; + sched_priv->next_major_frame +=3D DEFAULT_TIMESLICE; + sched_priv->next_switch_time =3D sched_priv->next_major_frame; } + else + { + sched_priv->next_switch_time =3D sched_priv->next_major_frame + + sched_priv->schedule[0].runtime; + sched_priv->next_major_frame +=3D sched_priv->major_frame; + } + } +=20 + /* Switch minor frame or find correct minor frame after a miss */ + while ( (now >=3D sched_priv->next_switch_time) && + (sched_priv->sched_index < sched_priv->num_schedule_entries) ) + { + sched_priv->sched_index++; + sched_priv->next_switch_time +=3D + sched_priv->schedule[sched_priv->sched_index].runtime; } =20 /* --=20 2.43.0