From 0ec4cf2484ad5860d84dda1aef44dc35e7c2a81d Mon Sep 17 00:00:00 2001 From: Srivatsa Vaddagiri Date: Tue, 11 Jun 2013 17:43:09 -0700 Subject: sched: re-calculate a cpu's next_balance point upon sched domain changes A cpus next_balance point could be stale when its being attached to a sched domain hierarchy. That would lead to undesirable delay in cpu doing a load balance and hence potentially affect scheduling latencies for tasks. Fix that by initializing cpu's next_balance point when its being attached to a sched domain hierarchy. Change-Id: I855cff8da5ca28d278596c3bb0163b839d4704bc Signed-off-by: Srivatsa Vaddagiri [rameezmustafa@codeaurora.org: Modify commit text to reflect dropped patches] Signed-off-by: Syed Rameez Mustafa --- kernel/sched/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cd488bf2a0d1..daababd6b211 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6057,6 +6057,7 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu) { struct rq *rq = cpu_rq(cpu); struct sched_domain *tmp; + unsigned long next_balance = rq->next_balance; /* Remove the sched domains which do not contribute to scheduling. */ for (tmp = sd; tmp; ) { @@ -6088,6 +6089,17 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu) sd->child = NULL; } + for (tmp = sd; tmp; ) { + unsigned long interval; + + interval = msecs_to_jiffies(tmp->balance_interval); + if (time_after(next_balance, tmp->last_balance + interval)) + next_balance = tmp->last_balance + interval; + + tmp = tmp->parent; + } + rq->next_balance = next_balance; + sched_domain_debug(sd, cpu); rq_attach_root(rq, rd); -- cgit v1.2.3