diff options
| author | Glenn Elliott <gelliott@cs.unc.edu> | 2014-03-18 14:21:19 -0400 |
|---|---|---|
| committer | Glenn Elliott <gelliott@cs.unc.edu> | 2014-03-18 14:21:19 -0400 |
| commit | 5927f76175586daa4e7fb88c631b99d21e685298 (patch) | |
| tree | 99ba58ea274b8d5519e733c85a78e2749724f1a5 | |
| parent | 6a6d06e65c50d7da5dd2019dafbe76ac9c7d018d (diff) | |
Cleanup priority tracking for budget enforcement.wip-gpusync-merge
| -rw-r--r-- | include/litmus/sbinheap.h | 6 | ||||
| -rw-r--r-- | litmus/sched_cedf.c | 65 |
2 files changed, 43 insertions, 28 deletions
diff --git a/include/litmus/sbinheap.h b/include/litmus/sbinheap.h index 3f952beca63b..a108d9e92288 100644 --- a/include/litmus/sbinheap.h +++ b/include/litmus/sbinheap.h | |||
| @@ -150,6 +150,12 @@ static inline int sbinheap_empty(struct sbinheap *heap) | |||
| 150 | return(heap->size == 0); | 150 | return(heap->size == 0); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | /* Returns true if the sbinheap is full. */ | ||
| 154 | static inline int sbinheap_full(struct sbinheap *heap) | ||
| 155 | { | ||
| 156 | return(heap->size == heap->max_size); | ||
| 157 | } | ||
| 158 | |||
| 153 | /* Get the maximum size of the heap */ | 159 | /* Get the maximum size of the heap */ |
| 154 | static inline idx_t sbinheap_max_size(struct sbinheap *heap) | 160 | static inline idx_t sbinheap_max_size(struct sbinheap *heap) |
| 155 | { | 161 | { |
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 61fef55f38a5..760fb4269e00 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c | |||
| @@ -258,44 +258,53 @@ static void cedf_untrack_in_top_m(struct task_struct *t) | |||
| 258 | { | 258 | { |
| 259 | /* cluster lock must be held */ | 259 | /* cluster lock must be held */ |
| 260 | cedf_domain_t *cluster = task_cpu_cluster(t); | 260 | cedf_domain_t *cluster = task_cpu_cluster(t); |
| 261 | int exited_top_m = 0; | ||
| 261 | 262 | ||
| 262 | if (!sbinheap_is_in_heap(&tsk_rt(t)->budget.top_m_node) && | 263 | BUG_ON(sbinheap_is_in_heap(&tsk_rt(t)->budget.top_m_node) && |
| 263 | !binheap_is_in_heap(&tsk_rt(t)->budget.not_top_m_node)) | 264 | binheap_is_in_heap(&tsk_rt(t)->budget.not_top_m_node)); |
| 264 | return; | 265 | |
| 266 | if (sbinheap_is_in_heap(&tsk_rt(t)->budget.top_m_node)) { | ||
| 267 | exited_top_m = bt_flag_is_set(t, BTF_IS_TOP_M); | ||
| 268 | WARN_ON_ONCE(!exited_top_m); | ||
| 265 | 269 | ||
| 266 | if (bt_flag_is_set(t, BTF_IS_TOP_M)) { | ||
| 267 | /* delete t's entry */ | ||
| 268 | sbinheap_delete(&tsk_rt(t)->budget.top_m_node, &cluster->top_m); | 270 | sbinheap_delete(&tsk_rt(t)->budget.top_m_node, &cluster->top_m); |
| 269 | INIT_SBINHEAP_NODE(&tsk_rt(t)->budget.top_m_node); | 271 | INIT_SBINHEAP_NODE(&tsk_rt(t)->budget.top_m_node); |
| 270 | budget_state_machine(t,on_exit_top_m); | ||
| 271 | bt_flag_clear(t, BTF_IS_TOP_M); | ||
| 272 | 272 | ||
| 273 | /* move a task over from the overflow heap */ | 273 | if (likely(exited_top_m)) { |
| 274 | if(!binheap_empty(&cluster->not_top_m)) { | 274 | budget_state_machine(t,on_exit_top_m); |
| 275 | struct budget_tracker *bt = | 275 | bt_flag_clear(t, BTF_IS_TOP_M); |
| 276 | binheap_top_entry(&cluster->not_top_m, struct budget_tracker, | ||
| 277 | not_top_m_node); | ||
| 278 | struct task_struct *to_move = | ||
| 279 | container_of( | ||
| 280 | container_of(bt, struct rt_param, budget), | ||
| 281 | struct task_struct, | ||
| 282 | rt_param); | ||
| 283 | |||
| 284 | binheap_delete_root(&cluster->not_top_m, struct budget_tracker, | ||
| 285 | not_top_m_node); | ||
| 286 | INIT_BINHEAP_NODE(&tsk_rt(to_move)->budget.not_top_m_node); | ||
| 287 | |||
| 288 | sbinheap_add(&tsk_rt(to_move)->budget.top_m_node, | ||
| 289 | &cluster->top_m, | ||
| 290 | struct budget_tracker, top_m_node); | ||
| 291 | bt_flag_set(to_move, BTF_IS_TOP_M); | ||
| 292 | budget_state_machine(to_move,on_enter_top_m); | ||
| 293 | } | 276 | } |
| 294 | } | 277 | } |
| 295 | else { | 278 | else if(likely(binheap_is_in_heap(&tsk_rt(t)->budget.not_top_m_node))) { |
| 296 | binheap_delete(&tsk_rt(t)->budget.not_top_m_node, &cluster->not_top_m); | 279 | binheap_delete(&tsk_rt(t)->budget.not_top_m_node, &cluster->not_top_m); |
| 297 | INIT_BINHEAP_NODE(&tsk_rt(t)->budget.not_top_m_node); | 280 | INIT_BINHEAP_NODE(&tsk_rt(t)->budget.not_top_m_node); |
| 298 | } | 281 | } |
| 282 | |||
| 283 | /* move a task over from the overflow heap */ | ||
| 284 | if(!sbinheap_full(&cluster->top_m) && | ||
| 285 | !binheap_empty(&cluster->not_top_m)) { | ||
| 286 | struct budget_tracker *bt = | ||
| 287 | binheap_top_entry(&cluster->not_top_m, struct budget_tracker, | ||
| 288 | not_top_m_node); | ||
| 289 | struct task_struct *to_move = | ||
| 290 | container_of( | ||
| 291 | container_of(bt, struct rt_param, budget), | ||
| 292 | struct task_struct, | ||
| 293 | rt_param); | ||
| 294 | |||
| 295 | /* task should have already been moved into the top m */ | ||
| 296 | WARN_ON_ONCE(!exited_top_m); | ||
| 297 | |||
| 298 | binheap_delete_root(&cluster->not_top_m, struct budget_tracker, | ||
| 299 | not_top_m_node); | ||
| 300 | INIT_BINHEAP_NODE(&tsk_rt(to_move)->budget.not_top_m_node); | ||
| 301 | |||
| 302 | sbinheap_add(&tsk_rt(to_move)->budget.top_m_node, | ||
| 303 | &cluster->top_m, | ||
| 304 | struct budget_tracker, top_m_node); | ||
| 305 | bt_flag_set(to_move, BTF_IS_TOP_M); | ||
| 306 | budget_state_machine(to_move,on_enter_top_m); | ||
| 307 | } | ||
| 299 | } | 308 | } |
| 300 | 309 | ||
| 301 | 310 | ||
