[PATCH 34/41] sched: Update clock of nohz busiest rq before balancing
Frederic Weisbecker
fweisbec at gmail.com
Mon Apr 30 23:55:08 UTC 2012
move_tasks() and active_load_balance_cpu_stop() both need
to have the busiest rq clock uptodate because they may end
up calling can_migrate_task() that uses rq->clock_task
to determine if the task running in the busiest runqueue
is cache hot.
Hence if the busiest runqueue is tickless, update its clock
before reading it.
Signed-off-by: Frederic Weisbecker <fweisbec at gmail.com>
Cc: Alessio Igor Bogani <abogani at kernel.org>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Avi Kivity <avi at redhat.com>
Cc: Chris Metcalf <cmetcalf at tilera.com>
Cc: Christoph Lameter <cl at linux.com>
Cc: Daniel Lezcano <daniel.lezcano at linaro.org>
Cc: Geoff Levand <geoff at infradead.org>
Cc: Gilad Ben Yossef <gilad at benyossef.com>
Cc: Hakan Akkan <hakanakkan at gmail.com>
Cc: Ingo Molnar <mingo at kernel.org>
Cc: Kevin Hilman <khilman at ti.com>
Cc: Max Krasnyansky <maxk at qualcomm.com>
Cc: Paul E. McKenney <paulmck at linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Stephen Hemminger <shemminger at vyatta.com>
Cc: Steven Rostedt <rostedt at goodmis.org>
Cc: Sven-Thorsten Dietrich <thebigcorporation at gmail.com>
Cc: Thomas Gleixner <tglx at linutronix.de>
---
kernel/sched/fair.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 42a87d7..eff80e0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4455,6 +4455,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
int *balance)
{
int ld_moved, lb_flags = 0, active_balance = 0;
+ int clock_updated;
struct sched_group *group;
unsigned long imbalance;
struct rq *busiest;
@@ -4488,6 +4489,7 @@ redo:
schedstat_add(sd, lb_imbalance[idle], imbalance);
ld_moved = 0;
+ clock_updated = 0;
if (busiest->nr_running > 1) {
/*
* Attempt to move tasks. If find_busiest_group has found
@@ -4498,6 +4500,12 @@ redo:
lb_flags |= LBF_ALL_PINNED;
local_irq_save(flags);
double_rq_lock(this_rq, busiest);
+ /*
+ * Move tasks may end up calling can_migrate_task() which
+ * requires an uptodate value of the rq clock.
+ */
+ update_nohz_rq_clock(busiest);
+ clock_updated = 1;
ld_moved = move_tasks(this_rq, this_cpu, busiest,
imbalance, sd, idle, &lb_flags);
double_rq_unlock(this_rq, busiest);
@@ -4563,6 +4571,13 @@ redo:
busiest->active_balance = 1;
busiest->push_cpu = this_cpu;
active_balance = 1;
+ /*
+ * active_load_balance_cpu_stop may end up calling
+ * can_migrate_task() which requires an uptodate
+ * value of the rq clock.
+ */
+ if (!clock_updated)
+ update_nohz_rq_clock(busiest);
}
raw_spin_unlock_irqrestore(&busiest->lock, flags);
--
1.7.5.4
More information about the linaro-sched-sig
mailing list