aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-09-10 07:42:00 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-15 10:01:04 -0400
commit5f3edc1b1ead6d9bd45a85c551f44eff8fe76b9f (patch)
tree46f987010ca017be945831b76d8ea846f1ba8fc9 /kernel
parentaaee1203ca52b9db799433c33c9bffc33cdf8909 (diff)
sched: Hook sched_balance_self() into sched_class::select_task_rq()
Rather ugly patch to fully place the sched_balance_self() code inside the fair class. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c14
-rw-r--r--kernel/sched_fair.c7
-rw-r--r--kernel/sched_idletask.c2
-rw-r--r--kernel/sched_rt.c5
4 files changed, 18 insertions, 10 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 60400a22401f..32b7a81230c2 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2350,7 +2350,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
2350 if (unlikely(task_running(rq, p))) 2350 if (unlikely(task_running(rq, p)))
2351 goto out_activate; 2351 goto out_activate;
2352 2352
2353 cpu = p->sched_class->select_task_rq(p, sync); 2353 cpu = p->sched_class->select_task_rq(p, SD_BALANCE_WAKE, sync);
2354 if (cpu != orig_cpu) { 2354 if (cpu != orig_cpu) {
2355 set_task_cpu(p, cpu); 2355 set_task_cpu(p, cpu);
2356 task_rq_unlock(rq, &flags); 2356 task_rq_unlock(rq, &flags);
@@ -2525,11 +2525,6 @@ void sched_fork(struct task_struct *p, int clone_flags)
2525 2525
2526 __sched_fork(p); 2526 __sched_fork(p);
2527 2527
2528#ifdef CONFIG_SMP
2529 cpu = sched_balance_self(cpu, SD_BALANCE_FORK);
2530#endif
2531 set_task_cpu(p, cpu);
2532
2533 /* 2528 /*
2534 * Make sure we do not leak PI boosting priority to the child. 2529 * Make sure we do not leak PI boosting priority to the child.
2535 */ 2530 */
@@ -2560,6 +2555,11 @@ void sched_fork(struct task_struct *p, int clone_flags)
2560 if (!rt_prio(p->prio)) 2555 if (!rt_prio(p->prio))
2561 p->sched_class = &fair_sched_class; 2556 p->sched_class = &fair_sched_class;
2562 2557
2558#ifdef CONFIG_SMP
2559 cpu = p->sched_class->select_task_rq(p, SD_BALANCE_FORK, 0);
2560#endif
2561 set_task_cpu(p, cpu);
2562
2563#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 2563#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
2564 if (likely(sched_info_on())) 2564 if (likely(sched_info_on()))
2565 memset(&p->sched_info, 0, sizeof(p->sched_info)); 2565 memset(&p->sched_info, 0, sizeof(p->sched_info));
@@ -3114,7 +3114,7 @@ out:
3114void sched_exec(void) 3114void sched_exec(void)
3115{ 3115{
3116 int new_cpu, this_cpu = get_cpu(); 3116 int new_cpu, this_cpu = get_cpu();
3117 new_cpu = sched_balance_self(this_cpu, SD_BALANCE_EXEC); 3117 new_cpu = current->sched_class->select_task_rq(current, SD_BALANCE_EXEC, 0);
3118 put_cpu(); 3118 put_cpu();
3119 if (new_cpu != this_cpu) 3119 if (new_cpu != this_cpu)
3120 sched_migrate_task(current, new_cpu); 3120 sched_migrate_task(current, new_cpu);
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index a82d71d3afed..f2eb5b934715 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1300,7 +1300,9 @@ wake_affine(struct sched_domain *this_sd, struct rq *this_rq,
1300 return 0; 1300 return 0;
1301} 1301}
1302 1302
1303static int select_task_rq_fair(struct task_struct *p, int sync) 1303static int sched_balance_self(int cpu, int flag);
1304
1305static int select_task_rq_fair(struct task_struct *p, int flag, int sync)
1304{ 1306{
1305 struct sched_domain *sd, *this_sd = NULL; 1307 struct sched_domain *sd, *this_sd = NULL;
1306 int prev_cpu, this_cpu, new_cpu; 1308 int prev_cpu, this_cpu, new_cpu;
@@ -1314,6 +1316,9 @@ static int select_task_rq_fair(struct task_struct *p, int sync)
1314 this_rq = cpu_rq(this_cpu); 1316 this_rq = cpu_rq(this_cpu);
1315 new_cpu = prev_cpu; 1317 new_cpu = prev_cpu;
1316 1318
1319 if (flag != SD_BALANCE_WAKE)
1320 return sched_balance_self(this_cpu, flag);
1321
1317 /* 1322 /*
1318 * 'this_sd' is the first domain that both 1323 * 'this_sd' is the first domain that both
1319 * this_cpu and prev_cpu are present in: 1324 * this_cpu and prev_cpu are present in:
diff --git a/kernel/sched_idletask.c b/kernel/sched_idletask.c
index 499672c10cbd..99b2f0337609 100644
--- a/kernel/sched_idletask.c
+++ b/kernel/sched_idletask.c
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#ifdef CONFIG_SMP 8#ifdef CONFIG_SMP
9static int select_task_rq_idle(struct task_struct *p, int sync) 9static int select_task_rq_idle(struct task_struct *p, int flag, int sync)
10{ 10{
11 return task_cpu(p); /* IDLE tasks as never migrated */ 11 return task_cpu(p); /* IDLE tasks as never migrated */
12} 12}
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 2eb4bd6a526c..438380810ac4 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -938,10 +938,13 @@ static void yield_task_rt(struct rq *rq)
938#ifdef CONFIG_SMP 938#ifdef CONFIG_SMP
939static int find_lowest_rq(struct task_struct *task); 939static int find_lowest_rq(struct task_struct *task);
940 940
941static int select_task_rq_rt(struct task_struct *p, int sync) 941static int select_task_rq_rt(struct task_struct *p, int flag, int sync)
942{ 942{
943 struct rq *rq = task_rq(p); 943 struct rq *rq = task_rq(p);
944 944
945 if (flag != SD_BALANCE_WAKE)
946 return smp_processor_id();
947
945 /* 948 /*
946 * If the current task is an RT task, then 949 * If the current task is an RT task, then
947 * try to see if we can wake this RT task up on another 950 * try to see if we can wake this RT task up on another