diff options
author | Jeremy Erickson <jerickso@cs.unc.edu> | 2011-01-22 18:50:11 -0500 |
---|---|---|
committer | Jeremy Erickson <jerickso@cs.unc.edu> | 2011-01-22 18:50:11 -0500 |
commit | 50251cbf3d36c5da36b2c74be223827c48f60a1a (patch) | |
tree | b50e6b5485865e43bb14b7a9c3093fbf4bcdf2c0 | |
parent | a6519b1ef7ee7d207240ba492d333ad912c7da0a (diff) |
Fix bugs and add more tracing
-rw-r--r-- | litmus/sched_mc.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/litmus/sched_mc.c b/litmus/sched_mc.c index 63dd157925ab..aafe3e095c2a 100644 --- a/litmus/sched_mc.c +++ b/litmus/sched_mc.c | |||
@@ -343,12 +343,15 @@ static void update_ghost_time(struct task_struct *p) | |||
343 | delta = clock - p->se.exec_start; | 343 | delta = clock - p->se.exec_start; |
344 | if (unlikely ((s64)delta < 0)) { | 344 | if (unlikely ((s64)delta < 0)) { |
345 | delta = 0; | 345 | delta = 0; |
346 | TRACE_TASK(p, "WARNING: negative time delta.\n"); | ||
346 | } | 347 | } |
347 | if (p->rt_param.job_params.ghost_budget <= delta) { | 348 | if (p->rt_param.job_params.ghost_budget <= delta) { |
349 | TRACE_TASK(p, "Ghost job ended in update_ghost_time\n"); | ||
348 | p->rt_param.job_params.ghost_budget = 0; | 350 | p->rt_param.job_params.ghost_budget = 0; |
349 | job_completion(p, 0); | 351 | job_completion(p, 0); |
350 | } | 352 | } |
351 | else{ | 353 | else{ |
354 | TRACE_TASK(p, "Ghost jub updated, but didn't finish\n"); | ||
352 | p->rt_param.job_params.ghost_budget -= delta; | 355 | p->rt_param.job_params.ghost_budget -= delta; |
353 | p->se.exec_start = clock; | 356 | p->se.exec_start = clock; |
354 | } | 357 | } |
@@ -397,6 +400,8 @@ static noinline void link_task_to_cpu(struct task_struct* linked, | |||
397 | (linked->rt_param.task_params.cpu != entry->cpu)); | 400 | (linked->rt_param.task_params.cpu != entry->cpu)); |
398 | 401 | ||
399 | if (linked && is_ghost(linked)) { | 402 | if (linked && is_ghost(linked)) { |
403 | TRACE_TASK(linked, "Linking ghost job to CPU %d.\n", | ||
404 | entry->cpu); | ||
400 | BUG_ON(entry->linked && | 405 | BUG_ON(entry->linked && |
401 | entry->linked->rt_param.task_params.crit < | 406 | entry->linked->rt_param.task_params.crit < |
402 | linked->rt_param.task_params.crit); | 407 | linked->rt_param.task_params.crit); |
@@ -524,12 +529,17 @@ static noinline void unlink(struct task_struct* t) | |||
524 | entry = remote_cpu_entry(cpu); | 529 | entry = remote_cpu_entry(cpu); |
525 | t->rt_param.linked_on = NO_CPU; | 530 | t->rt_param.linked_on = NO_CPU; |
526 | if (is_ghost(t)) { | 531 | if (is_ghost(t)) { |
527 | /* Clear the timer.*/ | 532 | /* Clear the timer if it's set. |
533 | * It may be unset if we are called as a result of | ||
534 | * the watchdog timer triggering. | ||
535 | */ | ||
528 | timer = ghost_timer(cpu, | 536 | timer = ghost_timer(cpu, |
529 | t->rt_param.task_params.crit); | 537 | t->rt_param.task_params.crit); |
530 | /* Should already be watching task.*/ | 538 | if (timer->task) { |
531 | BUG_ON(timer->task != t); | 539 | /* Should already be watching task.*/ |
532 | cancel_watchdog_timer(timer); | 540 | BUG_ON(timer->task != t); |
541 | cancel_watchdog_timer(timer); | ||
542 | } | ||
533 | if (t->rt_param.job_params.ghost_budget > 0){ | 543 | if (t->rt_param.job_params.ghost_budget > 0){ |
534 | /* Job isn't finished, so do accounting. */ | 544 | /* Job isn't finished, so do accounting. */ |
535 | update_ghost_time(t); | 545 | update_ghost_time(t); |
@@ -743,6 +753,7 @@ static noinline void job_completion(struct task_struct *t, int forced) | |||
743 | * needed. | 753 | * needed. |
744 | */ | 754 | */ |
745 | if (!is_ghost(t)) { | 755 | if (!is_ghost(t)) { |
756 | TRACE_TASK(t, "Converting to ghost.\n"); | ||
746 | cpu = remote_cpu_entry(t->rt_param.scheduled_on); | 757 | cpu = remote_cpu_entry(t->rt_param.scheduled_on); |
747 | /*Unlink first while it's not a ghost job.*/ | 758 | /*Unlink first while it's not a ghost job.*/ |
748 | unlink(t); | 759 | unlink(t); |
@@ -768,6 +779,11 @@ static noinline void job_completion(struct task_struct *t, int forced) | |||
768 | /* prepare for next period */ | 779 | /* prepare for next period */ |
769 | if (is_ghost(t)) { | 780 | if (is_ghost(t)) { |
770 | t->rt_param.job_params.ghost_budget = 0; | 781 | t->rt_param.job_params.ghost_budget = 0; |
782 | /*Need to unlink here so prepare_for_next_period doesn't try | ||
783 | * to unlink us | ||
784 | */ | ||
785 | unlink(t); | ||
786 | already_unlinked = 1; | ||
771 | prepare_for_next_period(t); | 787 | prepare_for_next_period(t); |
772 | } | 788 | } |
773 | else { | 789 | else { |
@@ -795,10 +811,16 @@ static enum hrtimer_restart watchdog_timeout(struct hrtimer *timer) | |||
795 | struct watchdog_timer, | 811 | struct watchdog_timer, |
796 | timer); | 812 | timer); |
797 | unsigned long flags; | 813 | unsigned long flags; |
814 | struct task_struct* task = wt->task; | ||
798 | raw_spin_lock_irqsave(&global_lock, flags); | 815 | raw_spin_lock_irqsave(&global_lock, flags); |
799 | /*If we have triggered, we know the budget must have expired.*/ | 816 | /*If we have triggered, we know the budget must have expired.*/ |
800 | wt->task->rt_param.job_params.ghost_budget = 0; | 817 | /*This needs to run first, so it doesn't look to job_completion like |
801 | job_completion(wt->task, 0); | 818 | * we have an active timer. |
819 | */ | ||
820 | wt->task = NULL; | ||
821 | task->rt_param.job_params.ghost_budget = 0; | ||
822 | job_completion(task, 0); | ||
823 | TRACE_TASK(task, "Watchdog timeout\n"); | ||
802 | raw_spin_unlock_irqrestore(&global_lock, flags); | 824 | raw_spin_unlock_irqrestore(&global_lock, flags); |
803 | return HRTIMER_NORESTART; | 825 | return HRTIMER_NORESTART; |
804 | } | 826 | } |