linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>, peterz@infradead.org
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org,
	kernel-team@fb.com, morten.rasmussen@arm.com, tglx@linutronix.de,
	dietmar.eggeman@arm.com, mgorman@techsingularity.com,
	vincent.guittot@linaro.org
Subject: Re: [PATCH 5/8] sched,cfs: use explicit cfs_rq of parent se helper
Date: Thu, 20 Jun 2019 12:29:22 -0400	[thread overview]
Message-ID: <c5c73fd374ed952eedc46a89af294e1d521609b2.camel@surriel.com> (raw)
In-Reply-To: <55c0dc01-24b2-bb7f-6ceb-b65c52f7b46b@arm.com>

[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]

On Thu, 2019-06-20 at 18:23 +0200, Dietmar Eggemann wrote:
> On 6/12/19 9:32 PM, Rik van Riel wrote:
> > Use an explicit "cfs_rq of parent sched_entity" helper in a few
> > strategic places, where cfs_rq_of(se) may no longer point at the
> > right runqueue once we flatten the hierarchical cgroup runqueues.
> > 
> > No functional change.
> > 
> > Signed-off-by: Rik van Riel <riel@surriel.com>
> > ---
> >  kernel/sched/fair.c | 17 +++++++++++++----
> >  1 file changed, 13 insertions(+), 4 deletions(-)
> > 
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index dcc521d251e3..c6ede2ecc935 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -275,6 +275,15 @@ static inline struct cfs_rq
> > *group_cfs_rq(struct sched_entity *grp)
> >  	return grp->my_q;
> >  }
> >  
> > +/* runqueue owned by the parent entity */
> > +static inline struct cfs_rq *group_cfs_rq_of_parent(struct
> > sched_entity *se)
> > +{
> > +	if (se->parent)
> > +		return group_cfs_rq(se->parent);
> > +
> > +	return &cfs_rq_of(se)->rq->cfs;
> > +}
> > +
> >  static inline bool list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
> >  {
> >  	struct rq *rq = rq_of(cfs_rq);
> > @@ -3298,7 +3307,7 @@ static inline int
> > propagate_entity_load_avg(struct sched_entity *se)
> >  
> >  	gcfs_rq->propagate = 0;
> >  
> > -	cfs_rq = cfs_rq_of(se);
> > +	cfs_rq = group_cfs_rq_of_parent(se);
> >  
> >  	add_tg_cfs_propagate(cfs_rq, gcfs_rq->prop_runnable_sum);
> >  
> > @@ -7779,7 +7788,7 @@ static void update_cfs_rq_h_load(struct
> > cfs_rq *cfs_rq)
> >  
> >  	WRITE_ONCE(cfs_rq->h_load_next, NULL);
> >  	for_each_sched_entity(se) {
> > -		cfs_rq = cfs_rq_of(se);
> > +		cfs_rq = group_cfs_rq_of_parent(se);
> 
> Why do you change this here? task_se_h_load() calls
> update_cfs_rq_h_load() with cfs_rq = group_cfs_rq_of_parent(se)
> because
> the task might not be on the cfs_rq yet.

Because patch 6 points cfs_rq_of(se) at the CPU's top level
cfs_rq for every task se ...

... but I guess since I have not changed where the cfs_rq_of
points for cgroup sched_entities, this change is not necessary
at this time, and I should be able to go without it, in this
function.

> But inside update_cfs_rq_h_load() the first se is derived from
> cfs_rq->tg->se[cpu_of(rq)] so in the first for_each_sched_entity()
> loop
> we should still start with group_cfs_rq() (se->my_q) ?
> 
> The system doesn't barf with these two WARN_ON's in.
> 
> @@ -7663,12 +7673,17 @@ static void update_cfs_rq_h_load(struct
> cfs_rq
> *cfs_rq)
>         unsigned long now = jiffies;
>         unsigned long load;
> 
> +       WARN_ON(se && (se != group_cfs_rq(se)->tg->se[cpu_of(rq)]));
> +
>         if (cfs_rq->last_h_load_update == now)
>                 return;
> 
>         WRITE_ONCE(cfs_rq->h_load_next, NULL);
>         for_each_sched_entity(se) {
>                 cfs_rq = group_cfs_rq_of_parent(se);
> +
> +               WARN_ON(se != group_cfs_rq(se)->tg->se[cpu_of(rq)]);
> +
>                 WRITE_ONCE(cfs_rq->h_load_next, se);
>                 if (cfs_rq->last_h_load_update == now)
>                         break;
> 
> 
> [...]
> 
> 
-- 
All Rights Reversed.

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

  reply	other threads:[~2019-06-20 16:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 19:32 [RFC] sched,cfs: flatten CPU controller runqueues Rik van Riel
2019-06-12 19:32 ` [PATCH 1/8] sched: introduce task_se_h_load helper Rik van Riel
2019-06-19 12:52   ` Dietmar Eggemann
2019-06-19 13:57     ` Rik van Riel
2019-06-19 15:18       ` Dietmar Eggemann
2019-06-19 15:55         ` Rik van Riel
2019-06-12 19:32 ` [PATCH 2/8] sched: change /proc/sched_debug fields Rik van Riel
2019-06-12 19:32 ` [PATCH 3/8] sched,fair: redefine runnable_load_avg as the sum of task_h_load Rik van Riel
2019-06-18  9:08   ` Dietmar Eggemann
2019-06-26 14:34   ` Dietmar Eggemann
2019-06-12 19:32 ` [PATCH 4/8] sched,fair: remove cfs rqs from leaf_cfs_rq_list bottom up Rik van Riel
2019-06-12 19:32 ` [PATCH 5/8] sched,cfs: use explicit cfs_rq of parent se helper Rik van Riel
2019-06-20 16:23   ` Dietmar Eggemann
2019-06-20 16:29     ` Rik van Riel [this message]
2019-06-24 11:24       ` Dietmar Eggemann
2019-06-26 15:58   ` Dietmar Eggemann
2019-06-26 16:15     ` Rik van Riel
2019-06-12 19:32 ` [PATCH 6/8] sched,cfs: fix zero length timeslice calculation Rik van Riel
2019-06-12 19:32 ` [PATCH 7/8] sched,fair: refactor enqueue/dequeue_entity Rik van Riel
2019-06-12 19:32 ` [PATCH 8/8] sched,fair: flatten hierarchical runqueues Rik van Riel
2019-06-25  9:50   ` Dietmar Eggemann
2019-06-25 13:51     ` Rik van Riel
2019-06-28 10:26   ` Dietmar Eggemann
2019-06-28 19:36     ` Rik van Riel

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=c5c73fd374ed952eedc46a89af294e1d521609b2.camel@surriel.com \
    --to=riel@surriel.com \
    --cc=dietmar.eggeman@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.com \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.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 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).