diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-07-01 17:46:56 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2014-06-07 05:30:57 -0400 |
commit | cf4eed14dba46a535f5a8b5252e239d759e0735f (patch) | |
tree | 126483872e4328d8387077f24331246e094d576e | |
parent | 721496c96d228ba5d13abd2b383b99e2d8d5196e (diff) |
Integrate LITMUS^RT scheduling class with sched_setscheduler
-rw-r--r-- | kernel/sched/core.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d54b6d6cfc2c..afc134d73fcc 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -89,6 +89,7 @@ | |||
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> | ||
92 | 93 | ||
93 | #define CREATE_TRACE_POINTS | 94 | #define CREATE_TRACE_POINTS |
94 | #include <trace/events/sched.h> | 95 | #include <trace/events/sched.h> |
@@ -3909,7 +3910,9 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio) | |||
3909 | p->normal_prio = normal_prio(p); | 3910 | p->normal_prio = normal_prio(p); |
3910 | /* we are holding p->pi_lock already */ | 3911 | /* we are holding p->pi_lock already */ |
3911 | p->prio = rt_mutex_getprio(p); | 3912 | p->prio = rt_mutex_getprio(p); |
3912 | if (rt_prio(p->prio)) | 3913 | if (p->policy == SCHED_LITMUS) |
3914 | p->sched_class = &litmus_sched_class; | ||
3915 | else if (rt_prio(p->prio)) | ||
3913 | p->sched_class = &rt_sched_class; | 3916 | p->sched_class = &rt_sched_class; |
3914 | else | 3917 | else |
3915 | p->sched_class = &fair_sched_class; | 3918 | p->sched_class = &fair_sched_class; |
@@ -3940,6 +3943,7 @@ static int __sched_setscheduler(struct task_struct *p, int policy, | |||
3940 | const struct sched_class *prev_class; | 3943 | const struct sched_class *prev_class; |
3941 | struct rq *rq; | 3944 | struct rq *rq; |
3942 | int reset_on_fork; | 3945 | int reset_on_fork; |
3946 | int litmus_task = 0; | ||
3943 | 3947 | ||
3944 | /* may grab non-irq protected spin_locks */ | 3948 | /* may grab non-irq protected spin_locks */ |
3945 | BUG_ON(in_interrupt()); | 3949 | BUG_ON(in_interrupt()); |
@@ -3954,7 +3958,7 @@ recheck: | |||
3954 | 3958 | ||
3955 | if (policy != SCHED_FIFO && policy != SCHED_RR && | 3959 | if (policy != SCHED_FIFO && policy != SCHED_RR && |
3956 | policy != SCHED_NORMAL && policy != SCHED_BATCH && | 3960 | policy != SCHED_NORMAL && policy != SCHED_BATCH && |
3957 | policy != SCHED_IDLE) | 3961 | policy != SCHED_IDLE && policy != SCHED_LITMUS) |
3958 | return -EINVAL; | 3962 | return -EINVAL; |
3959 | } | 3963 | } |
3960 | 3964 | ||
@@ -3969,6 +3973,8 @@ recheck: | |||
3969 | return -EINVAL; | 3973 | return -EINVAL; |
3970 | if (rt_policy(policy) != (param->sched_priority != 0)) | 3974 | if (rt_policy(policy) != (param->sched_priority != 0)) |
3971 | return -EINVAL; | 3975 | return -EINVAL; |
3976 | if (policy == SCHED_LITMUS && policy == p->policy) | ||
3977 | return -EINVAL; | ||
3972 | 3978 | ||
3973 | /* | 3979 | /* |
3974 | * Allow unprivileged RT tasks to decrease priority: | 3980 | * Allow unprivileged RT tasks to decrease priority: |
@@ -4012,6 +4018,12 @@ recheck: | |||
4012 | return retval; | 4018 | return retval; |
4013 | } | 4019 | } |
4014 | 4020 | ||
4021 | if (policy == SCHED_LITMUS) { | ||
4022 | retval = litmus_admit_task(p); | ||
4023 | if (retval) | ||
4024 | return retval; | ||
4025 | } | ||
4026 | |||
4015 | /* | 4027 | /* |
4016 | * make sure no PI-waiters arrive (or leave) while we are | 4028 | * make sure no PI-waiters arrive (or leave) while we are |
4017 | * changing the priority of the task: | 4029 | * changing the priority of the task: |
@@ -4068,10 +4080,25 @@ recheck: | |||
4068 | 4080 | ||
4069 | p->sched_reset_on_fork = reset_on_fork; | 4081 | p->sched_reset_on_fork = reset_on_fork; |
4070 | 4082 | ||
4083 | if (p->policy == SCHED_LITMUS) { | ||
4084 | litmus_exit_task(p); | ||
4085 | litmus_task = 1; | ||
4086 | } | ||
4087 | |||
4071 | oldprio = p->prio; | 4088 | oldprio = p->prio; |
4072 | prev_class = p->sched_class; | 4089 | prev_class = p->sched_class; |
4073 | __setscheduler(rq, p, policy, param->sched_priority); | 4090 | __setscheduler(rq, p, policy, param->sched_priority); |
4074 | 4091 | ||
4092 | if (policy == SCHED_LITMUS) { | ||
4093 | #ifdef CONFIG_SMP | ||
4094 | p->rt_param.stack_in_use = running ? rq->cpu : NO_CPU; | ||
4095 | #else | ||
4096 | p->rt_param.stack_in_use = running ? 0 : NO_CPU; | ||
4097 | #endif | ||
4098 | p->rt_param.present = running; | ||
4099 | litmus->task_new(p, on_rq, running); | ||
4100 | } | ||
4101 | |||
4075 | if (running) | 4102 | if (running) |
4076 | p->sched_class->set_curr_task(rq); | 4103 | p->sched_class->set_curr_task(rq); |
4077 | if (on_rq) | 4104 | if (on_rq) |
@@ -4082,6 +4109,9 @@ recheck: | |||
4082 | 4109 | ||
4083 | rt_mutex_adjust_pi(p); | 4110 | rt_mutex_adjust_pi(p); |
4084 | 4111 | ||
4112 | if (litmus_task) | ||
4113 | litmus_dealloc(p); | ||
4114 | |||
4085 | return 0; | 4115 | return 0; |
4086 | } | 4116 | } |
4087 | 4117 | ||