Re: [patch 08/18] sched: add support for throttling group entities

From: Paul Turner
Date: Mon Aug 08 2011 - 12:16:37 EST


On Mon, Aug 8, 2011 at 9:00 AM, Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> wrote:
> On Mon, 2011-08-08 at 23:46 +0800, Lin Ming wrote:
>> On Fri, Jul 22, 2011 at 12:43 AM, Paul Turner <pjt@xxxxxxxxxx> wrote:
>>
>> > +static __used void throttle_cfs_rq(struct cfs_rq *cfs_rq)
>> > +{
>> > +       struct rq *rq = rq_of(cfs_rq);
>> > +       struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg);
>> > +       struct sched_entity *se;
>> > +       long task_delta, dequeue = 1;
>> > +
>> > +       se = cfs_rq->tg->se[cpu_of(rq_of(cfs_rq))];
>> > +
>> > +       /* account load preceding throttle */
>> > +       update_cfs_load(cfs_rq, 0);
>> > +
>> > +       task_delta = cfs_rq->h_nr_running;
>> > +       for_each_sched_entity(se) {
>> > +               struct cfs_rq *qcfs_rq = cfs_rq_of(se);
>> > +               /* throttled entity or throttle-on-deactivate */
>> > +               if (!se->on_rq)
>> > +                       break;
>>
>> Does it mean it's possible that child se is unthrottled but parent se
>> is throttled?
>
> Yep..
>
>> I thought if parent group was throttled then its children should be
>> throttled too.
>> I may misunderstood the code, please correct me then.
>
> That would be costly, as throttling a parent would require throttling
> all its children (of which there can be arbitrary many).
>

In case it is not clear, the children of a throttled entity can not be
scheduled, they are implicitly throttled by virtue of their
parent/ancestor having reached its bandwidth limit (and being
throttled).

Consider the hierarchy below:
A
/ \
D B
\
C

If A and B both have bandwidth limits then B being on_rq depends on:

1. A being within its bandwidth limit, otherwise the entire hierarchy
would be dequeued
2. B being within its bandwidth limit, otherwise the hierarchy B-C
would be dequeued

B's throttle state is independent of whether A has reached its limit;
however it will not be runnable while A is throttled.

The per-cfs_rq throttle_count may be more directly in-line with what
your interpretation of "throttled"; it maintains explicit tracking of
whether or not an entity is throttled (including via its parent).

- Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/