From: Peter Zijlstra <peterz@infradead.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, pjt@google.com,
yuyang.du@intel.com, dietmar.eggemann@arm.com,
bsegall@google.com, Morten.Rasmussen@arm.com
Subject: Re: [RFC PATCH v2] sched: reflect sched_entity movement into task_group's utilization
Date: Wed, 1 Jun 2016 15:36:32 +0200 [thread overview]
Message-ID: <20160601133632.GB28447@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1464080252-17209-1-git-send-email-vincent.guittot@linaro.org>
On Tue, May 24, 2016 at 10:57:32AM +0200, Vincent Guittot wrote:
> +/*
> + * Save how much utilization has just been added/removed on cfs rq so we can
> + * propagate it across the whole tg tree
> + */
> +static void set_tg_cfs_rq_util(struct cfs_rq *cfs_rq, int delta)
> +{
> + if (cfs_rq->tg == &root_task_group)
> + return;
> +
> + cfs_rq->diff_util_avg += delta;
> +}
function name doesn't really reflect its purpose..
> +
> +/* Take into account the change of the utilization of a child task group */
This comment could be so much better... :-)
> +static void update_tg_cfs_util(struct sched_entity *se, int blocked)
> +{
> + int delta;
> + struct cfs_rq *cfs_rq;
> + long update_util_avg;
> + long last_update_time;
> + long old_util_avg;
> +
> +
> + /*
> + * update_blocked_average will call this function for root cfs_rq
> + * whose se is null. In this case just return
> + */
> + if (!se)
> + return;
> +
> + if (entity_is_task(se))
> + return 0;
> +
> + /* Get sched_entity of cfs rq */
> + cfs_rq = group_cfs_rq(se);
> +
> + update_util_avg = cfs_rq->diff_util_avg;
> +
> + if (!update_util_avg)
> + return 0;
> +
> + /* Clear pending changes */
> + cfs_rq->diff_util_avg = 0;
> +
> + /* Add changes in sched_entity utilizaton */
> + old_util_avg = se->avg.util_avg;
> + se->avg.util_avg = max_t(long, se->avg.util_avg + update_util_avg, 0);
> + se->avg.util_sum = se->avg.util_avg * LOAD_AVG_MAX;
> +
> + /* Get parent cfs_rq */
> + cfs_rq = cfs_rq_of(se);
> +
> + if (blocked) {
> + /*
> + * blocked utilization has to be synchronized with its parent
> + * cfs_rq's timestamp
> + */
> + last_update_time = cfs_rq_last_update_time(cfs_rq);
> +
> + __update_load_avg(last_update_time, cpu_of(rq_of(cfs_rq)),
> + &se->avg,
> + se->on_rq * scale_load_down(se->load.weight),
> + cfs_rq->curr == se, NULL);
> + }
> +
> + delta = se->avg.util_avg - old_util_avg;
> +
> + cfs_rq->avg.util_avg = max_t(long, cfs_rq->avg.util_avg + delta, 0);
> + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * LOAD_AVG_MAX;
> +
> + set_tg_cfs_rq_util(cfs_rq, delta);
> +}
So if I read this right it computes the utilization delta for group se's
and propagates it into the corresponding parent group cfs_rq ?
> @@ -6276,6 +6368,8 @@ static void update_blocked_averages(int cpu)
>
> if (update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq, true))
> update_tg_load_avg(cfs_rq, 0);
> + /* Propagate pending util changes to the parent */
> + update_tg_cfs_util(cfs_rq->tg->se[cpu], true);
And this is why you need the strict bottom-up thing fixed..
> @@ -8370,6 +8464,20 @@ static void detach_task_cfs_rq(struct task_struct *p)
>
> /* Catch up with the cfs_rq and remove our load when we leave */
> detach_entity_load_avg(cfs_rq, se);
> +
> + /*
> + * Propagate the detach across the tg tree to ake it visible to the
> + * root
> + */
> + for_each_sched_entity(se) {
> + cfs_rq = cfs_rq_of(se);
> +
> + if (cfs_rq_throttled(cfs_rq))
> + break;
> +
> + update_load_avg(se, 1);
> + update_tg_cfs_util(se, false);
> + }
> }
>
> static void attach_task_cfs_rq(struct task_struct *p)
> @@ -8399,8 +8507,21 @@ static void switched_from_fair(struct rq *rq, struct task_struct *p)
>
> static void switched_to_fair(struct rq *rq, struct task_struct *p)
> {
> + struct sched_entity *se = &p->se;
> + struct cfs_rq *cfs_rq;
> +
> attach_task_cfs_rq(p);
>
> + for_each_sched_entity(se) {
> + cfs_rq = cfs_rq_of(se);
> +
> + if (cfs_rq_throttled(cfs_rq))
> + break;
> +
> + update_load_avg(se, 1);
> + update_tg_cfs_util(se, false);
> + }
> +
> if (task_on_rq_queued(p)) {
> /*
> * We were most likely switched from sched_rt, so
So I would expect this to be in attach_task_cfs_rq() to mirror the
detach_task_cfs_rq().
Also, this change is somewhat independent but required for the 'flat'
util measure, right?
next prev parent reply other threads:[~2016-06-01 13:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 8:57 Vincent Guittot
2016-05-24 9:55 ` Vincent Guittot
2016-06-06 10:52 ` Dietmar Eggemann
2016-06-06 12:44 ` Vincent Guittot
2016-06-01 12:54 ` Peter Zijlstra
2016-06-01 19:45 ` Dietmar Eggemann
2016-06-05 23:58 ` Yuyang Du
2016-06-01 13:36 ` Peter Zijlstra [this message]
2016-06-01 15:26 ` Vincent Guittot
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=20160601133632.GB28447@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Morten.Rasmussen@arm.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pjt@google.com \
--cc=vincent.guittot@linaro.org \
--cc=yuyang.du@intel.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
all inboxes | Powered by JetHome®