diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-08-09 07:18:52 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-08-09 07:20:28 -0400 |
commit | 3057498a98914c809c58f828fbbd7bc061ee8a6d (patch) | |
tree | 2a042f28709bcdc9b77f7e4d91626838e82d9fa5 | |
parent | cdb8efa4e1ffe6207722a545ec71242f49e7111f (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 426f4e776188..1fe02e0e801c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -91,6 +91,7 @@ | |||
91 | #include <litmus/ceiling.h> | 91 | #include <litmus/ceiling.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> |
@@ -3380,7 +3381,9 @@ static void __setscheduler(struct rq *rq, struct task_struct *p, | |||
3380 | else | 3381 | else |
3381 | p->prio = normal_prio(p); | 3382 | p->prio = normal_prio(p); |
3382 | 3383 | ||
3383 | if (dl_prio(p->prio)) | 3384 | if (p->policy == SCHED_LITMUS) |
3385 | p->sched_class = &litmus_sched_class; | ||
3386 | else if (dl_prio(p->prio)) | ||
3384 | p->sched_class = &dl_sched_class; | 3387 | p->sched_class = &dl_sched_class; |
3385 | else if (rt_prio(p->prio)) | 3388 | else if (rt_prio(p->prio)) |
3386 | p->sched_class = &rt_sched_class; | 3389 | p->sched_class = &rt_sched_class; |
@@ -3483,6 +3486,7 @@ static int __sched_setscheduler(struct task_struct *p, | |||
3483 | const struct sched_class *prev_class; | 3486 | const struct sched_class *prev_class; |
3484 | struct rq *rq; | 3487 | struct rq *rq; |
3485 | int reset_on_fork; | 3488 | int reset_on_fork; |
3489 | int litmus_task = 0; | ||
3486 | 3490 | ||
3487 | /* may grab non-irq protected spin_locks */ | 3491 | /* may grab non-irq protected spin_locks */ |
3488 | BUG_ON(in_interrupt()); | 3492 | BUG_ON(in_interrupt()); |
@@ -3497,7 +3501,7 @@ recheck: | |||
3497 | if (policy != SCHED_DEADLINE && | 3501 | if (policy != SCHED_DEADLINE && |
3498 | policy != SCHED_FIFO && policy != SCHED_RR && | 3502 | policy != SCHED_FIFO && policy != SCHED_RR && |
3499 | policy != SCHED_NORMAL && policy != SCHED_BATCH && | 3503 | policy != SCHED_NORMAL && policy != SCHED_BATCH && |
3500 | policy != SCHED_IDLE) | 3504 | policy != SCHED_IDLE && policy != SCHED_LITMUS) |
3501 | return -EINVAL; | 3505 | return -EINVAL; |
3502 | } | 3506 | } |
3503 | 3507 | ||
@@ -3515,6 +3519,8 @@ recheck: | |||
3515 | if ((dl_policy(policy) && !__checkparam_dl(attr)) || | 3519 | if ((dl_policy(policy) && !__checkparam_dl(attr)) || |
3516 | (rt_policy(policy) != (attr->sched_priority != 0))) | 3520 | (rt_policy(policy) != (attr->sched_priority != 0))) |
3517 | return -EINVAL; | 3521 | return -EINVAL; |
3522 | if (policy == SCHED_LITMUS && policy == p->policy) | ||
3523 | return -EINVAL; | ||
3518 | 3524 | ||
3519 | /* | 3525 | /* |
3520 | * Allow unprivileged RT tasks to decrease priority: | 3526 | * Allow unprivileged RT tasks to decrease priority: |
@@ -3573,6 +3579,12 @@ recheck: | |||
3573 | return retval; | 3579 | return retval; |
3574 | } | 3580 | } |
3575 | 3581 | ||
3582 | if (policy == SCHED_LITMUS) { | ||
3583 | retval = litmus_admit_task(p); | ||
3584 | if (retval) | ||
3585 | return retval; | ||
3586 | } | ||
3587 | |||
3576 | /* | 3588 | /* |
3577 | * make sure no PI-waiters arrive (or leave) while we are | 3589 | * make sure no PI-waiters arrive (or leave) while we are |
3578 | * changing the priority of the task: | 3590 | * changing the priority of the task: |
@@ -3656,6 +3668,11 @@ change: | |||
3656 | return -EBUSY; | 3668 | return -EBUSY; |
3657 | } | 3669 | } |
3658 | 3670 | ||
3671 | if (p->policy == SCHED_LITMUS) { | ||
3672 | litmus_exit_task(p); | ||
3673 | litmus_task = 1; | ||
3674 | } | ||
3675 | |||
3659 | p->sched_reset_on_fork = reset_on_fork; | 3676 | p->sched_reset_on_fork = reset_on_fork; |
3660 | oldprio = p->prio; | 3677 | oldprio = p->prio; |
3661 | 3678 | ||
@@ -3683,6 +3700,16 @@ change: | |||
3683 | prev_class = p->sched_class; | 3700 | prev_class = p->sched_class; |
3684 | __setscheduler(rq, p, attr, true); | 3701 | __setscheduler(rq, p, attr, true); |
3685 | 3702 | ||
3703 | if (policy == SCHED_LITMUS) { | ||
3704 | #ifdef CONFIG_SMP | ||
3705 | p->rt_param.stack_in_use = running ? rq->cpu : NO_CPU; | ||
3706 | #else | ||
3707 | p->rt_param.stack_in_use = running ? 0 : NO_CPU; | ||
3708 | #endif | ||
3709 | p->rt_param.present = running; | ||
3710 | litmus->task_new(p, queued, running); | ||
3711 | } | ||
3712 | |||
3686 | if (running) | 3713 | if (running) |
3687 | p->sched_class->set_curr_task(rq); | 3714 | p->sched_class->set_curr_task(rq); |
3688 | if (queued) { | 3715 | if (queued) { |
@@ -3698,6 +3725,9 @@ change: | |||
3698 | 3725 | ||
3699 | rt_mutex_adjust_pi(p); | 3726 | rt_mutex_adjust_pi(p); |
3700 | 3727 | ||
3728 | if (litmus_task) | ||
3729 | litmus_dealloc(p); | ||
3730 | |||
3701 | return 0; | 3731 | return 0; |
3702 | } | 3732 | } |
3703 | 3733 | ||