aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorDmitry Adamushko <dmitry.adamushko@gmail.com>2007-10-15 11:00:08 -0400
committerIngo Molnar <mingo@elte.hu>2007-10-15 11:00:08 -0400
commitf6b53205e17c8ca481c69ed579a35a650a4b481a (patch)
treed7820281757e3a2c7cfff7e38275261dcd077eab /kernel/sched.c
parent4530d7ab0fb8d5056b68c376949e2d5c4db7817e (diff)
sched: rework enqueue/dequeue_entity() to get rid of set_curr_task()
rework enqueue/dequeue_entity() to get rid of sched_class::set_curr_task(). This simplifies sched_setscheduler(), rt_mutex_setprio() and sched_move_tasks(). text data bss dec hex filename 24330 2734 20 27084 69cc sched.o.before 24233 2730 20 26983 6967 sched.o.after Signed-off-by: Dmitry Adamushko <dmitry.adamushko@gmail.com> Signed-off-by: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index e1f784f4b4db..72c936d3e332 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3915,8 +3915,8 @@ EXPORT_SYMBOL(sleep_on_timeout);
3915 */ 3915 */
3916void rt_mutex_setprio(struct task_struct *p, int prio) 3916void rt_mutex_setprio(struct task_struct *p, int prio)
3917{ 3917{
3918 int oldprio, on_rq, running;
3919 unsigned long flags; 3918 unsigned long flags;
3919 int oldprio, on_rq;
3920 struct rq *rq; 3920 struct rq *rq;
3921 3921
3922 BUG_ON(prio < 0 || prio > MAX_PRIO); 3922 BUG_ON(prio < 0 || prio > MAX_PRIO);
@@ -3926,12 +3926,8 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
3926 3926
3927 oldprio = p->prio; 3927 oldprio = p->prio;
3928 on_rq = p->se.on_rq; 3928 on_rq = p->se.on_rq;
3929 running = task_running(rq, p); 3929 if (on_rq)
3930 if (on_rq) {
3931 dequeue_task(rq, p, 0); 3930 dequeue_task(rq, p, 0);
3932 if (running)
3933 p->sched_class->put_prev_task(rq, p);
3934 }
3935 3931
3936 if (rt_prio(prio)) 3932 if (rt_prio(prio))
3937 p->sched_class = &rt_sched_class; 3933 p->sched_class = &rt_sched_class;
@@ -3941,15 +3937,13 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
3941 p->prio = prio; 3937 p->prio = prio;
3942 3938
3943 if (on_rq) { 3939 if (on_rq) {
3944 if (running)
3945 p->sched_class->set_curr_task(rq);
3946 enqueue_task(rq, p, 0); 3940 enqueue_task(rq, p, 0);
3947 /* 3941 /*
3948 * Reschedule if we are currently running on this runqueue and 3942 * Reschedule if we are currently running on this runqueue and
3949 * our priority decreased, or if we are not currently running on 3943 * our priority decreased, or if we are not currently running on
3950 * this runqueue and our priority is higher than the current's 3944 * this runqueue and our priority is higher than the current's
3951 */ 3945 */
3952 if (running) { 3946 if (task_running(rq, p)) {
3953 if (p->prio > oldprio) 3947 if (p->prio > oldprio)
3954 resched_task(rq->curr); 3948 resched_task(rq->curr);
3955 } else { 3949 } else {
@@ -4155,7 +4149,7 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio)
4155int sched_setscheduler(struct task_struct *p, int policy, 4149int sched_setscheduler(struct task_struct *p, int policy,
4156 struct sched_param *param) 4150 struct sched_param *param)
4157{ 4151{
4158 int retval, oldprio, oldpolicy = -1, on_rq, running; 4152 int retval, oldprio, oldpolicy = -1, on_rq;
4159 unsigned long flags; 4153 unsigned long flags;
4160 struct rq *rq; 4154 struct rq *rq;
4161 4155
@@ -4237,24 +4231,20 @@ recheck:
4237 } 4231 }
4238 update_rq_clock(rq); 4232 update_rq_clock(rq);
4239 on_rq = p->se.on_rq; 4233 on_rq = p->se.on_rq;
4240 running = task_running(rq, p); 4234 if (on_rq)
4241 if (on_rq) {
4242 deactivate_task(rq, p, 0); 4235 deactivate_task(rq, p, 0);
4243 if (running) 4236
4244 p->sched_class->put_prev_task(rq, p);
4245 }
4246 oldprio = p->prio; 4237 oldprio = p->prio;
4247 __setscheduler(rq, p, policy, param->sched_priority); 4238 __setscheduler(rq, p, policy, param->sched_priority);
4239
4248 if (on_rq) { 4240 if (on_rq) {
4249 if (running)
4250 p->sched_class->set_curr_task(rq);
4251 activate_task(rq, p, 0); 4241 activate_task(rq, p, 0);
4252 /* 4242 /*
4253 * Reschedule if we are currently running on this runqueue and 4243 * Reschedule if we are currently running on this runqueue and
4254 * our priority decreased, or if we are not currently running on 4244 * our priority decreased, or if we are not currently running on
4255 * this runqueue and our priority is higher than the current's 4245 * this runqueue and our priority is higher than the current's
4256 */ 4246 */
4257 if (running) { 4247 if (task_running(rq, p)) {
4258 if (p->prio > oldprio) 4248 if (p->prio > oldprio)
4259 resched_task(rq->curr); 4249 resched_task(rq->curr);
4260 } else { 4250 } else {
@@ -6855,19 +6845,13 @@ static void sched_move_task(struct container_subsys *ss, struct container *cont,
6855 running = task_running(rq, tsk); 6845 running = task_running(rq, tsk);
6856 on_rq = tsk->se.on_rq; 6846 on_rq = tsk->se.on_rq;
6857 6847
6858 if (on_rq) { 6848 if (on_rq)
6859 dequeue_task(rq, tsk, 0); 6849 dequeue_task(rq, tsk, 0);
6860 if (unlikely(running))
6861 tsk->sched_class->put_prev_task(rq, tsk);
6862 }
6863 6850
6864 set_task_cfs_rq(tsk); 6851 set_task_cfs_rq(tsk);
6865 6852
6866 if (on_rq) { 6853 if (on_rq)
6867 if (unlikely(running))
6868 tsk->sched_class->set_curr_task(rq);
6869 enqueue_task(rq, tsk, 0); 6854 enqueue_task(rq, tsk, 0);
6870 }
6871 6855
6872done: 6856done:
6873 task_rq_unlock(rq, &flags); 6857 task_rq_unlock(rq, &flags);