diff options
author | Waiman Long <Waiman.Long@hpe.com> | 2015-11-25 14:09:38 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-12-04 04:34:47 -0500 |
commit | a426f99c91d1036767a7819aaaba6bd3191b7f06 (patch) | |
tree | d47b87b2576ebb2618144dd2f6416a0c8e36efd8 | |
parent | ed82b8a1ff76ed7b2709e36ed361ddd022fe2407 (diff) |
sched/fair: Avoid redundant idle_cpu() call in update_sg_lb_stats()
Part of the responsibility of the update_sg_lb_stats() function is to
update the idle_cpus statistical counter in struct sg_lb_stats. This
check is done by calling idle_cpu(). The idle_cpu() function, in
turn, checks a number of fields within the run queue structure such
as rq->curr and rq->nr_running.
With the current layout of the run queue structure, rq->curr and
rq->nr_running are in separate cachelines. The rq->curr variable is
checked first followed by nr_running. As nr_running is also accessed
by update_sg_lb_stats() earlier, it makes no sense to load another
cacheline when nr_running is not 0 as idle_cpu() will always return
false in this case.
This patch eliminates this redundant cacheline load by checking the
cached nr_running before calling idle_cpu().
Signed-off-by: Waiman Long <Waiman.Long@hpe.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Douglas Hatch <doug.hatch@hpe.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Scott J Norton <scott.norton@hpe.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1448478580-26467-2-git-send-email-Waiman.Long@hpe.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/sched/fair.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index efd664c4926e..4b0e8b8700fd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -6398,7 +6398,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, | |||
6398 | bool *overload) | 6398 | bool *overload) |
6399 | { | 6399 | { |
6400 | unsigned long load; | 6400 | unsigned long load; |
6401 | int i; | 6401 | int i, nr_running; |
6402 | 6402 | ||
6403 | memset(sgs, 0, sizeof(*sgs)); | 6403 | memset(sgs, 0, sizeof(*sgs)); |
6404 | 6404 | ||
@@ -6415,7 +6415,8 @@ static inline void update_sg_lb_stats(struct lb_env *env, | |||
6415 | sgs->group_util += cpu_util(i); | 6415 | sgs->group_util += cpu_util(i); |
6416 | sgs->sum_nr_running += rq->cfs.h_nr_running; | 6416 | sgs->sum_nr_running += rq->cfs.h_nr_running; |
6417 | 6417 | ||
6418 | if (rq->nr_running > 1) | 6418 | nr_running = rq->nr_running; |
6419 | if (nr_running > 1) | ||
6419 | *overload = true; | 6420 | *overload = true; |
6420 | 6421 | ||
6421 | #ifdef CONFIG_NUMA_BALANCING | 6422 | #ifdef CONFIG_NUMA_BALANCING |
@@ -6423,7 +6424,10 @@ static inline void update_sg_lb_stats(struct lb_env *env, | |||
6423 | sgs->nr_preferred_running += rq->nr_preferred_running; | 6424 | sgs->nr_preferred_running += rq->nr_preferred_running; |
6424 | #endif | 6425 | #endif |
6425 | sgs->sum_weighted_load += weighted_cpuload(i); | 6426 | sgs->sum_weighted_load += weighted_cpuload(i); |
6426 | if (idle_cpu(i)) | 6427 | /* |
6428 | * No need to call idle_cpu() if nr_running is not 0 | ||
6429 | */ | ||
6430 | if (!nr_running && idle_cpu(i)) | ||
6427 | sgs->idle_cpus++; | 6431 | sgs->idle_cpus++; |
6428 | } | 6432 | } |
6429 | 6433 | ||