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

Re: [Xen-devel] xen credit



On Mon, Apr 15, 2013 at 8:35 PM, zhangwqh <zhangwqh@xxxxxxx> wrote:
> Hi all,
>
> Now I am reading the source code sched-credit. The xen version is 4.2.1.  I
> can not fully understand two places.

It's better if you stick to a single question per e-mail.


> Other question is the member s_time_t start_time in structure struct
> csched_vcpu. The meaning and function for this variable?
> I do not know why when a vcpu is descheduled, its start_time - now, why a
> vcpu is scheduled, its start_time + now?
> deschedule:
> if ( !is_idle_vcpu(scurr->vcpu) )
>     {
>         /* Update credits of a non-idle VCPU. */
>         burn_credits(scurr, now);
>         scurr->start_time -= now;
>     }
>
> schedule:
> if ( !tasklet_work_scheduled
>          && prv->ratelimit_us
>          && vcpu_runnable(current)
>          && !is_idle_vcpu(current)
>          && runtime < MICROSECS(prv->ratelimit_us) )
>     {
>         snext = scurr;
>         snext->start_time += now;
>         perfc_incr(delay_ms);
>         tslice = MICROSECS(prv->ratelimit_us);
>         ret.migrated = 0;
>         goto out;
>     }
>
> Anybody can give me some advice for these problems? Thank you in advance!

If you use "git blame" (or "hg annotate"), you'll find that the lines
in question were changed in changeset 4f74c85e.

That changeset has a comment briefly explaining the idea:

    credit scheduler: fix credits overflow

    In changing credits-per-tick from 100 to 1000000, a possible overflow
    was introduced in the accounting algorithm, when credit totals (which
    can be in the millions) gets multiplied by a weight (typically 256):
    th eresult can easily overflow a signed 32-bit variable.

    Fix this by reverting to 100 credits per tick, and maintain long-term
    fairness/correctness by tracking at the nanosecond level exactly how
    much execution time has been accounted to each VCPU. We do this by
    rounding execution time so far to nearest number of credits, but then
    remember the VCPU's 'partial credit balance'.

    Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>

The key phrase there is "remembering the VCPU's partial credit balance'.

 -George

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


 


Rackspace

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