From 3057498a98914c809c58f828fbbd7bc061ee8a6d Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Sun, 9 Aug 2015 13:18:52 +0200 Subject: Integrate LITMUS^RT scheduling class with sched_setscheduler --- kernel/sched/core.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'kernel') diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 426f4e776188..1fe02e0e801c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -91,6 +91,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -3380,7 +3381,9 @@ static void __setscheduler(struct rq *rq, struct task_struct *p, else p->prio = normal_prio(p); - if (dl_prio(p->prio)) + if (p->policy == SCHED_LITMUS) + p->sched_class = &litmus_sched_class; + else if (dl_prio(p->prio)) p->sched_class = &dl_sched_class; else if (rt_prio(p->prio)) p->sched_class = &rt_sched_class; @@ -3483,6 +3486,7 @@ static int __sched_setscheduler(struct task_struct *p, const struct sched_class *prev_class; struct rq *rq; int reset_on_fork; + int litmus_task = 0; /* may grab non-irq protected spin_locks */ BUG_ON(in_interrupt()); @@ -3497,7 +3501,7 @@ recheck: if (policy != SCHED_DEADLINE && policy != SCHED_FIFO && policy != SCHED_RR && policy != SCHED_NORMAL && policy != SCHED_BATCH && - policy != SCHED_IDLE) + policy != SCHED_IDLE && policy != SCHED_LITMUS) return -EINVAL; } @@ -3515,6 +3519,8 @@ recheck: if ((dl_policy(policy) && !__checkparam_dl(attr)) || (rt_policy(policy) != (attr->sched_priority != 0))) return -EINVAL; + if (policy == SCHED_LITMUS && policy == p->policy) + return -EINVAL; /* * Allow unprivileged RT tasks to decrease priority: @@ -3573,6 +3579,12 @@ recheck: return retval; } + if (policy == SCHED_LITMUS) { + retval = litmus_admit_task(p); + if (retval) + return retval; + } + /* * make sure no PI-waiters arrive (or leave) while we are * changing the priority of the task: @@ -3656,6 +3668,11 @@ change: return -EBUSY; } + if (p->policy == SCHED_LITMUS) { + litmus_exit_task(p); + litmus_task = 1; + } + p->sched_reset_on_fork = reset_on_fork; oldprio = p->prio; @@ -3683,6 +3700,16 @@ change: prev_class = p->sched_class; __setscheduler(rq, p, attr, true); + if (policy == SCHED_LITMUS) { +#ifdef CONFIG_SMP + p->rt_param.stack_in_use = running ? rq->cpu : NO_CPU; +#else + p->rt_param.stack_in_use = running ? 0 : NO_CPU; +#endif + p->rt_param.present = running; + litmus->task_new(p, queued, running); + } + if (running) p->sched_class->set_curr_task(rq); if (queued) { @@ -3698,6 +3725,9 @@ change: rt_mutex_adjust_pi(p); + if (litmus_task) + litmus_dealloc(p); + return 0; } -- cgit v1.2.2