From f8db543cc4e96dc82e0bd249899321be44ec3427 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 26 Jan 2011 17:41:51 -0500 Subject: EDF-WM: rely on generic enforcement timer Since LITMUS^RT 2010.2 has generic support for precise budget enforcement, we don't need to implement it EDF-WM anymore. --- litmus/sched_edf_wm.c | 97 --------------------------------------------------- 1 file changed, 97 deletions(-) diff --git a/litmus/sched_edf_wm.c b/litmus/sched_edf_wm.c index f4219ca812d3..8b7be32b40dd 100644 --- a/litmus/sched_edf_wm.c +++ b/litmus/sched_edf_wm.c @@ -18,10 +18,6 @@ typedef struct { int cpu; struct task_struct* scheduled; /* only RT tasks */ - /* The enforcement timer is used to accurately police - * slice budgets. */ - struct hrtimer enforcement_timer; - int timer_armed; /* * scheduling lock slock * protects the domain and serializes scheduling decisions @@ -39,7 +35,6 @@ DEFINE_PER_CPU(wm_domain_t, wm_domains); #define local_domain (&__get_cpu_var(wm_domains)) #define remote_domain(cpu) (&per_cpu(wm_domains, cpu)) #define domain_of_task(task) (remote_domain(get_partition(task))) -#define domain_from_timer(t) (container_of((t), wm_domain_t, enforcement_timer)) static int is_sliced_task(struct task_struct* t) { @@ -115,14 +110,6 @@ static lt_t slice_budget_remaining(struct task_struct* t) return slice_budget(t) - slice_exec_time(t); } -static lt_t wm_budget_remaining(struct task_struct* t) -{ - if (is_sliced_task(t)) - return slice_budget_remaining(t); - else - return budget_remaining(t); -} - static int wm_budget_exhausted(struct task_struct* t) { if (is_sliced_task(t)) @@ -214,78 +201,6 @@ static void preempt(wm_domain_t *dom) preempt_if_preemptable(NULL, dom->cpu); } -static enum hrtimer_restart on_enforcement_timeout(struct hrtimer *timer) -{ - wm_domain_t *dom = domain_from_timer(timer); - unsigned long flags; - - raw_spin_lock_irqsave(&dom->slock, flags); - if (likely(dom->timer_armed)) { - TRACE_DOM(dom, "enforcement timer fired.\n"); - dom->timer_armed = 0; - preempt(dom); - } else - TRACE_DOM(dom, "timer fired but not armed???\n"); - raw_spin_unlock_irqrestore(&dom->slock, flags); - return HRTIMER_NORESTART; -} - -/* assumes called with IRQs off */ -static void cancel_enforcement_timer(wm_domain_t* dom) -{ - int ret; - - TRACE_DOM(dom, "cancelling enforcement timer.\n"); - - /* Arming the timer makes only sense locally. */ - BUG_ON(dom->cpu != raw_smp_processor_id()); - - /* Since interrupts are disabled and and dom->timer_armed is only - * modified locally, we do not need to lock this domain. - */ - - if (dom->timer_armed) { - ret = hrtimer_try_to_cancel(&dom->enforcement_timer); - /* Should never be inactive. */ - BUG_ON(ret == 0); - /* Should never be running concurrently. */ - BUG_ON(ret == -1); - - dom->timer_armed = 0; - } -} - -/* assumes called with IRQs off */ -static void arm_enforcement_timer(wm_domain_t* dom, struct task_struct* t) -{ - lt_t when_to_fire; - - TRACE_DOM(dom, "arming enforcement timer.\n"); - - /* The task has to belong to this domain. */ - BUG_ON(domain_of_task(t) != dom); - - /* Arming the timer makes only sense locally. */ - BUG_ON(dom->cpu != raw_smp_processor_id()); - - /* Calling this when there is no budget left for the task - * makes no sense. */ - BUG_ON(wm_budget_exhausted(t)); - - /* __hrtimer_start_range_ns() cancels the timer - * anyway, so we don't have to check whether it is still armed - */ - - when_to_fire = litmus_clock() + wm_budget_remaining(t); - __hrtimer_start_range_ns(&dom->enforcement_timer, - ns_to_ktime(when_to_fire), - 0 /* delta */, - HRTIMER_MODE_ABS_PINNED, - 0 /* no wakeup */); - - dom->timer_armed = 1; -} - static void wm_domain_init(wm_domain_t* dom, check_resched_needed_t check, release_jobs_t release, @@ -294,9 +209,6 @@ static void wm_domain_init(wm_domain_t* dom, edf_domain_init(&dom->domain, check, release); dom->cpu = cpu; dom->scheduled = NULL; - dom->timer_armed = 0; - hrtimer_init(&dom->enforcement_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); - dom->enforcement_timer.function = on_enforcement_timeout; } static void wm_requeue_remote(struct task_struct *t) @@ -473,15 +385,6 @@ static struct task_struct* wm_schedule(struct task_struct * prev) wm_requeue_remote(migrate); } - if (next && budget_precisely_enforced(next)) { - /* Make sure we call into the scheduler when this budget - * expires. */ - arm_enforcement_timer(dom, next); - } else if (dom->timer_armed) { - /* Make sure we don't cause unnecessary interrupts. */ - cancel_enforcement_timer(dom); - } - return next; } -- cgit v1.2.2