aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2011-05-07 19:38:51 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2011-05-07 19:38:51 -0400
commitd0598c54028251a018650665043156266664e0bf (patch)
tree15e3b140b96ec5abdb6030396ad8facd3dd61ce2
parent1a05af24647f5655769ce16d48d02e726fc1dbab (diff)
Changed candidate queue logic
-rw-r--r--litmus/sched_edf_hsb.c50
-rw-r--r--litmus/sched_edf_hsb_noslack.c107
2 files changed, 84 insertions, 73 deletions
diff --git a/litmus/sched_edf_hsb.c b/litmus/sched_edf_hsb.c
index fd2070c6f94d..d74f4337ac2b 100644
--- a/litmus/sched_edf_hsb.c
+++ b/litmus/sched_edf_hsb.c
@@ -243,7 +243,7 @@ static void remove_slack(server_t *slack)
243 if (!slack) 243 if (!slack)
244 return; 244 return;
245 TRACE_SERVER_SUB(slack, "slack removed"); 245 TRACE_SERVER_SUB(slack, "slack removed");
246 //sched_trace_action(NULL, SLACK_EXPIRED_ACTION); 246 //////sched_trace_action(NULL, SLACK_EXPIRED_ACTION);
247 247
248 if (head_in_list(&slack->list)) 248 if (head_in_list(&slack->list))
249 list_del_init(&slack->list); 249 list_del_init(&slack->list);
@@ -288,6 +288,13 @@ static inline struct task_struct* get_candidate(struct list_head *pos)
288 return task; 288 return task;
289} 289}
290 290
291static inline lt_t real_deadline(struct task_struct *task)
292{
293 server_t *server = task_srt_server(task);
294 int job_diff = server->job_no - task_job_no(task);
295 return get_deadline(task) - job_diff * get_rt_period(task);
296}
297
291/* 298/*
292 * Candidate queue is EDF. 299 * Candidate queue is EDF.
293 */ 300 */
@@ -300,7 +307,7 @@ static void add_slack_candidate(struct task_struct *task)
300 307
301 list_for_each_prev(pos, &slack_candidates) { 308 list_for_each_prev(pos, &slack_candidates) {
302 queued = get_candidate(pos); 309 queued = get_candidate(pos);
303 if (lt_before_eq(get_deadline(queued), get_deadline(task))) { 310 if (lt_before_eq(real_deadline(queued), real_deadline(task))) {
304 __list_add(&task_data(task)->candidate_list, 311 __list_add(&task_data(task)->candidate_list,
305 pos, pos->next); 312 pos, pos->next);
306 return; 313 return;
@@ -321,8 +328,6 @@ static void donate_slack(server_t *donator)
321 BUG_ON(!hrt_server->ready); 328 BUG_ON(!hrt_server->ready);
322 } 329 }
323 330
324 BUG_ON(head_in_list(&slack->list));
325
326 slack->wcet = donator->budget; 331 slack->wcet = donator->budget;
327 slack->budget = donator->budget; 332 slack->budget = donator->budget;
328 slack->deadline = donator->deadline; 333 slack->deadline = donator->deadline;
@@ -373,7 +378,7 @@ static noinline void check_donate_slack(server_t *donator, struct task_struct *w
373 if (!donate) 378 if (!donate)
374 return; 379 return;
375 380
376 sched_trace_action(was_scheduled, SLACK_DONATED_ACTION); 381 ////sched_trace_action(was_scheduled, SLACK_DONATED_ACTION);
377 382
378 donate_slack(donator); 383 donate_slack(donator);
379} 384}
@@ -664,7 +669,7 @@ static void requeue_server(server_t *server, lt_t now)
664 hrt_server->ready = 1; 669 hrt_server->ready = 1;
665 remove_slack(server_slack(server)); 670 remove_slack(server_slack(server));
666 hrt_server->no_slack = 0; 671 hrt_server->no_slack = 0;
667 sched_trace_action(NULL, SERVER_RELEASED_ACTION); 672 ////sched_trace_action(NULL, SERVER_RELEASED_ACTION);
668 } else if (server->type == S_BE) { 673 } else if (server->type == S_BE) {
669 TRACE_SERVER_SUB(server, "BE added to ready"); 674 TRACE_SERVER_SUB(server, "BE added to ready");
670 bheap_insert(server_order, &be_ready_servers, server->hn); 675 bheap_insert(server_order, &be_ready_servers, server->hn);
@@ -686,7 +691,7 @@ static void reclaim_slack(server_t *slack)
686 return; 691 return;
687 692
688 /* SRT servers do not ever reclaim slack */ 693 /* SRT servers do not ever reclaim slack */
689 sched_trace_action(NULL, SLACK_RECLAIM_ACTION); 694 ////sched_trace_action(NULL, SLACK_RECLAIM_ACTION);
690 695
691 exec = slack->wcet - slack->budget; 696 exec = slack->wcet - slack->budget;
692 TRACE_SERVER_SUB(donator, "reclaiming %llu slack", TIME(exec)); 697 TRACE_SERVER_SUB(donator, "reclaiming %llu slack", TIME(exec));
@@ -726,7 +731,7 @@ static noinline void link_server(cpu_entry_t *entry,
726 /* Should have already been removed from slack list */ 731 /* Should have already been removed from slack list */
727 BUG_ON(head_in_list(&task_data(entry->linked)->candidate_list)); 732 BUG_ON(head_in_list(&task_data(entry->linked)->candidate_list));
728 BUG_ON(is_be(entry->linked) && is_queued(entry->linked)); 733 BUG_ON(is_be(entry->linked) && is_queued(entry->linked));
729 sched_trace_action(entry->linked, SLACK_RUN_ACTION); 734 ////sched_trace_action(entry->linked, SLACK_RUN_ACTION);
730 BUG_ON(is_srt(entry->linked) && 735 BUG_ON(is_srt(entry->linked) &&
731 task_srt_server(entry->linked)->job_no <= 736 task_srt_server(entry->linked)->job_no <=
732 task_job_no(entry->linked)); 737 task_job_no(entry->linked));
@@ -734,7 +739,7 @@ static noinline void link_server(cpu_entry_t *entry,
734 /* Should have already been removed from ready heap */ 739 /* Should have already been removed from ready heap */
735 BUG_ON(bheap_node_in_heap(next_server->hn)); 740 BUG_ON(bheap_node_in_heap(next_server->hn));
736 BUG_ON(is_queued(entry->linked)); 741 BUG_ON(is_queued(entry->linked));
737 sched_trace_action(entry->linked, next_server->id); 742 ////sched_trace_action(entry->linked, next_server->id);
738 } 743 }
739 744
740 if (next_server->type != S_SLACK && 745 if (next_server->type != S_SLACK &&
@@ -773,7 +778,7 @@ static noinline void unlink_server(cpu_entry_t *entry, int requeue)
773 778
774 if (server->type == S_SLACK && server->deadline) { 779 if (server->type == S_SLACK && server->deadline) {
775 add_slack(server); 780 add_slack(server);
776 sched_trace_action(entry->linked, SLACK_STOP_ACTION); 781 ////sched_trace_action(entry->linked, SLACK_STOP_ACTION);
777 782
778 /* Donator needs to absorb slack execution time */ 783 /* Donator needs to absorb slack execution time */
779 reclaim_slack(server); 784 reclaim_slack(server);
@@ -1004,7 +1009,7 @@ static noinline int catchup_srt_server(struct task_struct *task)
1004 1009
1005 rv = 1; 1010 rv = 1;
1006 1011
1007 sched_trace_action(task, SERVER_RELEASED_ACTION); 1012 ////sched_trace_action(task, SERVER_RELEASED_ACTION);
1008 1013
1009 } else if (lt_before(srt_server->deadline, now) && 1014 } else if (lt_before(srt_server->deadline, now) &&
1010 srt_server->job_no <= 1) { 1015 srt_server->job_no <= 1) {
@@ -1053,7 +1058,7 @@ static noinline struct task_struct* next_eligible_hrt(hrt_server_t *hrt_server)
1053 slack = lt_subtract(hrt_server->server.deadline, 1058 slack = lt_subtract(hrt_server->server.deadline,
1054 hrt_server->server.budget); 1059 hrt_server->server.budget);
1055 1060
1056 sched_trace_action(task, SERVER_RELEASED_ACTION); 1061 ////sched_trace_action(task, SERVER_RELEASED_ACTION);
1057 } 1062 }
1058 1063
1059 /* If the slack timer is active, this is not necessary */ 1064 /* If the slack timer is active, this is not necessary */
@@ -1063,7 +1068,7 @@ static noinline struct task_struct* next_eligible_hrt(hrt_server_t *hrt_server)
1063 TRACE_SERVER_SUB(&hrt_server->server, "no slack: %llu", 1068 TRACE_SERVER_SUB(&hrt_server->server, "no slack: %llu",
1064 TIME(slack)); 1069 TIME(slack));
1065 hrt_server->no_slack = 1; 1070 hrt_server->no_slack = 1;
1066 sched_trace_action(task, NO_SLACK_ACTION); 1071 ////sched_trace_action(task, NO_SLACK_ACTION);
1067 } else { 1072 } else {
1068 slack_timer_arm(hrt_server); 1073 slack_timer_arm(hrt_server);
1069 } 1074 }
@@ -1173,7 +1178,8 @@ static noinline server_t* next_eligible_be_server(void)
1173 1178
1174 if (is_server_linked(be_server)) { 1179 if (is_server_linked(be_server)) {
1175 TRACE_SERVER_SUB(be_server, "linked"); 1180 TRACE_SERVER_SUB(be_server, "linked");
1176 continue; 1181 be_server = next_be_server();
1182 return NULL;
1177 } 1183 }
1178 1184
1179 catchup_server(be_server, now); 1185 catchup_server(be_server, now);
@@ -1182,7 +1188,7 @@ static noinline server_t* next_eligible_be_server(void)
1182 be_server->hn); 1188 be_server->hn);
1183 be_server = next_be_server(); 1189 be_server = next_be_server();
1184 TRACE_SERVER_SUB(be_server, "catching up BE server"); 1190 TRACE_SERVER_SUB(be_server, "catching up BE server");
1185 sched_trace_action(NULL, SERVER_RELEASED_ACTION); /* Release */ 1191 ////sched_trace_action(NULL, SERVER_RELEASED_ACTION); /* Release */
1186 } 1192 }
1187 1193
1188 if (be_server && lt_before(now, be_server->release)) { 1194 if (be_server && lt_before(now, be_server->release)) {
@@ -1692,7 +1698,7 @@ static enum hrtimer_restart slack_timer_fire(struct hrtimer *timer)
1692 1698
1693 TRACE_TIMER("slack timer fired for P%d", entry->cpu); 1699 TRACE_TIMER("slack timer fired for P%d", entry->cpu);
1694 BUG_ON(!server->ready); 1700 BUG_ON(!server->ready);
1695 sched_trace_action(entry->linked, NO_SLACK_ACTION); 1701 ////sched_trace_action(entry->linked, NO_SLACK_ACTION);
1696 1702
1697 /* Set new state of entry */ 1703 /* Set new state of entry */
1698 server->no_slack = 1; 1704 server->no_slack = 1;
@@ -1729,9 +1735,7 @@ static void job_completion(cpu_entry_t *entry, struct task_struct* task)
1729 "rel: %llu, dead: %llu", 1735 "rel: %llu, dead: %llu",
1730 TIME(get_release(task)), 1736 TIME(get_release(task)),
1731 TIME(get_deadline(task))); 1737 TIME(get_deadline(task)));
1732 } 1738 } else if (server->type == S_SRT) {
1733
1734 if (server->type == S_SRT) {
1735 /* If the task is behind the server it must release immediately, 1739 /* If the task is behind the server it must release immediately,
1736 * leaving its release time and deadline unchanged. 1740 * leaving its release time and deadline unchanged.
1737 */ 1741 */
@@ -1803,9 +1807,10 @@ static void server_completed(server_t *server, struct task_struct *task)
1803 1807
1804 if (server->type != S_SLACK) { 1808 if (server->type != S_SLACK) {
1805 server_release(server); 1809 server_release(server);
1806 sched_trace_action(task, SERVER_COMPLETED_ACTION);
1807 } 1810 }
1808 1811
1812 sched_trace_action(task, SERVER_COMPLETED_ACTION);
1813
1809 unlink(task); 1814 unlink(task);
1810 requeue(task, get_rt_domain(entry, task)); 1815 requeue(task, get_rt_domain(entry, task));
1811 1816
@@ -1853,7 +1858,7 @@ static void servers_released(struct list_head *servers)
1853 1858
1854 raw_spin_lock_irqsave(global_lock, flags); 1859 raw_spin_lock_irqsave(global_lock, flags);
1855 1860
1856 sched_trace_action(NULL, SERVER_RELEASED_ACTION); 1861 ////sched_trace_action(NULL, SERVER_RELEASED_ACTION);
1857 TRACE_TIMER("Servers released"); 1862 TRACE_TIMER("Servers released");
1858 1863
1859 list_for_each_safe(pos, safe, servers) { 1864 list_for_each_safe(pos, safe, servers) {
@@ -2151,7 +2156,8 @@ static void edf_hsb_task_block(struct task_struct *task)
2151 struct task_struct *linked; 2156 struct task_struct *linked;
2152 server_t *linked_server; 2157 server_t *linked_server;
2153 2158
2154 TRACE_TASK(task, "block at %llu\n", litmus_clock()); 2159 TRACE_TASK(task, "block at %llu in state %llu\n",
2160 litmus_clock(), task->state);
2155 set_rt_flags(task, RT_F_BLOCK); 2161 set_rt_flags(task, RT_F_BLOCK);
2156 2162
2157 raw_spin_lock_irqsave(global_lock, flags); 2163 raw_spin_lock_irqsave(global_lock, flags);
diff --git a/litmus/sched_edf_hsb_noslack.c b/litmus/sched_edf_hsb_noslack.c
index 545588dbc915..4d91f99d4094 100644
--- a/litmus/sched_edf_hsb_noslack.c
+++ b/litmus/sched_edf_hsb_noslack.c
@@ -243,7 +243,7 @@ static void remove_slack(server_t *slack)
243 if (!slack) 243 if (!slack)
244 return; 244 return;
245 TRACE_SERVER_SUB(slack, "slack removed"); 245 TRACE_SERVER_SUB(slack, "slack removed");
246 //sched_trace_action(NULL, SLACK_EXPIRED_ACTION); 246 //////sched_trace_action(NULL, SLACK_EXPIRED_ACTION);
247 247
248 if (head_in_list(&slack->list)) 248 if (head_in_list(&slack->list))
249 list_del_init(&slack->list); 249 list_del_init(&slack->list);
@@ -288,6 +288,13 @@ static inline struct task_struct* get_candidate(struct list_head *pos)
288 return task; 288 return task;
289} 289}
290 290
291static inline lt_t real_deadline(struct task_struct *task)
292{
293 server_t *server = task_srt_server(task);
294 int job_diff = server->job_no - task_job_no(task);
295 return get_deadline(task) - job_diff * get_rt_period(task);
296}
297
291/* 298/*
292 * Candidate queue is EDF. 299 * Candidate queue is EDF.
293 */ 300 */
@@ -300,7 +307,7 @@ static void add_slack_candidate(struct task_struct *task)
300 307
301 list_for_each_prev(pos, &slack_candidates) { 308 list_for_each_prev(pos, &slack_candidates) {
302 queued = get_candidate(pos); 309 queued = get_candidate(pos);
303 if (lt_before_eq(get_deadline(queued), get_deadline(task))) { 310 if (lt_before_eq(real_deadline(queued), real_deadline(task))) {
304 __list_add(&task_data(task)->candidate_list, 311 __list_add(&task_data(task)->candidate_list,
305 pos, pos->next); 312 pos, pos->next);
306 return; 313 return;
@@ -321,8 +328,6 @@ static void donate_slack(server_t *donator)
321 BUG_ON(!hrt_server->ready); 328 BUG_ON(!hrt_server->ready);
322 } 329 }
323 330
324 BUG_ON(head_in_list(&slack->list));
325
326 slack->wcet = donator->budget; 331 slack->wcet = donator->budget;
327 slack->budget = donator->budget; 332 slack->budget = donator->budget;
328 slack->deadline = donator->deadline; 333 slack->deadline = donator->deadline;
@@ -373,7 +378,7 @@ static noinline void check_donate_slack(server_t *donator, struct task_struct *w
373 if (!donate) 378 if (!donate)
374 return; 379 return;
375 380
376 sched_trace_action(was_scheduled, SLACK_DONATED_ACTION); 381 ////sched_trace_action(was_scheduled, SLACK_DONATED_ACTION);
377 382
378 donate_slack(donator); 383 donate_slack(donator);
379} 384}
@@ -439,10 +444,9 @@ static noinline server_t* next_eligible_slack_server(void)
439 */ 444 */
440static noinline struct task_struct* next_eligible_slack(void) 445static noinline struct task_struct* next_eligible_slack(void)
441{ 446{
442 struct task_struct *next = NULL; 447 struct task_struct *next = get_candidate(slack_candidates.next);
443 448
444 next = get_candidate(slack_candidates.next); 449 while (next && task_srt_server(next)->job_no <= task_job_no(next)) {
445 while (next && tsk_rt(next)->linked_on != NO_CPU) {
446 list_del_init(&task_data(next)->candidate_list); 450 list_del_init(&task_data(next)->candidate_list);
447 next = get_candidate(slack_candidates.next); 451 next = get_candidate(slack_candidates.next);
448 } 452 }
@@ -454,8 +458,6 @@ static noinline struct task_struct* next_eligible_slack(void)
454 next = __peek_ready(&be_domain); 458 next = __peek_ready(&be_domain);
455 } 459 }
456 460
457 BUG_ON(next && tsk_rt(next)->linked_on != NO_CPU);
458
459 return next; 461 return next;
460} 462}
461 463
@@ -667,7 +669,7 @@ static void requeue_server(server_t *server, lt_t now)
667 hrt_server->ready = 1; 669 hrt_server->ready = 1;
668 remove_slack(server_slack(server)); 670 remove_slack(server_slack(server));
669 hrt_server->no_slack = 0; 671 hrt_server->no_slack = 0;
670 sched_trace_action(NULL, SERVER_RELEASED_ACTION); 672 ////sched_trace_action(NULL, SERVER_RELEASED_ACTION);
671 } else if (server->type == S_BE) { 673 } else if (server->type == S_BE) {
672 TRACE_SERVER_SUB(server, "BE added to ready"); 674 TRACE_SERVER_SUB(server, "BE added to ready");
673 bheap_insert(server_order, &be_ready_servers, server->hn); 675 bheap_insert(server_order, &be_ready_servers, server->hn);
@@ -685,11 +687,11 @@ static void reclaim_slack(server_t *slack)
685 lt_t exec; 687 lt_t exec;
686 server_t *donator = server_slack(slack); 688 server_t *donator = server_slack(slack);
687 689
688 if (!donator) 690 if (!donator || lt_before_eq(slack->deadline, litmus_clock()))
689 return; 691 return;
690 692
691 /* SRT servers do not ever reclaim slack */ 693 /* SRT servers do not ever reclaim slack */
692 sched_trace_action(NULL, SLACK_RECLAIM_ACTION); 694 ////sched_trace_action(NULL, SLACK_RECLAIM_ACTION);
693 695
694 exec = slack->wcet - slack->budget; 696 exec = slack->wcet - slack->budget;
695 TRACE_SERVER_SUB(donator, "reclaiming %llu slack", TIME(exec)); 697 TRACE_SERVER_SUB(donator, "reclaiming %llu slack", TIME(exec));
@@ -721,7 +723,6 @@ static noinline void link_server(cpu_entry_t *entry,
721 BUG_ON(next_server->job_no + 1 < task_job_no(entry->linked)); 723 BUG_ON(next_server->job_no + 1 < task_job_no(entry->linked));
722 BUG_ON(lt_after(get_deadline(entry->linked), 724 BUG_ON(lt_after(get_deadline(entry->linked),
723 next_server->deadline)); 725 next_server->deadline));
724 BUG_ON(head_in_list(&task_data(entry->linked)->candidate_list));
725 } else if (next_server->type == S_HRT) { 726 } else if (next_server->type == S_HRT) {
726 /* HRT servers should never, ever migrate */ 727 /* HRT servers should never, ever migrate */
727 BUG_ON(entry->cpu != task_cpu(entry->linked)); 728 BUG_ON(entry->cpu != task_cpu(entry->linked));
@@ -730,12 +731,15 @@ static noinline void link_server(cpu_entry_t *entry,
730 /* Should have already been removed from slack list */ 731 /* Should have already been removed from slack list */
731 BUG_ON(head_in_list(&task_data(entry->linked)->candidate_list)); 732 BUG_ON(head_in_list(&task_data(entry->linked)->candidate_list));
732 BUG_ON(is_be(entry->linked) && is_queued(entry->linked)); 733 BUG_ON(is_be(entry->linked) && is_queued(entry->linked));
733 sched_trace_action(entry->linked, SLACK_RUN_ACTION); 734 ////sched_trace_action(entry->linked, SLACK_RUN_ACTION);
735 BUG_ON(is_srt(entry->linked) &&
736 task_srt_server(entry->linked)->job_no <=
737 task_job_no(entry->linked));
734 } else { /* BE */ 738 } else { /* BE */
735 /* Should have already been removed from ready heap */ 739 /* Should have already been removed from ready heap */
736 BUG_ON(bheap_node_in_heap(next_server->hn)); 740 BUG_ON(bheap_node_in_heap(next_server->hn));
737 BUG_ON(is_queued(entry->linked)); 741 BUG_ON(is_queued(entry->linked));
738 sched_trace_action(entry->linked, next_server->id); 742 ////sched_trace_action(entry->linked, next_server->id);
739 } 743 }
740 744
741 if (next_server->type != S_SLACK && 745 if (next_server->type != S_SLACK &&
@@ -774,7 +778,7 @@ static noinline void unlink_server(cpu_entry_t *entry, int requeue)
774 778
775 if (server->type == S_SLACK && server->deadline) { 779 if (server->type == S_SLACK && server->deadline) {
776 add_slack(server); 780 add_slack(server);
777 sched_trace_action(entry->linked, SLACK_STOP_ACTION); 781 ////sched_trace_action(entry->linked, SLACK_STOP_ACTION);
778 782
779 /* Donator needs to absorb slack execution time */ 783 /* Donator needs to absorb slack execution time */
780 reclaim_slack(server); 784 reclaim_slack(server);
@@ -940,6 +944,7 @@ static noinline void unlink(struct task_struct* t)
940 if (head_in_list(&task_data(t)->candidate_list)) { 944 if (head_in_list(&task_data(t)->candidate_list)) {
941 list_del_init(&task_data(t)->candidate_list); 945 list_del_init(&task_data(t)->candidate_list);
942 } 946 }
947
943} 948}
944 949
945/* 950/*
@@ -1004,7 +1009,7 @@ static noinline int catchup_srt_server(struct task_struct *task)
1004 1009
1005 rv = 1; 1010 rv = 1;
1006 1011
1007 sched_trace_action(task, SERVER_RELEASED_ACTION); 1012 ////sched_trace_action(task, SERVER_RELEASED_ACTION);
1008 1013
1009 } else if (lt_before(srt_server->deadline, now) && 1014 } else if (lt_before(srt_server->deadline, now) &&
1010 srt_server->job_no <= 1) { 1015 srt_server->job_no <= 1) {
@@ -1053,7 +1058,7 @@ static noinline struct task_struct* next_eligible_hrt(hrt_server_t *hrt_server)
1053 slack = lt_subtract(hrt_server->server.deadline, 1058 slack = lt_subtract(hrt_server->server.deadline,
1054 hrt_server->server.budget); 1059 hrt_server->server.budget);
1055 1060
1056 sched_trace_action(task, SERVER_RELEASED_ACTION); 1061 ////sched_trace_action(task, SERVER_RELEASED_ACTION);
1057 } 1062 }
1058 1063
1059 /* If the slack timer is active, this is not necessary */ 1064 /* If the slack timer is active, this is not necessary */
@@ -1063,7 +1068,7 @@ static noinline struct task_struct* next_eligible_hrt(hrt_server_t *hrt_server)
1063 TRACE_SERVER_SUB(&hrt_server->server, "no slack: %llu", 1068 TRACE_SERVER_SUB(&hrt_server->server, "no slack: %llu",
1064 TIME(slack)); 1069 TIME(slack));
1065 hrt_server->no_slack = 1; 1070 hrt_server->no_slack = 1;
1066 sched_trace_action(task, NO_SLACK_ACTION); 1071 ////sched_trace_action(task, NO_SLACK_ACTION);
1067 } else { 1072 } else {
1068 slack_timer_arm(hrt_server); 1073 slack_timer_arm(hrt_server);
1069 } 1074 }
@@ -1173,7 +1178,8 @@ static noinline server_t* next_eligible_be_server(void)
1173 1178
1174 if (is_server_linked(be_server)) { 1179 if (is_server_linked(be_server)) {
1175 TRACE_SERVER_SUB(be_server, "linked"); 1180 TRACE_SERVER_SUB(be_server, "linked");
1176 continue; 1181 be_server = next_be_server();
1182 return NULL;
1177 } 1183 }
1178 1184
1179 catchup_server(be_server, now); 1185 catchup_server(be_server, now);
@@ -1182,7 +1188,7 @@ static noinline server_t* next_eligible_be_server(void)
1182 be_server->hn); 1188 be_server->hn);
1183 be_server = next_be_server(); 1189 be_server = next_be_server();
1184 TRACE_SERVER_SUB(be_server, "catching up BE server"); 1190 TRACE_SERVER_SUB(be_server, "catching up BE server");
1185 sched_trace_action(NULL, SERVER_RELEASED_ACTION); /* Release */ 1191 ////sched_trace_action(NULL, SERVER_RELEASED_ACTION); /* Release */
1186 } 1192 }
1187 1193
1188 if (be_server && lt_before(now, be_server->release)) { 1194 if (be_server && lt_before(now, be_server->release)) {
@@ -1279,10 +1285,6 @@ static void next_global_task(cpu_entry_t *entry,
1279 next_slack = next_eligible_slack(); 1285 next_slack = next_eligible_slack();
1280 slack_server = next_eligible_slack_server(); 1286 slack_server = next_eligible_slack_server();
1281 1287
1282 BUG_ON(next_slack && tsk_rt(next_slack)->linked_on != NO_CPU);
1283 BUG_ON(next_srt && tsk_rt(next_srt)->linked_on != NO_CPU);
1284 BUG_ON(next_be && tsk_rt(next_be)->linked_on != NO_CPU);
1285
1286 TRACE_SUB("be_server: %d, next_be: %d, next_srt: %d, slack_server: %d " 1288 TRACE_SUB("be_server: %d, next_be: %d, next_srt: %d, slack_server: %d "
1287 "next_slack: %d", (be_server) ? be_server->id : -1, 1289 "next_slack: %d", (be_server) ? be_server->id : -1,
1288 (next_be) ? next_be->pid : -1, 1290 (next_be) ? next_be->pid : -1,
@@ -1359,6 +1361,12 @@ static void remove_from_ready(server_t *server, struct task_struct *task,
1359 TRACE_TASK_SUB(task, "BE removed from ready"); 1361 TRACE_TASK_SUB(task, "BE removed from ready");
1360 remove(&be_domain, task); 1362 remove(&be_domain, task);
1361 } 1363 }
1364
1365 /* Remove from consideration of slack servers */
1366 if (head_in_list(&task_data(task)->candidate_list)) {
1367 TRACE_TASK_SUB(task, "deleting candidate");
1368 list_del_init(&task_data(task)->candidate_list);
1369 }
1362 } else { 1370 } else {
1363 slack = server_slack(server); 1371 slack = server_slack(server);
1364 if (slack && head_in_list(&slack->list)) { 1372 if (slack && head_in_list(&slack->list)) {
@@ -1379,13 +1387,6 @@ static void remove_from_ready(server_t *server, struct task_struct *task,
1379 } 1387 }
1380 1388
1381 BUG_ON(!task_data(task)); 1389 BUG_ON(!task_data(task));
1382
1383 /* Remove from consideration of slack servers */
1384 if (head_in_list(&task_data(task)->candidate_list)) {
1385 TRACE_TASK_SUB(task, "deleting candidate");
1386 list_del_init(&task_data(task)->candidate_list);
1387 }
1388
1389} 1390}
1390 1391
1391static void check_for_slack_preempt(struct task_struct*,server_t*,cpu_entry_t*, int); 1392static void check_for_slack_preempt(struct task_struct*,server_t*,cpu_entry_t*, int);
@@ -1469,11 +1470,21 @@ static noinline void check_for_slack_preempt(struct task_struct *task,
1469 server_t *slack = server_slack(server); 1470 server_t *slack = server_slack(server);
1470 struct task_struct *slack_task; 1471 struct task_struct *slack_task;
1471 1472
1472 /* Bad! There is no use trying to move the link of this task as it 1473 /* The task is currently being run by another server */
1473 * is almost always scheduled on another CPU. 1474 if (tsk_rt(task)->linked_on != NO_CPU) {
1474 */ 1475 entry = task_linked_entry(task);
1475 BUG_ON(tsk_rt(task)->linked_on != NO_CPU && 1476
1476 tsk_rt(task)->linked_on != next_entry->cpu); 1477 if (entry != next_entry) {
1478 TRACE_TASK_SUB(task, "was on P%d", entry->cpu);
1479
1480 unlink(task);
1481
1482 /* if (resched) { */
1483 /* edf_hsb_pick_next(entry); */
1484 /* preempt_if_preemptable(entry->scheduled, entry->cpu); */
1485 /* } */
1486 }
1487 }
1477 1488
1478 /* The server's slack is currently being run */ 1489 /* The server's slack is currently being run */
1479 if (slack && is_server_linked(slack)) { 1490 if (slack && is_server_linked(slack)) {
@@ -1687,7 +1698,7 @@ static enum hrtimer_restart slack_timer_fire(struct hrtimer *timer)
1687 1698
1688 TRACE_TIMER("slack timer fired for P%d", entry->cpu); 1699 TRACE_TIMER("slack timer fired for P%d", entry->cpu);
1689 BUG_ON(!server->ready); 1700 BUG_ON(!server->ready);
1690 sched_trace_action(entry->linked, NO_SLACK_ACTION); 1701 ////sched_trace_action(entry->linked, NO_SLACK_ACTION);
1691 1702
1692 /* Set new state of entry */ 1703 /* Set new state of entry */
1693 server->no_slack = 1; 1704 server->no_slack = 1;
@@ -1724,15 +1735,7 @@ static void job_completion(cpu_entry_t *entry, struct task_struct* task)
1724 "rel: %llu, dead: %llu", 1735 "rel: %llu, dead: %llu",
1725 TIME(get_release(task)), 1736 TIME(get_release(task)),
1726 TIME(get_deadline(task))); 1737 TIME(get_deadline(task)));
1727 check_slack_candidate(task); 1738 } else if (server->type == S_SRT) {
1728 sched_trace_task_completion(task, 1);
1729
1730 return;
1731 }
1732
1733 BUG_ON(is_queued(task));
1734
1735 if (server->type == S_SRT) {
1736 /* If the task is behind the server it must release immediately, 1739 /* If the task is behind the server it must release immediately,
1737 * leaving its release time and deadline unchanged. 1740 * leaving its release time and deadline unchanged.
1738 */ 1741 */
@@ -1804,9 +1807,10 @@ static void server_completed(server_t *server, struct task_struct *task)
1804 1807
1805 if (server->type != S_SLACK) { 1808 if (server->type != S_SLACK) {
1806 server_release(server); 1809 server_release(server);
1807 sched_trace_action(task, SERVER_COMPLETED_ACTION);
1808 } 1810 }
1809 1811
1812 sched_trace_action(task, SERVER_COMPLETED_ACTION);
1813
1810 unlink(task); 1814 unlink(task);
1811 requeue(task, get_rt_domain(entry, task)); 1815 requeue(task, get_rt_domain(entry, task));
1812 1816
@@ -1854,7 +1858,7 @@ static void servers_released(struct list_head *servers)
1854 1858
1855 raw_spin_lock_irqsave(global_lock, flags); 1859 raw_spin_lock_irqsave(global_lock, flags);
1856 1860
1857 sched_trace_action(NULL, SERVER_RELEASED_ACTION); 1861 ////sched_trace_action(NULL, SERVER_RELEASED_ACTION);
1858 TRACE_TIMER("Servers released"); 1862 TRACE_TIMER("Servers released");
1859 1863
1860 list_for_each_safe(pos, safe, servers) { 1864 list_for_each_safe(pos, safe, servers) {
@@ -2152,7 +2156,8 @@ static void edf_hsb_task_block(struct task_struct *task)
2152 struct task_struct *linked; 2156 struct task_struct *linked;
2153 server_t *linked_server; 2157 server_t *linked_server;
2154 2158
2155 TRACE_TASK(task, "block at %llu\n", litmus_clock()); 2159 TRACE_TASK(task, "block at %llu in state %llu\n",
2160 litmus_clock(), task->state);
2156 set_rt_flags(task, RT_F_BLOCK); 2161 set_rt_flags(task, RT_F_BLOCK);
2157 2162
2158 raw_spin_lock_irqsave(global_lock, flags); 2163 raw_spin_lock_irqsave(global_lock, flags);