mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Ingo Molnar <mingo@kernel.org>, Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: linux-kernel@vger.kernel.org, Mike Galbraith <efault@gmx.de>,
	Paul Turner <pjt@google.com>, 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>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 06/10] sched, fair: Make group power more consitent
Date: Mon, 19 Aug 2013 18:01:04 +0200	[thread overview]
Message-ID: <20130819160425.452928356@infradead.org> (raw)
In-Reply-To: <20130819160058.539049611@infradead.org>

[-- Attachment #1: peterz-more-bfg-cleanups-2.patch --]
[-- Type: text/plain, Size: 5436 bytes --]

For easier access, less dereferences and more consisent value, store
the group power in update_sg_lb_stats() and use it thereafter. The
actual value in sched_group::sched_group_power::power can change
throughout the load-balance pass if we're unlucky.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
 kernel/sched/fair.c |   49 ++++++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4284,6 +4284,7 @@ struct sg_lb_stats {
 	unsigned long group_load; /* Total load over the CPUs of the group */
 	unsigned long sum_weighted_load; /* Weighted load of group's tasks */
 	unsigned long load_per_task;
+	unsigned long group_power;
 	unsigned int sum_nr_running; /* Nr tasks running in the group */
 	unsigned int group_capacity;
 	unsigned int idle_cpus;
@@ -4320,11 +4321,11 @@ static inline void init_sd_lb_stats(stru
 	 *		   long unsigned int  avg_load;            //    40  8
 	 *		   long unsigned int  group_load;          //    48  8
 	 *	           ...
-	 *	   } busiest_stat;                                 //    40 56
-	 *	   struct sg_lb_stats	      this_stat;	   //    96 56
+	 *	   } busiest_stat;                                 //    40 64
+	 *	   struct sg_lb_stats	      this_stat;	   //   104 64
 	 *
-	 *	   // size: 152, cachelines: 3, members: 7
-	 *	   // last cacheline: 24 bytes
+	 *	   // size: 168, cachelines: 3, members: 7
+	 *	   // last cacheline: 40 bytes
 	 * };
 	 *
 	 * Skimp on the clearing to avoid duplicate work. We can avoid clearing
@@ -4574,7 +4575,8 @@ static inline void update_sg_lb_stats(st
 		update_group_power(env->sd, env->dst_cpu);
 
 	/* Adjust by relative CPU power of the group */
-	sgs->avg_load = (sgs->group_load*SCHED_POWER_SCALE) / group->sgp->power;
+	sgs->group_power = group->sgp->power;
+	sgs->avg_load = (sgs->group_load*SCHED_POWER_SCALE) / sgs->group_power;
 
 	/*
 	 * Consider the group unbalanced when the imbalance is larger
@@ -4593,7 +4595,7 @@ static inline void update_sg_lb_stats(st
 		sgs->group_imb = 1;
 
 	sgs->group_capacity =
-		DIV_ROUND_CLOSEST(group->sgp->power, SCHED_POWER_SCALE);
+		DIV_ROUND_CLOSEST(sgs->group_power, SCHED_POWER_SCALE);
 
 	if (!sgs->group_capacity)
 		sgs->group_capacity = fix_small_capacity(env->sd, group);
@@ -4696,7 +4698,7 @@ static inline void update_sd_lb_stats(st
 
 		/* Now, start updating sd_lb_stats */
 		sds->total_load += sgs->group_load;
-		sds->total_pwr += sg->sgp->power;
+		sds->total_pwr += sgs->group_power;
 
 		if (!local_group && update_sd_pick_busiest(env, sds, sg, sgs)) {
 			sds->busiest = sg;
@@ -4744,8 +4746,9 @@ static int check_asym_packing(struct lb_
 	if (env->dst_cpu > busiest_cpu)
 		return 0;
 
-	env->imbalance = DIV_ROUND_CLOSEST(sds->busiest_stat.avg_load *
-				sds->busiest->sgp->power, SCHED_POWER_SCALE);
+	env->imbalance = DIV_ROUND_CLOSEST(
+		sds->busiest_stat.avg_load * sds->busiest_stat.group_power,
+		SCHED_POWER_SCALE);
 
 	return 1;
 }
@@ -4775,7 +4778,7 @@ void fix_small_imbalance(struct lb_env *
 
 	scaled_busy_load_per_task =
 		(busiest->load_per_task * SCHED_POWER_SCALE) /
-		sds->busiest->sgp->power;
+		busiest->group_power;
 
 	if (busiest->avg_load - this->avg_load + scaled_busy_load_per_task >=
 	    (scaled_busy_load_per_task * imbn)) {
@@ -4789,32 +4792,32 @@ void fix_small_imbalance(struct lb_env *
 	 * moving them.
 	 */
 
-	pwr_now += sds->busiest->sgp->power *
+	pwr_now += busiest->group_power *
 			min(busiest->load_per_task, busiest->avg_load);
-	pwr_now += sds->this->sgp->power *
+	pwr_now += this->group_power *
 			min(this->load_per_task, this->avg_load);
 	pwr_now /= SCHED_POWER_SCALE;
 
 	/* Amount of load we'd subtract */
 	tmp = (busiest->load_per_task * SCHED_POWER_SCALE) /
-		sds->busiest->sgp->power;
+		busiest->group_power;
 	if (busiest->avg_load > tmp) {
-		pwr_move += sds->busiest->sgp->power *
+		pwr_move += busiest->group_power *
 			    min(busiest->load_per_task,
 				busiest->avg_load - tmp);
 	}
 
 	/* Amount of load we'd add */
-	if (busiest->avg_load * sds->busiest->sgp->power <
+	if (busiest->avg_load * busiest->group_power <
 	    busiest->load_per_task * SCHED_POWER_SCALE) {
-		tmp = (busiest->avg_load * sds->busiest->sgp->power) /
-			sds->this->sgp->power;
+		tmp = (busiest->avg_load * busiest->group_power) /
+		      this->group_power;
 	} else {
 		tmp = (busiest->load_per_task * SCHED_POWER_SCALE) /
-			sds->this->sgp->power;
+		      this->group_power;
 	}
-	pwr_move += sds->this->sgp->power *
-			min(this->load_per_task, this->avg_load + tmp);
+	pwr_move += this->group_power *
+		    min(this->load_per_task, this->avg_load + tmp);
 	pwr_move /= SCHED_POWER_SCALE;
 
 	/* Move if we gain throughput */
@@ -4859,7 +4862,7 @@ static inline void calculate_imbalance(s
 			(busiest->sum_nr_running - busiest->group_capacity);
 
 		load_above_capacity *= (SCHED_LOAD_SCALE * SCHED_POWER_SCALE);
-		load_above_capacity /= sds->busiest->sgp->power;
+		load_above_capacity /= busiest->group_power;
 	}
 
 	/*
@@ -4877,8 +4880,8 @@ static inline void calculate_imbalance(s
 
 	/* How much load to actually move to equalise the imbalance */
 	env->imbalance = min(
-		max_pull * sds->busiest->sgp->power,
-		(sds->avg_load - this->avg_load) * sds->this->sgp->power
+		max_pull * busiest->group_power,
+		(sds->avg_load - this->avg_load) * this->group_power
 	) / SCHED_POWER_SCALE;
 
 	/*



  parent reply	other threads:[~2013-08-19 16:16 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 ` Peter Zijlstra [this message]
2013-08-23  3:40   ` [PATCH 06/10] sched, fair: Make group power more consitent 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
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=20130819160425.452928356@infradead.org \
    --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