xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: George Dunlap <george.dunlap@eu.citrix.com>
Cc: ian.campbell@citrix.com, xisisu@gmail.com,
	stefano.stabellini@eu.citrix.com, lu@cse.wustl.edu,
	ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	ptxlinh@gmail.com, xumengpanda@gmail.com,
	Meng Xu <mengxu@cis.upenn.edu>,
	JBeulich@suse.com, chaowang@wustl.edu, lichong659@gmail.com,
	dgolomb@seas.upenn.edu
Subject: Re: [PATCH v2 1/4] xen: add real time scheduler rt
Date: Tue, 9 Sep 2014 11:42:01 +0200	[thread overview]
Message-ID: <1410255721.5651.32.camel@Abyss> (raw)
In-Reply-To: <540DF920.9090802@eu.citrix.com>


[-- Attachment #1.1: Type: text/plain, Size: 4183 bytes --]

On Mon, 2014-09-08 at 19:44 +0100, George Dunlap wrote:
> On 09/07/2014 08:40 PM, Meng Xu wrote:

> > +/*
> > + * update deadline and budget when deadline is in the past,
> > + * it need to be updated to the deadline of the current period
> > + */
> > +static void
> > +rt_update_helper(s_time_t now, struct rt_vcpu *svc)
> > +{
> > +    s_time_t diff = now - svc->cur_deadline;
> > +
> > +    if ( diff >= 0 )
> > +    {
> > +        /* now can be later for several periods */
> > +        long count = ( diff/svc->period ) + 1;
> > +        svc->cur_deadline += count * svc->period;
> > +        svc->cur_budget = svc->budget;
> 
> In the common case, don't we expect diff/svc->period to be a small 
> number, like 0 or 1?  
>
In general, yes. The only exception is when cur_deadline is set for the
first time. In that case, now can be arbitrary large and cur_deadline
will always be 0, so quite a few iterations may be required, possibly
taking longer than the div and the mult.

That is not an hot path anyway, so either approach would be fine in that
case. For all the other occurrences, the while{} approach is an absolute
win-win, IMO.

> If so, since division and multiplication are so 
> expensive, it might make more sense to make this a while() loop:
> 
>   while (now - svc_cur_deadline > 0 )
>   {
>    svc->cur_deadline += svc->period;
>    count++;
>   }
>   if ( count ) {
>    svc->cur_budget = svc->budget;
>    [tracing code]
>   }
> 
> And similarly for the other 64-bit division Dario was asking about below?
> 
Hehe, this is, I think, the third or fourth time I say I'd like this to
be turned into a while! :-D

If it were me doing this, I'd go for something like this:

  static void
  rt_update_helper(s_time_t now, struct rt_vcpu *svc)
  {
      if ( svc->cur_deadline > now )
          return;

      do
          svc->cur_deadline += svc->period;
      while ( svc->cur_deadline <= now );
      svc->cur_budget = svc->budget;

      [tracing]
  }

Or even just the do {} while (and below), and have the check at the call
sites (as George is also saying below).

> I probably wouldn't  make this a precondition of going in.
> 
No, I'm not strict about this either, we can do it later. I don't think
it's a big or a too disruptive change, though. :-)

> > +
> > +        /* TRACE */
> > +        {
> > +            struct {
> > +                unsigned dom:16,vcpu:16;
> > +                unsigned cur_budget_lo, cur_budget_hi;
> > +            } d;
> > +            d.dom = svc->vcpu->domain->domain_id;
> > +            d.vcpu = svc->vcpu->vcpu_id;
> > +            d.cur_budget_lo = (unsigned) svc->cur_budget;
> > +            d.cur_budget_hi = (unsigned) (svc->cur_budget >> 32);
> > +            trace_var(TRC_RT_BUDGET_REPLENISH, 1,
> > +                      sizeof(d),
> > +                      (unsigned char *) &d);
> > +        }
> > +
> > +        return;
> > +    }
> > +}
> > +
> > +static inline void
> > +__runq_remove(struct rt_vcpu *svc)
> > +{
> > +    if ( __vcpu_on_runq(svc) )
> > +        list_del_init(&svc->runq_elem);
> > +}
> > +
> > +/*
> > + * Insert svc in the RunQ according to EDF: vcpus with smaller deadlines
> > + * goes first.
> > + */
> > +static void
> > +__runq_insert(const struct scheduler *ops, struct rt_vcpu *svc)
> > +{
> > +    struct rt_private *prv = RT_PRIV(ops);
> > +    struct list_head *runq = RUNQ(ops);
>
Oh, BTW, George, what do you think about these? The case, I mean. Since
now they're  static inlines, I've been telling Meng to turn the function
names lower case.

This is, of course, a minor thing, but since we're saying the are not
major issues... :-)

> Overall, the code was pretty clean, and easy for me to read -- very much 
> like credit1 and credit2, so thanks. :-)
> 
Yep, indeed!

Regards,
Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2014-09-09  9:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-07 19:40 Introduce rt real-time scheduler for Xen Meng Xu
2014-09-07 19:40 ` [PATCH v2 1/4] xen: add real time scheduler rt Meng Xu
2014-09-08 14:32   ` George Dunlap
2014-09-08 18:44   ` George Dunlap
2014-09-09  9:42     ` Dario Faggioli [this message]
2014-09-09 11:31       ` George Dunlap
2014-09-09 12:52         ` Meng Xu
2014-09-09 12:25       ` Meng Xu
2014-09-09 12:46     ` Meng Xu
2014-09-09 16:57   ` Dario Faggioli
2014-09-09 18:21     ` Meng Xu
2014-09-11  8:44       ` Dario Faggioli
2014-09-11 13:49         ` Meng Xu
2014-09-07 19:40 ` [PATCH v2 2/4] libxc: add rt scheduler Meng Xu
2014-09-08 14:38   ` George Dunlap
2014-09-08 14:50   ` Ian Campbell
2014-09-08 14:53   ` Dario Faggioli
2014-09-07 19:41 ` [PATCH v2 3/4] libxl: " Meng Xu
2014-09-08 15:19   ` George Dunlap
2014-09-09 12:59     ` Meng Xu
2014-09-07 19:41 ` [PATCH v2 4/4] xl: introduce " Meng Xu
2014-09-08 16:06   ` George Dunlap
2014-09-08 16:16     ` Dario Faggioli
2014-09-09 13:14     ` Meng Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410255721.5651.32.camel@Abyss \
    --to=dario.faggioli@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=chaowang@wustl.edu \
    --cc=dgolomb@seas.upenn.edu \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=lichong659@gmail.com \
    --cc=lu@cse.wustl.edu \
    --cc=mengxu@cis.upenn.edu \
    --cc=ptxlinh@gmail.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xisisu@gmail.com \
    --cc=xumengpanda@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).