diff options
Diffstat (limited to 'litmus/sched_mc_ce.c')
-rw-r--r-- | litmus/sched_mc_ce.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/litmus/sched_mc_ce.c b/litmus/sched_mc_ce.c index c799738c0090..9f6929e55ab2 100644 --- a/litmus/sched_mc_ce.c +++ b/litmus/sched_mc_ce.c | |||
@@ -118,9 +118,9 @@ unsigned int mc_ce_get_expected_job(const int cpu, const int idx) | |||
118 | static inline lt_t get_cycle_offset(const lt_t when, const lt_t cycle_time) | 118 | static inline lt_t get_cycle_offset(const lt_t when, const lt_t cycle_time) |
119 | { | 119 | { |
120 | long long st = atomic64_read(&start_time); | 120 | long long st = atomic64_read(&start_time); |
121 | //lt_t offset = (when - st) % cycle_time; | 121 | lt_t offset = (when - st) % cycle_time; |
122 | lt_t offset = 0; | 122 | /* lt_t offset = 0; */ |
123 | TRACE("when: %llu cycle_time: %llu start_time: %lld offset %llu\n", | 123 | STRACE("when: %llu cycle_time: %llu start_time: %lld offset %llu\n", |
124 | when, cycle_time, st, offset); | 124 | when, cycle_time, st, offset); |
125 | return offset; | 125 | return offset; |
126 | } | 126 | } |
@@ -138,7 +138,7 @@ void mc_ce_job_completion(struct domain *dom, struct task_struct *ts) | |||
138 | const struct ce_pid_entry *pid_entry = get_pid_entry(cpu, idx); | 138 | const struct ce_pid_entry *pid_entry = get_pid_entry(cpu, idx); |
139 | unsigned int just_finished; | 139 | unsigned int just_finished; |
140 | 140 | ||
141 | TRACE_TASK(ts, "Completed\n"); | 141 | TRACE_MC_TASK(ts, "Completed\n"); |
142 | 142 | ||
143 | /* sched_trace_task_completion(ts, 0); */ | 143 | /* sched_trace_task_completion(ts, 0); */ |
144 | /* post-increment is important here */ | 144 | /* post-increment is important here */ |
@@ -152,13 +152,13 @@ void mc_ce_job_completion(struct domain *dom, struct task_struct *ts) | |||
152 | if (just_finished < pid_entry->expected_job) { | 152 | if (just_finished < pid_entry->expected_job) { |
153 | /* this job is already released because it's running behind */ | 153 | /* this job is already released because it's running behind */ |
154 | set_rt_flags(ts, RT_F_RUNNING); | 154 | set_rt_flags(ts, RT_F_RUNNING); |
155 | TRACE_TASK(ts, "appears behind: the expected job is %u but " | 155 | TRACE_MC_TASK(ts, "appears behind: the expected job is %u but " |
156 | "job %u just completed\n", | 156 | "job %u just completed\n", |
157 | pid_entry->expected_job, just_finished); | 157 | pid_entry->expected_job, just_finished); |
158 | } else if (pid_entry->expected_job < just_finished) { | 158 | } else if (pid_entry->expected_job < just_finished) { |
159 | printk(KERN_CRIT "job %u completed in expected job %u which " | 159 | TRACE_MC_TASK(ts, "job %u completed in expected job %u which " |
160 | "seems too early\n", just_finished, | 160 | "seems too early\n", just_finished, |
161 | pid_entry->expected_job); | 161 | pid_entry->expected_job); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
@@ -189,7 +189,7 @@ static int mc_ce_schedule_at(const struct domain *dom, lt_t offset) | |||
189 | } | 189 | } |
190 | /* can only happen if cycle_time is not right */ | 190 | /* can only happen if cycle_time is not right */ |
191 | BUG_ON(pid_entry->acc_time > pid_table->cycle_time); | 191 | BUG_ON(pid_entry->acc_time > pid_table->cycle_time); |
192 | TRACE("schedule at returning task %d for CPU %d\n", idx, ce_data->cpu); | 192 | STRACE("schedule at returning task %d for CPU %d\n", idx, ce_data->cpu); |
193 | return idx; | 193 | return idx; |
194 | } | 194 | } |
195 | 195 | ||
@@ -211,7 +211,7 @@ static struct task_struct *mc_ce_schedule(struct task_struct *prev) | |||
211 | exists = NULL != ce_data->scheduled; | 211 | exists = NULL != ce_data->scheduled; |
212 | sleep = exists && RT_F_SLEEP == get_rt_flags(ce_data->scheduled); | 212 | sleep = exists && RT_F_SLEEP == get_rt_flags(ce_data->scheduled); |
213 | 213 | ||
214 | TRACE("exists: %d, sleep: %d\n", exists, sleep); | 214 | STRACE("exists: %d, sleep: %d\n", exists, sleep); |
215 | 215 | ||
216 | if (sleep) | 216 | if (sleep) |
217 | mc_ce_job_completion(dom, ce_data->scheduled); | 217 | mc_ce_job_completion(dom, ce_data->scheduled); |
@@ -226,7 +226,7 @@ static struct task_struct *mc_ce_schedule(struct task_struct *prev) | |||
226 | should_sched_asleep = should_sched_exists && | 226 | should_sched_asleep = should_sched_exists && |
227 | RT_F_SLEEP == get_rt_flags(ce_data->should_schedule); | 227 | RT_F_SLEEP == get_rt_flags(ce_data->should_schedule); |
228 | 228 | ||
229 | TRACE("should_sched_exists: %d, should_sched_blocked: %d, " | 229 | STRACE("should_sched_exists: %d, should_sched_blocked: %d, " |
230 | "should_sched_asleep: %d\n", should_sched_exists, | 230 | "should_sched_asleep: %d\n", should_sched_exists, |
231 | should_sched_blocked, should_sched_asleep); | 231 | should_sched_blocked, should_sched_asleep); |
232 | 232 | ||
@@ -248,7 +248,7 @@ static void mc_ce_finish_switch(struct task_struct *prev) | |||
248 | struct domain *dom = get_domain_for(smp_processor_id()); | 248 | struct domain *dom = get_domain_for(smp_processor_id()); |
249 | struct ce_dom_data *ce_data = dom->data; | 249 | struct ce_dom_data *ce_data = dom->data; |
250 | 250 | ||
251 | TRACE("finish switch\n"); | 251 | STRACE("finish switch\n"); |
252 | 252 | ||
253 | if (is_realtime(current) && CRIT_LEVEL_A == tsk_mc_crit(current)) | 253 | if (is_realtime(current) && CRIT_LEVEL_A == tsk_mc_crit(current)) |
254 | ce_data->scheduled = current; | 254 | ce_data->scheduled = current; |
@@ -495,19 +495,19 @@ lt_t mc_ce_timer_callback_common(struct domain *dom) | |||
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | if (ce_data->should_schedule) { | 498 | /* if (ce_data->should_schedule) { */ |
499 | get_deadline(should_schedule) = | 499 | /* get_deadline(should_schedule) = */ |
500 | cycle_start_abs + pid_entry->acc_time; | 500 | /* cycle_start_abs + pid_entry->acc_time; */ |
501 | get_release(should_schedule) = tsk_rt(should_schedule)->job_params.deadline - | 501 | /* get_release(should_schedule) = tsk_rt(should_schedule)->job_params.deadline - */ |
502 | pid_entry->budget; | 502 | /* pid_entry->budget; */ |
503 | tsk_rt(should_schedule)->job_params.exec_time = 0; | 503 | /* tsk_rt(should_schedule)->job_params.exec_time = 0; */ |
504 | 504 | ||
505 | TRACE_MC_TASK(should_schedule, "Released!\n"); | 505 | /* TRACE_MC_TASK(should_schedule, "Released!\n"); */ |
506 | set_rt_flags(ce_data->should_schedule, RT_F_RUNNING); | 506 | /* set_rt_flags(ce_data->should_schedule, RT_F_RUNNING); */ |
507 | sched_trace_task_release(should_schedule); | 507 | /* sched_trace_task_release(should_schedule); */ |
508 | sched_trace_server_release(-should_schedule->pid, get_rt_job(should_schedule), | 508 | /* sched_trace_server_release(-should_schedule->pid, get_rt_job(should_schedule), */ |
509 | tsk_rt(should_schedule)->job_params); | 509 | /* tsk_rt(should_schedule)->job_params); */ |
510 | } | 510 | /* } */ |
511 | return next_timer_abs; | 511 | return next_timer_abs; |
512 | } | 512 | } |
513 | 513 | ||
@@ -535,7 +535,7 @@ static enum hrtimer_restart mc_ce_timer_callback(struct hrtimer *timer) | |||
535 | #endif | 535 | #endif |
536 | dom = get_domain_for(ce_data->cpu); | 536 | dom = get_domain_for(ce_data->cpu); |
537 | 537 | ||
538 | TRACE("timer callback on CPU %d (before lock)\n", ce_data->cpu); | 538 | STRACE("timer callback on CPU %d (before lock)\n", ce_data->cpu); |
539 | 539 | ||
540 | raw_spin_lock_irqsave(dom->lock, flags); | 540 | raw_spin_lock_irqsave(dom->lock, flags); |
541 | next_timer_abs = mc_ce_timer_callback_common(dom); | 541 | next_timer_abs = mc_ce_timer_callback_common(dom); |
@@ -569,7 +569,7 @@ static int cancel_all_timers(void) | |||
569 | int cancel_res; | 569 | int cancel_res; |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | TRACE("cancel all timers\n"); | 572 | STRACE("cancel all timers\n"); |
573 | 573 | ||
574 | for_each_online_cpu(cpu) { | 574 | for_each_online_cpu(cpu) { |
575 | dom = get_domain_for(cpu); | 575 | dom = get_domain_for(cpu); |
@@ -579,6 +579,8 @@ static int cancel_all_timers(void) | |||
579 | cancel_event(&ce_data->event); | 579 | cancel_event(&ce_data->event); |
580 | #else | 580 | #else |
581 | cancel_res = hrtimer_cancel(&ce_data->timer); | 581 | cancel_res = hrtimer_cancel(&ce_data->timer); |
582 | atomic_set(&ce_data->timer_info.state, | ||
583 | HRTIMER_START_ON_INACTIVE); | ||
582 | ret = ret || cancel_res; | 584 | ret = ret || cancel_res; |
583 | #endif | 585 | #endif |
584 | } | 586 | } |
@@ -598,7 +600,7 @@ static void arm_all_timers(void) | |||
598 | int cpu, idx, cpu_for_timer; | 600 | int cpu, idx, cpu_for_timer; |
599 | const lt_t start = atomic64_read(&start_time); | 601 | const lt_t start = atomic64_read(&start_time); |
600 | 602 | ||
601 | TRACE("arm all timers\n"); | 603 | STRACE("arm all timers\n"); |
602 | 604 | ||
603 | for_each_online_cpu(cpu) { | 605 | for_each_online_cpu(cpu) { |
604 | dom = get_domain_for(cpu); | 606 | dom = get_domain_for(cpu); |
@@ -619,6 +621,9 @@ static void arm_all_timers(void) | |||
619 | add_event(get_event_group_for(cpu_for_timer), | 621 | add_event(get_event_group_for(cpu_for_timer), |
620 | &ce_data->event, start); | 622 | &ce_data->event, start); |
621 | #else | 623 | #else |
624 | hrtimer_start_on(cpu_for_timer, &ce_data->timer_info, | ||
625 | &ce_data->timer, ns_to_ktime(start), | ||
626 | HRTIMER_MODE_ABS_PINNED); | ||
622 | #endif | 627 | #endif |
623 | } | 628 | } |
624 | } | 629 | } |
@@ -630,7 +635,7 @@ static void arm_all_timers(void) | |||
630 | */ | 635 | */ |
631 | void mc_ce_release_at_common(struct task_struct *ts, lt_t start) | 636 | void mc_ce_release_at_common(struct task_struct *ts, lt_t start) |
632 | { | 637 | { |
633 | TRACE("release CE at %llu\n", start); | 638 | STRACE("release CE at %llu\n", start); |
634 | if (atomic_inc_and_test(&start_time_set)) { | 639 | if (atomic_inc_and_test(&start_time_set)) { |
635 | /* in this case, we won the race */ | 640 | /* in this case, we won the race */ |
636 | cancel_all_timers(); | 641 | cancel_all_timers(); |