[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [XEN PATCH v2] xen/arinc653: fix delay in the start of major frame


  • To: Nathan Studer <Nathan.Studer@xxxxxxxxxxxxxxx>, Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Choi, Anderson" <Anderson.Choi@xxxxxxxxxx>
  • Date: Fri, 18 Jul 2025 01:38:58 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=boeing.com; dmarc=pass action=none header.from=boeing.com; dkim=pass header.d=boeing.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector5401; 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=LzVPC0qwenVfhnKWiBJ8DO6rwXhZgBlch2qKiHwXgKw=; b=d8GLeI5sD/y5+LsBmLUr7OSdS8ZZ2VZPsnUuWjvU52woX+SayDvxlGblE9e5qGjcVN4ZaDpq7jFCN1R9tew4QTO5AxWgAsKTpcxf2bP2DQJuXkSn01PvTIvYHw646V4a1Au8no65bs6tfdsbH+sPG5AcpUrVr99hxDr2xlR2q8wehYpI3Zu0AsWLjbBVPc7gzCvuyIjp+j00VP1C75WNpR6LhPo3WfuTeuroaWY4XJ8zKeB4gYhFB25V2dVW35w0ou1Li03vF92Q1A8M7RyZ/r7y2MqErSF5Bij4bKSbtwySM46yzhXZ6eCATtFR3dZn9eIsMcF36ZjZygyxBbw/oQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector5401; d=microsoft.com; cv=none; b=FtcEZyZf6jZzfrzhzS8+J9bZopJzvJesHSsnDL2SDXsvX3AIttvOrA4soU+lPYcii0FIfVbnoqikZD/Ee4nIQSCiAzmRGkqgEO/jrJ7BW0NthkrMcT3jO1QSmwhnAnXww7xq1Yw/vPPgI2DJ4xolF6eZWBuQkP5k8WMWH6pYaOYEteP9iyjyCRLxb3mU4Pv4++2Lh8kdjf6S0j3MKXaLP147mJvbanYoHGDqSkUvPGgbKCCZ5i5ry+Fov5q+8Cvcez9H2N1oOYJWtOmYYV367yGkKb2Uk+hHznSARVmkTNReVxFVrrxtoNknaJfdwwMeRt8F+3uX/bV0y20HOHkB9A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=boeing.com;
  • Cc: "Weber (US), Matthew L" <matthew.l.weber3@xxxxxxxxxx>, "Whitehead (US), Joshua C" <joshua.c.whitehead@xxxxxxxxxx>, Stewart Hildebrand <stewart@xxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 18 Jul 2025 01:39:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHb9z26goGsZ4LY30285h3BvJPydLQ3FIeg
  • Thread-topic: [XEN PATCH v2] xen/arinc653: fix delay in the start of major frame

> EXT email: be mindful of links/attachments.
> 
> On 7/17/25 9:21, Hildebrand, Stewart wrote:
else +        { +            sched_priv->next_switch_time =
>>> sched_priv->next_major_frame + +               
>>> sched_priv->schedule[0].runtime; +           
>>> sched_priv->next_major_frame += sched_priv->major_frame; +        } + 
>>>   }
>> 
>> There's no need for the above loop, this can be fixed by subtracting
>> the remainder (modulus major_frame). E.g.:
>> 
>>     if ( now >= sched_priv->next_major_frame )
>>     {
>>         s_time_t major_frame = sched_priv->num_schedule_entries < 1
>>                                ? DEFAULT_TIMESLICE
>>                                : sched_priv->major_frame;
>>         s_time_t remainder = (now - sched_priv->next_major_frame) %
>> major_frame;
>> 
>>         sched_priv->sched_index = 0;
>>         sched_priv->next_major_frame = now - remainder + major_frame;
>>         sched_priv->next_switch_time = now - remainder +
>>                                        (sched_priv->num_schedule_entries < 1
>>                                         ? DEFAULT_TIMESLICE
>>                                         : sched_priv->schedule[0].runtime);
>>     }
> 

Stewart,

