diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-07-01 17:46:56 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-08-07 03:46:59 -0400 |
commit | b2d4904295d25557799e368389d63573a9fda4f0 (patch) | |
tree | 7fa2e62c369a908b40bbc8db4ba57592bb2c8a72 | |
parent | b2ddb2157bb6d291c317df1de18ad85addf93d8f (diff) |
Integrate LITMUS^RT scheduling class with sched_setscheduler
-rw-r--r-- | kernel/sched/core.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 90cc4b53cc5f..8debd642a22c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -89,6 +89,8 @@ | |||
89 | #include <litmus/litmus.h> | 89 | #include <litmus/litmus.h> |
90 | #include <litmus/trace.h> | 90 | #include <litmus/trace.h> |
91 | #include <litmus/sched_trace.h> | 91 | #include <litmus/sched_trace.h> |
92 | #include <litmus/sched_plugin.h> | ||
93 | |||
92 | void litmus_tick(struct rq*, struct task_struct*); | 94 | void litmus_tick(struct rq*, struct task_struct*); |
93 | 95 | ||
94 | #define CREATE_TRACE_POINTS | 96 | #define CREATE_TRACE_POINTS |
@@ -3900,7 +3902,9 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio) | |||
3900 | p->normal_prio = normal_prio(p); | 3902 | p->normal_prio = normal_prio(p); |
3901 | /* we are holding p->pi_lock already */ | 3903 | /* we are holding p->pi_lock already */ |
3902 | p->prio = rt_mutex_getprio(p); | 3904 | p->prio = rt_mutex_getprio(p); |
3903 | if (rt_prio(p->prio)) | 3905 | if (p->policy == SCHED_LITMUS) |
3906 | p->sched_class = &litmus_sched_class; | ||
3907 | else if (rt_prio(p->prio)) | ||
3904 | p->sched_class = &rt_sched_class; | 3908 | p->sched_class = &rt_sched_class; |
3905 | else | 3909 | else |
3906 | p->sched_class = &fair_sched_class; | 3910 | p->sched_class = &fair_sched_class; |
@@ -3945,7 +3949,7 @@ recheck: | |||
3945 | 3949 | ||
3946 | if (policy != SCHED_FIFO && policy != SCHED_RR && | 3950 | if (policy != SCHED_FIFO && policy != SCHED_RR && |
3947 | policy != SCHED_NORMAL && policy != SCHED_BATCH && | 3951 | policy != SCHED_NORMAL && policy != SCHED_BATCH && |
3948 | policy != SCHED_IDLE) | 3952 | policy != SCHED_IDLE && policy != SCHED_LITMUS) |
3949 | return -EINVAL; | 3953 | return -EINVAL; |
3950 | } | 3954 | } |
3951 | 3955 | ||
@@ -3960,6 +3964,8 @@ recheck: | |||
3960 | return -EINVAL; | 3964 | return -EINVAL; |
3961 | if (rt_policy(policy) != (param->sched_priority != 0)) | 3965 | if (rt_policy(policy) != (param->sched_priority != 0)) |
3962 | return -EINVAL; | 3966 | return -EINVAL; |
3967 | if (policy == SCHED_LITMUS && policy == p->policy) | ||
3968 | return -EINVAL; | ||
3963 | 3969 | ||
3964 | /* | 3970 | /* |
3965 | * Allow unprivileged RT tasks to decrease priority: | 3971 | * Allow unprivileged RT tasks to decrease priority: |
@@ -4003,6 +4009,12 @@ recheck: | |||
4003 | return retval; | 4009 | return retval; |
4004 | } | 4010 | } |
4005 | 4011 | ||
4012 | if (policy == SCHED_LITMUS) { | ||
4013 | retval = litmus_admit_task(p); | ||
4014 | if (retval) | ||
4015 | return retval; | ||
4016 | } | ||
4017 | |||
4006 | /* | 4018 | /* |
4007 | * make sure no PI-waiters arrive (or leave) while we are | 4019 | * make sure no PI-waiters arrive (or leave) while we are |
4008 | * changing the priority of the task: | 4020 | * changing the priority of the task: |
@@ -4059,10 +4071,23 @@ recheck: | |||
4059 | 4071 | ||
4060 | p->sched_reset_on_fork = reset_on_fork; | 4072 | p->sched_reset_on_fork = reset_on_fork; |
4061 | 4073 | ||
4074 | if (p->policy == SCHED_LITMUS) | ||
4075 | litmus_exit_task(p); | ||
4076 | |||
4062 | oldprio = p->prio; | 4077 | oldprio = p->prio; |
4063 | prev_class = p->sched_class; | 4078 | prev_class = p->sched_class; |
4064 | __setscheduler(rq, p, policy, param->sched_priority); | 4079 | __setscheduler(rq, p, policy, param->sched_priority); |
4065 | 4080 | ||
4081 | if (policy == SCHED_LITMUS) { | ||
4082 | #ifdef CONFIG_SMP | ||
4083 | p->rt_param.stack_in_use = running ? rq->cpu : NO_CPU; | ||
4084 | #else | ||
4085 | p->rt_param.stack_in_use = running ? 0 : NO_CPU; | ||
4086 | #endif | ||
4087 | p->rt_param.present = running; | ||
4088 | litmus->task_new(p, on_rq, running); | ||
4089 | } | ||
4090 | |||
4066 | if (running) | 4091 | if (running) |
4067 | p->sched_class->set_curr_task(rq); | 4092 | p->sched_class->set_curr_task(rq); |
4068 | if (on_rq) | 4093 | if (on_rq) |