All of lore.kernel.org
 help / color / mirror / Atom feed
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
Subject: Re: [RFC PATCH] sched: fix hierarchical order in rq->leaf_cfs_rq_list
Date: Wed, 1 Jun 2016 14:31:40 +0200	[thread overview]
Message-ID: <20160601123140.GW3192@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1464083710-4370-1-git-send-email-vincent.guittot@linaro.org>

On Tue, May 24, 2016 at 11:55:10AM +0200, Vincent Guittot wrote:
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 218f8e8..6d3fbf2 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -290,15 +290,31 @@ static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
>  		 * Ensure we either appear before our parent (if already
>  		 * enqueued) or force our parent to appear after us when it is
>  		 * enqueued.  The fact that we always enqueue bottom-up
> +		 * reduces this to two cases and a specila case for the root

'special'

> +		 * cfs_rq.
>  		 */
>  		if (cfs_rq->tg->parent &&
>  		    cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))]->on_list) {
> +			/* Add the child just before its parent */
> +			list_add_tail_rcu(&cfs_rq->leaf_cfs_rq_list,
> +				&(cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))]->leaf_cfs_rq_list));
> +			rq_of(cfs_rq)->leaf_alone = &rq_of(cfs_rq)->leaf_cfs_rq_list;
> +		} else if (!cfs_rq->tg->parent) {
> +			/*
> +			 * cfs_rq without parent should be
> +			 * at the end of the list
> +			 */
>  			list_add_tail_rcu(&cfs_rq->leaf_cfs_rq_list,
>  				&rq_of(cfs_rq)->leaf_cfs_rq_list);
> +			rq_of(cfs_rq)->leaf_alone = &rq_of(cfs_rq)->leaf_cfs_rq_list;
> +		} else {
> +			/*
> +			 * Our parent has not already been added so make sure
> +			 * that it will be put after us
> +			 */
> +			list_add_rcu(&cfs_rq->leaf_cfs_rq_list,
> +				rq_of(cfs_rq)->leaf_alone);
> +			rq_of(cfs_rq)->leaf_alone = &cfs_rq->leaf_cfs_rq_list;
>  		}
>  
>  		cfs_rq->on_list = 1;

Paul, Ben ?

This used to be critical for update_shares() (now
update_blocked_averages), but IIRC is not critical for that since PELT.

I find its more readable with like so..


Also; I feel the comments can use more love; my head hurts ;-)

---
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -286,35 +286,38 @@ static inline struct cfs_rq *group_cfs_r
 static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
 {
 	if (!cfs_rq->on_list) {
+		struct rq *rq = rq_of(cfs_rq);
+		int cpu = cpu_of(rq);
+
 		/*
 		 * Ensure we either appear before our parent (if already
 		 * enqueued) or force our parent to appear after us when it is
 		 * enqueued.  The fact that we always enqueue bottom-up
-		 * reduces this to two cases and a specila case for the root
+		 * reduces this to two cases and a special case for the root
 		 * cfs_rq.
 		 */
 		if (cfs_rq->tg->parent &&
-		    cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))]->on_list) {
+		    cfs_rq->tg->parent->cfs_rq[cpu]->on_list) {
 			/* Add the child just before its parent */
 			list_add_tail_rcu(&cfs_rq->leaf_cfs_rq_list,
-				&(cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))]->leaf_cfs_rq_list));
-			rq_of(cfs_rq)->leaf_alone = &rq_of(cfs_rq)->leaf_cfs_rq_list;
+				&(cfs_rq->tg->parent->cfs_rq[cpu]->leaf_cfs_rq_list));
+			rq->leaf_alone = &rq->leaf_cfs_rq_list;
 		} else if (!cfs_rq->tg->parent) {
 			/*
 			 * cfs_rq without parent should be
 			 * at the end of the list
 			 */
 			list_add_tail_rcu(&cfs_rq->leaf_cfs_rq_list,
-				&rq_of(cfs_rq)->leaf_cfs_rq_list);
-			rq_of(cfs_rq)->leaf_alone = &rq_of(cfs_rq)->leaf_cfs_rq_list;
+					  &rq->leaf_cfs_rq_list);
+			rq->leaf_alone = &rq->leaf_cfs_rq_list;
 		} else {
 			/*
 			 * Our parent has not already been added so make sure
 			 * that it will be put after us
 			 */
 			list_add_rcu(&cfs_rq->leaf_cfs_rq_list,
-				rq_of(cfs_rq)->leaf_alone);
-			rq_of(cfs_rq)->leaf_alone = &cfs_rq->leaf_cfs_rq_list;
+				     rq->leaf_alone);
+			rq->leaf_alone = &cfs_rq->leaf_cfs_rq_list;
 		}
 
 		cfs_rq->on_list = 1;

  parent reply	other threads:[~2016-06-01 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24  8:55 [RFC PATCH] sched: fix hierarchical order in rq->leaf_cfs_rq_list Vincent Guittot
2016-05-24  9:55 ` Vincent Guittot
2016-05-25 17:40   ` Dietmar Eggemann
2016-05-26  9:55     ` Vincent Guittot
2016-06-01 12:31   ` Peter Zijlstra [this message]
2016-06-01 17:42     ` bsegall
2016-06-02  7:42       ` 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=20160601123140.GW3192@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --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 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.