From 8b637fddc7f9a91febdb7fb398ac0a5f97d491ee Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Thu, 20 May 2010 14:33:27 -0400 Subject: Added support for choices in budget policy enforcement. NO_ENFORCEMENT - A job may execute beyond its declared execution time. Jobs notify the kernel that they are complete via liblitmus's sleep_next_period() QUANTUM_ENFORCEMENT - The kernel terminates a job if its actual execution time exceeds the declared execution time. PRECISE_ENFORCEMENT - Hook declared, but not yet implemented. Plan to support this policy through hrtimers. Error thrown if specified. --- include/litmus/litmus.h | 2 ++ include/litmus/rt_param.h | 11 +++++++++-- litmus/litmus.c | 7 +++++++ litmus/sched_cedf.c | 6 ++++-- litmus/sched_gsn_edf.c | 6 ++++-- litmus/sched_psn_edf.c | 6 ++++-- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index 62107e659c12..d515d1af1096 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h @@ -83,6 +83,8 @@ inline static int budget_exhausted(struct task_struct* t) return get_exec_time(t) >= get_exec_cost(t); } +#define budget_enforced(t) (tsk_rt(t)->task_params.budget_policy != NO_ENFORCEMENT) + #define is_hrt(t) \ (tsk_rt(t)->task_params.class == RT_CLASS_HARD) diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index 5b94d1a8eea7..a7a183f34a80 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h @@ -27,12 +27,19 @@ typedef enum { RT_CLASS_BEST_EFFORT } task_class_t; +typedef enum { + NO_ENFORCEMENT, /* job may overrun unhindered */ + QUANTUM_ENFORCEMENT, /* budgets are only checked on quantum boundaries */ + PRECISE_ENFORCEMENT /* NOT IMPLEMENTED - enforced with hrtimers */ +} budget_policy_t; + struct rt_task { lt_t exec_cost; lt_t period; lt_t phase; - unsigned int cpu; - task_class_t cls; + unsigned int cpu; + task_class_t cls; + budget_policy_t budget_policy; /* ignored by pfair */ }; /* The definition of the data that is shared between the kernel and real-time diff --git a/litmus/litmus.c b/litmus/litmus.c index e43596a5104c..8b8f2c171a5e 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c @@ -112,6 +112,13 @@ asmlinkage long sys_set_rt_task_param(pid_t pid, struct rt_task __user * param) "because wcet > period\n", pid); goto out_unlock; } + if (tp.budget_policy != NO_ENFORCEMENT && + tp.budget_policy != QUANTUM_ENFORCEMENT) + { + printk(KERN_INFO "litmus: real-time task %d rejected " + "because unsupported budget enforcement policy specified\n", pid); + goto out_unlock; + } target->rt_param.task_params = tp; diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index da44b451c9ad..76706a29245e 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c @@ -320,7 +320,7 @@ static noinline void job_completion(struct task_struct *t, int forced) */ static void cedf_tick(struct task_struct* t) { - if (is_realtime(t) && budget_exhausted(t)) { + if (is_realtime(t) && budget_enforced(t) && budget_exhausted(t)) { if (!is_np(t)) { /* np tasks will be preempted when they become * preemptable again @@ -378,7 +378,9 @@ static struct task_struct* cedf_schedule(struct task_struct * prev) /* (0) Determine state */ exists = entry->scheduled != NULL; blocks = exists && !is_running(entry->scheduled); - out_of_time = exists && budget_exhausted(entry->scheduled); + out_of_time = exists && + budget_enforced(entry->scheduled) && + budget_exhausted(entry->scheduled); np = exists && is_np(entry->scheduled); sleep = exists && get_rt_flags(entry->scheduled) == RT_F_SLEEP; preempt = entry->scheduled != entry->linked; diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index b9310dd6f75c..6137c74729cb 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c @@ -336,7 +336,7 @@ static noinline void job_completion(struct task_struct *t, int forced) */ static void gsnedf_tick(struct task_struct* t) { - if (is_realtime(t) && budget_exhausted(t)) { + if (is_realtime(t) && budget_enforced(t) && budget_exhausted(t)) { if (!is_np(t)) { /* np tasks will be preempted when they become * preemptable again @@ -399,7 +399,9 @@ static struct task_struct* gsnedf_schedule(struct task_struct * prev) /* (0) Determine state */ exists = entry->scheduled != NULL; blocks = exists && !is_running(entry->scheduled); - out_of_time = exists && budget_exhausted(entry->scheduled); + out_of_time = exists && + budget_enforced(entry->scheduled) && + budget_exhausted(entry->scheduled); np = exists && is_np(entry->scheduled); sleep = exists && get_rt_flags(entry->scheduled) == RT_F_SLEEP; preempt = entry->scheduled != entry->linked; diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c index 7f71ecfaaaae..af0b30cb8b89 100644 --- a/litmus/sched_psn_edf.c +++ b/litmus/sched_psn_edf.c @@ -107,7 +107,7 @@ static void psnedf_tick(struct task_struct *t) */ BUG_ON(is_realtime(t) && t != pedf->scheduled); - if (is_realtime(t) && budget_exhausted(t)) { + if (is_realtime(t) && budget_enforced(t) && budget_exhausted(t)) { if (!is_np(t)) { set_tsk_need_resched(t); TRACE("psnedf_scheduler_tick: " @@ -143,7 +143,9 @@ static struct task_struct* psnedf_schedule(struct task_struct * prev) /* (0) Determine state */ exists = pedf->scheduled != NULL; blocks = exists && !is_running(pedf->scheduled); - out_of_time = exists && budget_exhausted(pedf->scheduled); + out_of_time = exists && + budget_enforced(pedf->scheduled) && + budget_exhausted(pedf->scheduled); np = exists && is_np(pedf->scheduled); sleep = exists && get_rt_flags(pedf->scheduled) == RT_F_SLEEP; preempt = edf_preemption_needed(edf, prev); -- cgit v1.2.2