I appreciate your suggestion to eliminate the while loop.
What about initializing major_frame and schedule[0].runtime to 
DEFAULT_TIMESLICE at a653sched_init() and use them until the real parameters 
are set as below to eliminate the if branch?

diff --git a/xen/common/sched/arinc653.c b/xen/common/sched/arinc653.c
index 930361fa5c..73ce5cdfaf 100644
--- a/xen/common/sched/arinc653.c
+++ b/xen/common/sched/arinc653.c
@@ -361,6 +361,8 @@ a653sched_init(struct scheduler *ops)
     ops->sched_data = prv;

     prv->next_major_frame = 0;
+    prv->major_frame = DEFAULT_TIMESLICE;
+    prv->schedule[0].runtime = DEFAULT_TIMESLICE;
     spin_lock_init(&prv->lock);
     INIT_LIST_HEAD(&prv->unit_list);

static void cf_check
a653sched_do_schedule(
<snip>
    /* Switch to next major frame directly eliminating the use of loop */
    if ( now >= sched_priv->next_major_frame )
    {
        s_time_t major_frame = sched_priv->major_frame;
        s_time_t remainder = (now - sched_priv->next_major_frame) % major_frame;

        sched_priv->sched_index = 0;
        sched_priv->next_major_frame = now - remainder + major_frame;
        sched_priv->next_switch_time = now - remainder + 
sched_priv->schedule[0].runtime;
    }

> The direct method suggested by Stew is preferable in the unusual case where
> many major frames are missed.  (We have only seen that happen when using
> a debugger.)
> 
> To help uncover any issues like the one this patch addresses in the future we
> may also want to follow up this commit with a change to make scheduler
> misses more obvious.  Something like the following:
> 
> commit e95cbc9078127c412bd1605d93cb97837751b5b4 (HEAD -> master)
> Author: Nathan Studer <nathan.studer@xxxxxxxxxxxxxxx>
> Date:   Thu Jul 17 12:43:39 2025 -0400
> 
>     Do not silently skip frame overruns
> diff --git a/xen/common/sched/arinc653.c b/xen/common/sched/arinc653.c
> index 2d0d3bcbb3..a2c1c66c27 100644
> --- a/xen/common/sched/arinc653.c
> +++ b/xen/common/sched/arinc653.c
> @@ -523,9 +523,17 @@ a653sched_do_schedule(
>      a653sched_priv_t *sched_priv = SCHED_PRIV(ops);
>      const unsigned int cpu = sched_get_resource_cpu(smp_processor_id());
>      unsigned long flags;
> +    unsigned int oindex;
> +    unsigned int missed;
> 
>      spin_lock_irqsave(&sched_priv->lock, flags);
> +    if ( now > (sched_priv->next_major_frame +  sched_priv->major_frame))
> +    {
> +        missed = (now - sched_priv->next_major_frame) / sched_priv-
>> major_frame;
> +        printk(XENLOG_ERR, "Missed %d major frame(s)!\n", missed);
> +    }
> +
>      /* Switch to next major frame while handling potentially missed frames */
> @@ -544,6 +552,7 @@ a653sched_do_schedule(
>          }
>      }
> +    oindex = sched_priv->sched_index;
>      /* Switch minor frame or find correct minor frame after a miss */
>      while ( (now >= sched_priv->next_switch_time) &&
>              (sched_priv->sched_index <
>              sched_priv->num_schedule_entries) ) @@ -553,6 +562,12 @@
>              a653sched_do_schedule(
>              sched_priv->schedule[sched_priv->sched_index].runtime;
>      }
> +    if ( (oindex - sched_priv->sched_index) > 1)
> +    {
> +        missed = (oindex - sched_priv->sched_index - 1);
> +        printk(XENLOG_WARNING, "Missed %d minor frame(s)!\n", missed);
> +    }
> +
>      /*

Nathan,

Do we need a comma (,) between XENLOG_WARNING and the quoted string when 
calling printk()?
And wouldn't the log be printed every time a new minor frame starts, for 
example oindex = 0 and sched_priv->sched_index = 1?
I think you meant to use the condition "if (sched_priv->sched_index - oindex) > 
1" to check minor frame misses?

Thanks,
Anderson





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.