aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2015-08-09 07:18:52 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2017-05-26 17:12:32 -0400
commitb5506ae89a16f96120e68a994ade593366551849 (patch)
tree84164fe02ec805b3181282c983c54f4bea0ce9f5
parent5ebb43a73f5be054eed1f7f7ee880bfd1ab73431 (diff)
Integrate LITMUS^RT scheduling class with sched_setscheduler
-rw-r--r--kernel/sched/core.c32
-rw-r--r--kernel/sched/sched.h7
2 files changed, 37 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4fbcc40cb86d..abdf10c424f0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -91,6 +91,7 @@
91#include <litmus/litmus.h> 91#include <litmus/litmus.h>
92#include <litmus/trace.h> 92#include <litmus/trace.h>
93#include <litmus/sched_trace.h> 93#include <litmus/sched_trace.h>
94#include <litmus/sched_plugin.h>
94 95
95#define CREATE_TRACE_POINTS 96#define CREATE_TRACE_POINTS
96#include <trace/events/sched.h> 97#include <trace/events/sched.h>
@@ -4034,7 +4035,9 @@ static void __setscheduler(struct rq *rq, struct task_struct *p,
4034 else 4035 else
4035 p->prio = normal_prio(p); 4036 p->prio = normal_prio(p);
4036 4037
4037 if (dl_prio(p->prio)) 4038 if (p->policy == SCHED_LITMUS)
4039 p->sched_class = &litmus_sched_class;
4040 else if (dl_prio(p->prio))
4038 p->sched_class = &dl_sched_class; 4041 p->sched_class = &dl_sched_class;
4039 else if (rt_prio(p->prio)) 4042 else if (rt_prio(p->prio))
4040 p->sched_class = &rt_sched_class; 4043 p->sched_class = &rt_sched_class;
@@ -4138,6 +4141,7 @@ static int __sched_setscheduler(struct task_struct *p,
4138 int reset_on_fork; 4141 int reset_on_fork;
4139 int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE; 4142 int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE;
4140 struct rq *rq; 4143 struct rq *rq;
4144 int litmus_task = 0;
4141 4145
4142 /* may grab non-irq protected spin_locks */ 4146 /* may grab non-irq protected spin_locks */
4143 BUG_ON(in_interrupt()); 4147 BUG_ON(in_interrupt());
@@ -4167,6 +4171,8 @@ recheck:
4167 if ((dl_policy(policy) && !__checkparam_dl(attr)) || 4171 if ((dl_policy(policy) && !__checkparam_dl(attr)) ||
4168 (rt_policy(policy) != (attr->sched_priority != 0))) 4172 (rt_policy(policy) != (attr->sched_priority != 0)))
4169 return -EINVAL; 4173 return -EINVAL;
4174 if (policy == SCHED_LITMUS && policy == p->policy)
4175 return -EINVAL;
4170 4176
4171 /* 4177 /*
4172 * Allow unprivileged RT tasks to decrease priority: 4178 * Allow unprivileged RT tasks to decrease priority:
@@ -4225,6 +4231,12 @@ recheck:
4225 return retval; 4231 return retval;
4226 } 4232 }
4227 4233
4234 if (policy == SCHED_LITMUS) {
4235 retval = litmus_admit_task(p);
4236 if (retval)
4237 return retval;
4238 }
4239
4228 /* 4240 /*
4229 * make sure no PI-waiters arrive (or leave) while we are 4241 * make sure no PI-waiters arrive (or leave) while we are
4230 * changing the priority of the task: 4242 * changing the priority of the task:
@@ -4308,6 +4320,11 @@ change:
4308 return -EBUSY; 4320 return -EBUSY;
4309 } 4321 }
4310 4322
4323 if (is_realtime(p)) {
4324 litmus_exit_task(p);
4325 litmus_task = 1;
4326 }
4327
4311 p->sched_reset_on_fork = reset_on_fork; 4328 p->sched_reset_on_fork = reset_on_fork;
4312 oldprio = p->prio; 4329 oldprio = p->prio;
4313 4330
@@ -4334,6 +4351,16 @@ change:
4334 prev_class = p->sched_class; 4351 prev_class = p->sched_class;
4335 __setscheduler(rq, p, attr, pi); 4352 __setscheduler(rq, p, attr, pi);
4336 4353
4354 if (litmus_policy(policy)) {
4355#ifdef CONFIG_SMP
4356 p->rt_param.stack_in_use = running ? rq->cpu : NO_CPU;
4357#else
4358 p->rt_param.stack_in_use = running ? 0 : NO_CPU;
4359#endif
4360 p->rt_param.present = running;
4361 litmus->task_new(p, queued, running);
4362 }
4363
4337 if (queued) { 4364 if (queued) {
4338 /* 4365 /*
4339 * We enqueue to tail when the priority of a task is 4366 * We enqueue to tail when the priority of a task is
@@ -4360,6 +4387,9 @@ change:
4360 balance_callback(rq); 4387 balance_callback(rq);
4361 preempt_enable(); 4388 preempt_enable();
4362 4389
4390 if (litmus_task)
4391 litmus_dealloc(p);
4392
4363 return 0; 4393 return 0;
4364} 4394}
4365 4395
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 585b193b2442..34e2f3bd7875 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -113,6 +113,11 @@ static inline int rt_policy(int policy)
113 return policy == SCHED_FIFO || policy == SCHED_RR; 113 return policy == SCHED_FIFO || policy == SCHED_RR;
114} 114}
115 115
116static inline int litmus_policy(int policy)
117{
118 return policy == SCHED_LITMUS;
119}
120
116static inline int dl_policy(int policy) 121static inline int dl_policy(int policy)
117{ 122{
118 return policy == SCHED_DEADLINE; 123 return policy == SCHED_DEADLINE;
@@ -120,7 +125,7 @@ static inline int dl_policy(int policy)
120static inline bool valid_policy(int policy) 125static inline bool valid_policy(int policy)
121{ 126{
122 return idle_policy(policy) || fair_policy(policy) || 127 return idle_policy(policy) || fair_policy(policy) ||
123 rt_policy(policy) || dl_policy(policy); 128 rt_policy(policy) || dl_policy(policy) || litmus_policy(policy);
124} 129}
125 130
126static inline int task_has_rt_policy(struct task_struct *p) 131static inline int task_has_rt_policy(struct task_struct *p)