mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Paul Turner <pjt@google.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Mike Galbraith <efault@gmx.de>, Alex Shi <alex.shi@intel.com>,
	Preeti U Murthy <preeti@linux.vnet.ibm.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Namhyung Kim <namhyung@kernel.org>, Lei Wen <leiwen@marvell.com>,
	Rik van Riel <riel@surriel.com>, Joonsoo Kim <js1304@gmail.com>
Subject: Re: [PATCH 07/10] sched, fair: Optimize find_busiest_queue()
Date: Mon, 26 Aug 2013 14:07:15 +0200	[thread overview]
Message-ID: <20130826120715.GK31370@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <CAPM31RKTZYsZ6V6qjBNwZfE0i0Tk3fgeH_rxnDoG=pM24-TG_g@mail.gmail.com>

On Sat, Aug 24, 2013 at 03:33:59AM -0700, Paul Turner wrote:
> On Mon, Aug 19, 2013 at 9:01 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> > +++ b/kernel/sched/fair.c
> > @@ -4977,7 +4977,7 @@ static struct rq *find_busiest_queue(str
> >         unsigned long busiest_load = 0, busiest_power = SCHED_POWER_SCALE;
> >         int i;
> >
> > -       for_each_cpu(i, sched_group_cpus(group)) {
> > +       for_each_cpu_and(i, sched_group_cpus(group), env->cpus) {
> >                 unsigned long power = power_of(i);
> >                 unsigned long capacity = DIV_ROUND_CLOSEST(power,
> >                                                            SCHED_POWER_SCALE);
> > @@ -4986,9 +4986,6 @@ static struct rq *find_busiest_queue(str
> >                 if (!capacity)
> >                         capacity = fix_small_capacity(env->sd, group);
> >
> > -               if (!cpumask_test_cpu(i, env->cpus))
> > -                       continue;
> > -
> >                 rq = cpu_rq(i);
> >                 wl = weighted_cpuload(i);
> 
> There's no need to actually do the divisions immediately below this also.
> 
> e.g.
>   unsigned long max_load_power = SCHED_POWER_SCALE;
>   ...
>   if (wl * max_load_power > max_load * power) {
>    max_load = wl;
>    max_load_power = power;
>    ...
> 
> This would actually end up being a little more accurate even.
> 
> [ Alternatively without caching max_load_power we could compare wl *
> power vs max_load * SCHED_POWER_SCALE. ]

You've got me confused again. You're talking about something like the
below?

I suppose the problem with that is that we could keep selecting the
busiest rq with an unmovable task due to:

move_tasks():
		if ((load / 2) > env->imbalance)
			goto next;

That said, the condition in fbq() should at least be modified to match
this. Now the entire capacity crap comes from:

  bdb94aa sched: Try to deal with low capacity

But thinking a little more about it, if power drops that low imbalance
is likely to be _huge_ and we'd not meet that condition. Now if only I
wrote a more comprehensive Changelog and explained why that wouldn't be
the case. /me kicks himself.

---
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4990,28 +4990,12 @@ static struct sched_group *find_busiest_
 static struct rq *find_busiest_queue(struct lb_env *env,
 				     struct sched_group *group)
 {
-	struct rq *busiest = NULL, *rq;
 	unsigned long busiest_load = 0, busiest_power = 1;
+	struct rq *busiest = NULL;
 	int i;
 
 	for_each_cpu_and(i, sched_group_cpus(group), env->cpus) {
-		unsigned long power = power_of(i);
-		unsigned long capacity = DIV_ROUND_CLOSEST(power,
-							   SCHED_POWER_SCALE);
-		unsigned long wl;
-
-		if (!capacity)
-			capacity = fix_small_capacity(env->sd, group);
-
-		rq = cpu_rq(i);
-		wl = weighted_cpuload(i);
-
-		/*
-		 * When comparing with imbalance, use weighted_cpuload()
-		 * which is not scaled with the cpu power.
-		 */
-		if (capacity && rq->nr_running == 1 && wl > env->imbalance)
-			continue;
+		unsigned long wl = weighted_cpuload(i);
 
 		/*
 		 * For the load comparisons with the other cpu's, consider
@@ -5027,7 +5011,7 @@ static struct rq *find_busiest_queue(str
 		if (wl * busiest_power > busiest_load * power) {
 			busiest_load = wl;
 			busiest_power = power;
-			busiest = rq;
+			busiest = cpu_rq(i);
 		}
 	}
 


  reply	other threads:[~2013-08-26 12:07 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19 16:00 [PATCH 00/10] Various load-balance cleanups/optimizations -v2 Peter Zijlstra
2013-08-19 16:00 ` [PATCH 01/10] sched: Remove one division operation in find_busiest_queue() Peter Zijlstra
2013-08-22  8:58   ` Paul Turner
2013-08-22 10:25     ` Peter Zijlstra
2013-08-19 16:01 ` [PATCH 02/10] sched: Factor out code to should_we_balance() Peter Zijlstra
2013-08-22  9:58   ` Paul Turner
2013-08-22 10:42     ` Peter Zijlstra
2013-08-23  4:51       ` Joonsoo Kim
2013-08-23 11:37       ` Paul Turner
2013-08-19 16:01 ` [PATCH 03/10] sched: Clean-up struct sd_lb_stat Peter Zijlstra
2013-08-24 10:09   ` Paul Turner
2013-08-26 11:38     ` Peter Zijlstra
2013-08-26  2:56   ` Lei Wen
2013-08-26  4:36     ` Paul Turner
2013-08-26  8:42       ` Lei Wen
2013-08-19 16:01 ` [PATCH 04/10] sched, fair: Shrink sg_lb_stats and play memset games Peter Zijlstra
2013-08-21  2:08   ` Joonsoo Kim
2013-08-21  2:20     ` Joonsoo Kim
2013-08-21  8:38       ` Peter Zijlstra
2013-08-21  8:35     ` Peter Zijlstra
2013-08-24 10:15   ` Paul Turner
2013-08-26 11:46     ` Peter Zijlstra
2013-08-19 16:01 ` [PATCH 05/10] sched, fair: Remove duplicate load_per_task computations Peter Zijlstra
2013-08-19 16:01 ` [PATCH 06/10] sched, fair: Make group power more consitent Peter Zijlstra
2013-08-23  3:40   ` Preeti U Murthy
2013-08-19 16:01 ` [PATCH 07/10] sched, fair: Optimize find_busiest_queue() Peter Zijlstra
2013-08-23  8:11   ` Preeti U Murthy
2013-08-23 10:03     ` Peter Zijlstra
2013-08-23 10:54       ` Preeti U Murthy
2013-08-24 10:33   ` Paul Turner
2013-08-26 12:07     ` Peter Zijlstra [this message]
2013-08-27  9:13       ` Paul Turner
2013-08-19 16:01 ` [PATCH 08/10] sched, fair: Rework and comment the group_imb code Peter Zijlstra
2013-08-19 16:01 ` [PATCH 09/10] sched, fair: Fix the sd_parent_degenerate() code Peter Zijlstra
2013-08-24 10:45   ` Paul Turner
2013-08-26 12:09     ` Peter Zijlstra
2013-08-26 21:49       ` Rik van Riel
2013-08-27  9:05         ` Paul Turner
2013-08-19 16:01 ` [RFC][PATCH 10/10] sched, fair: Rewrite group_imb trigger Peter Zijlstra
2013-08-21  2:09 ` [PATCH 00/10] Various load-balance cleanups/optimizations -v2 Joonsoo Kim
2013-08-28  8:55 ` [RFC][PATCH 11/10] sched, fair: Reduce local_group logic Peter Zijlstra
2013-08-28  8:57   ` Peter Zijlstra
2013-08-28  9:16   ` Peter Zijlstra
2013-08-28 11:14 ` [PATCH 12/10] sched, fair: Fix group power_orig computation Peter Zijlstra
2013-08-28 11:15 ` [PATCH 13/10] sched, fair: Rework and comment the group_capacity code Peter Zijlstra
2013-08-28 11:16 ` [RFC][PATCH 14/10] sched, fair: Fix the group_capacity computation Peter Zijlstra
2013-09-04  7:44   ` 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=20130826120715.GK31370@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=alex.shi@intel.com \
    --cc=efault@gmx.de \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=js1304@gmail.com \
    --cc=leiwen@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=morten.rasmussen@arm.com \
    --cc=namhyung@kernel.org \
    --cc=pjt@google.com \
    --cc=preeti@linux.vnet.ibm.com \
    --cc=riel@surriel.com \
    --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

Powered by JetHome