diff options
author | Gregory Haskins <ghaskins@novell.com> | 2008-01-25 15:08:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-25 15:08:07 -0500 |
commit | 73fe6aae84400e2b475e2a1dc4e8592cd3ed6e69 (patch) | |
tree | 97c7d6a866d75563082c422491fc423b47aca9d7 /include | |
parent | c7a1e46aa9782a947cf2ed506245d43396dbf991 (diff) |
sched: add RT-balance cpu-weight
Some RT tasks (particularly kthreads) are bound to one specific CPU.
It is fairly common for two or more bound tasks to get queued up at the
same time. Consider, for instance, softirq_timer and softirq_sched. A
timer goes off in an ISR which schedules softirq_thread to run at RT50.
Then the timer handler determines that it's time to smp-rebalance the
system so it schedules softirq_sched to run. So we are in a situation
where we have two RT50 tasks queued, and the system will go into
rt-overload condition to request other CPUs for help.
This causes two problems in the current code:
1) If a high-priority bound task and a low-priority unbounded task queue
up behind the running task, we will fail to ever relocate the unbounded
task because we terminate the search on the first unmovable task.
2) We spend precious futile cycles in the fast-path trying to pull
overloaded tasks over. It is therefore optimial to strive to avoid the
overhead all together if we can cheaply detect the condition before
overload even occurs.
This patch tries to achieve this optimization by utilizing the hamming
weight of the task->cpus_allowed mask. A weight of 1 indicates that
the task cannot be migrated. We will then utilize this information to
skip non-migratable tasks and to eliminate uncessary rebalance attempts.
We introduce a per-rq variable to count the number of migratable tasks
that are currently running. We only go into overload if we have more
than one rt task, AND at least one of them is migratable.
In addition, we introduce a per-task variable to cache the cpus_allowed
weight, since the hamming calculation is probably relatively expensive.
We only update the cached value when the mask is updated which should be
relatively infrequent, especially compared to scheduling frequency
in the fast path.
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/init_task.h | 1 | ||||
-rw-r--r-- | include/linux/sched.h | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index cae35b6b9aec..572c65bcc80f 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -130,6 +130,7 @@ extern struct group_info init_groups; | |||
130 | .normal_prio = MAX_PRIO-20, \ | 130 | .normal_prio = MAX_PRIO-20, \ |
131 | .policy = SCHED_NORMAL, \ | 131 | .policy = SCHED_NORMAL, \ |
132 | .cpus_allowed = CPU_MASK_ALL, \ | 132 | .cpus_allowed = CPU_MASK_ALL, \ |
133 | .nr_cpus_allowed = NR_CPUS, \ | ||
133 | .mm = NULL, \ | 134 | .mm = NULL, \ |
134 | .active_mm = &init_mm, \ | 135 | .active_mm = &init_mm, \ |
135 | .run_list = LIST_HEAD_INIT(tsk.run_list), \ | 136 | .run_list = LIST_HEAD_INIT(tsk.run_list), \ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 0846f1f9e196..b07a2cf76401 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -847,6 +847,7 @@ struct sched_class { | |||
847 | void (*set_curr_task) (struct rq *rq); | 847 | void (*set_curr_task) (struct rq *rq); |
848 | void (*task_tick) (struct rq *rq, struct task_struct *p); | 848 | void (*task_tick) (struct rq *rq, struct task_struct *p); |
849 | void (*task_new) (struct rq *rq, struct task_struct *p); | 849 | void (*task_new) (struct rq *rq, struct task_struct *p); |
850 | void (*set_cpus_allowed)(struct task_struct *p, cpumask_t *newmask); | ||
850 | }; | 851 | }; |
851 | 852 | ||
852 | struct load_weight { | 853 | struct load_weight { |
@@ -956,6 +957,7 @@ struct task_struct { | |||
956 | 957 | ||
957 | unsigned int policy; | 958 | unsigned int policy; |
958 | cpumask_t cpus_allowed; | 959 | cpumask_t cpus_allowed; |
960 | int nr_cpus_allowed; | ||
959 | unsigned int time_slice; | 961 | unsigned int time_slice; |
960 | 962 | ||
961 | #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) | 963 | #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) |