提交 bdecea3a 编写于 作者: S Siddha, Suresh B 提交者: Linus Torvalds

sched: fix idle load balancing in softirqd context

Periodic load balancing in recent kernels happen in the softirq.  In
certain -rt configurations, these softirqs are handled in softirqd context.
 And hence the check for idle processor was always returning busy (as
nr_running > 1).

This patch captures the idle information at the tick and passes this info
to softirq context through an element 'idle_at_tick' in rq.

[kernel@kolivas.org: Fix reverse idle at tick logic]
Signed-off-by: NSuresh Siddha <suresh.b.siddha@intel.com>
Acked-by: NIngo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2bd7e20e
...@@ -223,6 +223,7 @@ struct rq { ...@@ -223,6 +223,7 @@ struct rq {
unsigned long raw_weighted_load; unsigned long raw_weighted_load;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
unsigned long cpu_load[3]; unsigned long cpu_load[3];
unsigned char idle_at_tick;
#endif #endif
unsigned long long nr_switches; unsigned long long nr_switches;
...@@ -2943,12 +2944,7 @@ static void run_rebalance_domains(struct softirq_action *h) ...@@ -2943,12 +2944,7 @@ static void run_rebalance_domains(struct softirq_action *h)
struct rq *this_rq = cpu_rq(this_cpu); struct rq *this_rq = cpu_rq(this_cpu);
unsigned long interval; unsigned long interval;
struct sched_domain *sd; struct sched_domain *sd;
/* enum idle_type idle = this_rq->idle_at_tick ? SCHED_IDLE : NOT_IDLE;
* We are idle if there are no processes running. This
* is valid even if we are the idle process (SMT).
*/
enum idle_type idle = !this_rq->nr_running ?
SCHED_IDLE : NOT_IDLE;
/* Earliest time when we have to call run_rebalance_domains again */ /* Earliest time when we have to call run_rebalance_domains again */
unsigned long next_balance = jiffies + 60*HZ; unsigned long next_balance = jiffies + 60*HZ;
...@@ -3218,14 +3214,16 @@ void scheduler_tick(void) ...@@ -3218,14 +3214,16 @@ void scheduler_tick(void)
unsigned long long now = sched_clock(); unsigned long long now = sched_clock();
struct task_struct *p = current; struct task_struct *p = current;
int cpu = smp_processor_id(); int cpu = smp_processor_id();
int idle_at_tick = idle_cpu(cpu);
struct rq *rq = cpu_rq(cpu); struct rq *rq = cpu_rq(cpu);
update_cpu_clock(p, rq, now); update_cpu_clock(p, rq, now);
if (p != rq->idle) if (!idle_at_tick)
task_running_tick(rq, p); task_running_tick(rq, p);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
update_load(rq); update_load(rq);
rq->idle_at_tick = idle_at_tick;
if (time_after_eq(jiffies, rq->next_balance)) if (time_after_eq(jiffies, rq->next_balance))
raise_softirq(SCHED_SOFTIRQ); raise_softirq(SCHED_SOFTIRQ);
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册