All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Whitehead <josh.whitehead@dornerworks.com>
To: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Robert VanVossen <robert.vanvossen@dornerworks.com>,
	Xen-devel <xen-devel@lists.xen.org>,
	Nate Studer <nate.studer@gmail.com>
Subject: Re: [RFC PATCH 1/4] Implement cbs algorithm, remove extra queues, latency scaling, and weight support from sedf
Date: Thu, 26 Jun 2014 16:18:32 -0400	[thread overview]
Message-ID: <53AC8018.4090402@dornerworks.com> (raw)
In-Reply-To: <1403021178.16864.190.camel@Solace>

On 6/17/2014 12:06 PM, Dario Faggioli wrote:
> Although very hard, I tried to have a look at the CBS implementation
> (so, some of the '+' hunks):
> 
> On ven, 2014-06-13 at 15:58 -0400, Josh Whitehead wrote:
>> ---
> 
>> @@ -410,49 +301,59 @@ static void desched_edf_dom(s_time_t now, struct vcpu* d)
>>    
>>      __del_from_queue(d);
>>  
>> -    /*
>> -     * Manage bookkeeping (i.e. calculate next deadline, memorise
>> -     * overrun-time of slice) of finished domains.
>> -     */
>> +#ifdef SEDF_STATS
>> +    /* Manage deadline misses */
>> +    if ( unlikely(inf->deadl_abs < now) )
>> +    {
>> +        inf->miss_tot++;
>> +        inf->miss_time += inf->cputime;
>> +    }
>> +#endif
>> +
>> +    /* Manage overruns */
>>      if ( inf->cputime >= inf->slice )
>>      {
>>          inf->cputime -= inf->slice;
>> -  
>> -        if ( inf->period < inf->period_orig )
>> -        {
>> -            /* This domain runs in latency scaling or burst mode */
>> -            inf->period *= 2;
>> -            inf->slice  *= 2;
>> -            if ( (inf->period > inf->period_orig) ||
>> -                 (inf->slice > inf->slice_orig) )
>> -            {
>> -                /* Reset slice and period */
>> -                inf->period = inf->period_orig;
>> -                inf->slice = inf->slice_orig;
>> -            }
>> -        }
>>  
>>          /* Set next deadline */
>>          inf->deadl_abs += inf->period;
>> +
>> +        /* Ensure that the cputime is always less than slice */
>> +        if ( unlikely(inf->cputime > inf->slice) )
>> +        {
>> +#ifdef SEDF_STATS
>> +            inf->over_tot++;
>> +            inf->over_time += inf->cputime;
>> +#endif
>> +
>> +            /* Make up for the overage by pushing the deadline
>> +               into the future */
>> +            inf->deadl_abs += ((inf->cputime / inf->slice)
>> +                               * inf->period) * 2;
>> +            inf->cputime -= (inf->cputime / inf->slice) * inf->slice;
>> +        }
>>
> Can you enlighten me a bit about the math here? I see what you're up to,
> but I'm not sure I understand the '*2'...
> 
Ah, the '*2' is not necessary, it may be a leftover from an experiment we were
doing at one point.  This was something we caught as well but apparently it got
overlooked before we submitted the series.  I will make sure to update this for
the V2 patch.

>> +        /* Ensure that the start of the next period is in the future */
>> +        if ( unlikely(PERIOD_BEGIN(inf) < now) )
>> +            inf->deadl_abs += 
>> +                (DIV_UP(now - PERIOD_BEGIN(inf),
>> +                        inf->period)) * inf->period;
>>      }
> 
>> @@ -1100,62 +663,65 @@ static void sedf_wake(const struct scheduler *ops, struct vcpu *d)
>>      inf->block_tot++;
>>  #endif
>>  
>> -    if ( unlikely(now < PERIOD_BEGIN(inf)) )
>> -    {
>> -        /* Unblocking in extra-time! */
>> -        if ( inf->status & EXTRA_WANT_PEN_Q )
>> +    if ( sedf_soft(d) )
>> +    {
>> +        /* Apply CBS rule
>> +         * Where:
>> +         *      c == Remaining server slice == (inf->slice - cpu_time) 
>> +         *      d == Server (vcpu) deadline  == inf->deadl_abs
>> +         *      r == Wake-up time of vcpu    == now
>> +         *      U == Server (vcpu) bandwidth == (inf->slice / inf->period)
>> +         *
>> +         * if c>=(d-r)*U  --->  
>> +         *      (inf->slice - cputime) >= (inf->deadl_abs - now) * inf->period
>> +         *
> Well, I think it's rather:
> 
>   (inf->slice - cputime) >= (inf->deadl_abs - now) *
>                               (inf->slice / inf->period)
> 
> It's only the comment that is wrong, though, the code is ok.
> 
Yes, just a typo in the comments, we will correct that.

>> +         * If true, push deadline back by one period and refresh slice, else
>> +         * use current slice and deadline.
>> +         */
>> +        if((inf->slice - inf->cputime) >= 
>> +            ((inf->deadl_abs - now) * (inf->slice / inf->period)))
>>          {
>>
> You can shuffle this a bit more, and avoid the '/'.
> 
> The condition above can be rewritten as:
> 
>   c >= (d-r) * (inf->slide/inf->period)
> 
> i.e.:
> 
>   c * inf->period >= (d-r) * inf->slice
> 
> and this, the code can be rewritten as:
> 
>   if ((inf->slice - inf->cputime) * inf->period >=
>       (inf->deadl_abs - now) * inf->slice)
> 
> which I think it's better. One may worry about the fact that the
> multiplication can overflow, but that's really unlikely, since all the
> involved time values are relative (i.e., remaining runtime, time to
> deadline, etc).
> 
> Anyway, let's cross that bridge when we get to it.
>
This is a good point- because of the new nature of the scheduler we had not made
any attempts at simplification yet, but rather attempted to keep it as apparent
and straightforward as possible until we were positive everything was working
correctly.  This would certainly be a good simplification and I agree the
multiplication overflow is highly unlikely.  If you would like I can make this
update in the V2, or we can leave it until we get any other bugs ironed out,
whichever you think would be easiest.  Thanks!

- Josh Whitehead

> Regards,
> Dario
> 

  reply	other threads:[~2014-06-26 20:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13 19:58 [RFC PATCH 0/4] Repurpose SEDF Scheduler for Real-time use Josh Whitehead
2014-06-13 19:58 ` [RFC PATCH 1/4] Implement cbs algorithm, remove extra queues, latency scaling, and weight support from sedf Josh Whitehead
2014-06-17 15:43   ` Dario Faggioli
2014-06-26 20:17     ` Joshua Whitehead
2014-06-28  2:19       ` Dario Faggioli
2014-06-17 16:06   ` Dario Faggioli
2014-06-26 20:18     ` Joshua Whitehead [this message]
2014-06-28  2:27       ` Dario Faggioli
2014-06-13 19:58 ` [RFC PATCH 2/4] Add cbs parameter support to xl tool stack, remove defunct sedf parameters Josh Whitehead
2014-06-17 15:02   ` Dario Faggioli
2014-06-26 19:55     ` Joshua Whitehead
2014-06-13 19:58 ` [RFC PATCH 3/4] Updated comments/variables to reflect cbs, fixed formatting and confusing comments/variables Josh Whitehead
2014-06-16  9:33   ` Jan Beulich
2014-06-16 15:29     ` George Dunlap
2014-06-17 16:11       ` Dario Faggioli
2014-06-17 17:28         ` Dario Faggioli
2014-06-25 20:13           ` Meng Xu
2014-06-26 21:24           ` Joshua Whitehead
2014-06-28  2:13             ` Dario Faggioli
2014-06-18 11:18         ` George Dunlap
2014-06-26 21:30           ` Joshua Whitehead
2014-06-26 21:23         ` Joshua Whitehead
2014-06-28  2:09           ` Dario Faggioli
2014-06-13 19:58 ` [RFC PATCH 4/4] Changed filenames with sedf to cbs to reflect the actual scheduler Josh Whitehead
2014-06-16  7:25 ` [RFC PATCH 0/4] Repurpose SEDF Scheduler for Real-time use Dario Faggioli
2014-06-17 14:44 ` Dario Faggioli
2014-06-26 19:53   ` Joshua Whitehead

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=53AC8018.4090402@dornerworks.com \
    --to=josh.whitehead@dornerworks.com \
    --cc=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=nate.studer@gmail.com \
    --cc=robert.vanvossen@dornerworks.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.