diff options
author | Jonathan <hermanjl@bonham.cs.unc.edu> | 2011-05-04 22:28:02 -0400 |
---|---|---|
committer | Jonathan <hermanjl@bonham.cs.unc.edu> | 2011-05-04 22:28:02 -0400 |
commit | 8886341b65aade46544912ad39f9205292a54375 (patch) | |
tree | f5e27137b0ce31ecbfaa3ad029c071b5c309a3ec | |
parent | 8c05d10580b60b0bcec570aa928151f5b05a15e0 (diff) |
Added bug ons in case of stack deadlock
-rw-r--r-- | litmus/Kconfig | 4 | ||||
-rw-r--r-- | litmus/sched_edf_hsb.c | 26 | ||||
-rw-r--r-- | litmus/sched_edf_hsb_noslack.c | 23 |
3 files changed, 44 insertions, 9 deletions
diff --git a/litmus/Kconfig b/litmus/Kconfig index 46563edf513c..08f4d5f62a71 100644 --- a/litmus/Kconfig +++ b/litmus/Kconfig | |||
@@ -110,8 +110,8 @@ config SCHED_TASK_TRACE | |||
110 | config SCHED_TASK_TRACE_SHIFT | 110 | config SCHED_TASK_TRACE_SHIFT |
111 | int "Buffer size for sched_trace_xxx() events" | 111 | int "Buffer size for sched_trace_xxx() events" |
112 | depends on SCHED_TASK_TRACE | 112 | depends on SCHED_TASK_TRACE |
113 | range 8 13 | 113 | range 8 24 |
114 | default 9 | 114 | default 24 |
115 | help | 115 | help |
116 | 116 | ||
117 | Select the buffer size of sched_trace_xxx() events as a power of two. | 117 | Select the buffer size of sched_trace_xxx() events as a power of two. |
diff --git a/litmus/sched_edf_hsb.c b/litmus/sched_edf_hsb.c index d176efca648b..8de315c0774d 100644 --- a/litmus/sched_edf_hsb.c +++ b/litmus/sched_edf_hsb.c | |||
@@ -262,8 +262,10 @@ static void add_slack(server_t *slack) | |||
262 | 262 | ||
263 | TRACE_SERVER_SUB(slack, "slack added"); | 263 | TRACE_SERVER_SUB(slack, "slack added"); |
264 | 264 | ||
265 | if (head_in_list(&slack->list)) | 265 | if (head_in_list(&slack->list)) { |
266 | TRACE_SERVER_SUB(slack, "already in list"); | ||
266 | return; | 267 | return; |
268 | } | ||
267 | 269 | ||
268 | list_for_each_prev(pos, &slack_queue) { | 270 | list_for_each_prev(pos, &slack_queue) { |
269 | queued = list_entry(pos, server_t, list); | 271 | queued = list_entry(pos, server_t, list); |
@@ -353,8 +355,9 @@ static noinline void check_donate_slack(server_t *donator, struct task_struct *w | |||
353 | return; | 355 | return; |
354 | } | 356 | } |
355 | 357 | ||
356 | if (donator->type == S_HRT) | 358 | if (donator->type == S_HRT) { |
357 | hrt_server = container_of(donator, hrt_server_t, server); | 359 | hrt_server = container_of(donator, hrt_server_t, server); |
360 | } | ||
358 | 361 | ||
359 | /* Donate if the server is waiting for a task release */ | 362 | /* Donate if the server is waiting for a task release */ |
360 | if ((donator->type == S_SRT && | 363 | if ((donator->type == S_SRT && |
@@ -404,17 +407,19 @@ static void check_slack_candidate(struct task_struct *task) | |||
404 | static noinline server_t* next_eligible_slack_server(void) | 407 | static noinline server_t* next_eligible_slack_server(void) |
405 | { | 408 | { |
406 | server_t *next_slack = NULL; | 409 | server_t *next_slack = NULL; |
410 | lt_t now = litmus_clock(); | ||
407 | 411 | ||
408 | while (!list_empty(&slack_queue)) { | 412 | while (!list_empty(&slack_queue)) { |
409 | next_slack = list_entry(slack_queue.next, server_t, list); | 413 | next_slack = list_entry(slack_queue.next, server_t, list); |
410 | BUG_ON(!next_slack); | 414 | BUG_ON(!next_slack); |
411 | 415 | ||
412 | if (lt_after(next_slack->deadline, litmus_clock()) && | 416 | if (lt_after(next_slack->deadline, now) && |
413 | lt_after(next_slack->budget, SLACK_MIN) && | 417 | lt_after(next_slack->budget, SLACK_MIN) && |
414 | !is_server_linked(next_slack)) { | 418 | !is_server_linked(next_slack)) { |
415 | break; | 419 | break; |
416 | } else { | 420 | } else { |
417 | /* Slack has expired or has too little time */ | 421 | /* Slack has expired or has too little time */ |
422 | BUG_ON(next_slack->id == 1001); | ||
418 | remove_slack(next_slack); | 423 | remove_slack(next_slack); |
419 | next_slack = NULL; | 424 | next_slack = NULL; |
420 | } | 425 | } |
@@ -628,8 +633,13 @@ static void requeue_server(server_t *server, lt_t now) | |||
628 | int added = 0; | 633 | int added = 0; |
629 | hrt_server_t *hrt_server; | 634 | hrt_server_t *hrt_server; |
630 | 635 | ||
631 | if (server->type == S_SRT || server->type == S_SLACK) | 636 | if (server->type == S_SRT) |
637 | return; | ||
638 | |||
639 | if (server->type == S_SLACK) { | ||
640 | add_slack(server); | ||
632 | return; | 641 | return; |
642 | } | ||
633 | 643 | ||
634 | if (lt_before(now, server->release)) { | 644 | if (lt_before(now, server->release)) { |
635 | added = add_server_release(server, &server_domain); | 645 | added = add_server_release(server, &server_domain); |
@@ -2206,6 +2216,10 @@ static struct task_struct* edf_hsb_schedule(struct task_struct *prev) | |||
2206 | 2216 | ||
2207 | curr = entry->scheduled; | 2217 | curr = entry->scheduled; |
2208 | 2218 | ||
2219 | if (entry->scheduled && !is_realtime(prev)) { | ||
2220 | TRACE_TASK_SUB(entry->scheduled, "Stack deadlock!"); | ||
2221 | } | ||
2222 | |||
2209 | TRACE("server_budget: %llu, server_deadline: %llu, " | 2223 | TRACE("server_budget: %llu, server_deadline: %llu, " |
2210 | "curr_time: %llu, no_slack: %d, ready: %d\n", | 2224 | "curr_time: %llu, no_slack: %d, ready: %d\n", |
2211 | TIME(entry->hrt_server.server.budget), | 2225 | TIME(entry->hrt_server.server.budget), |
@@ -2268,6 +2282,10 @@ static struct task_struct* edf_hsb_schedule(struct task_struct *prev) | |||
2268 | 2282 | ||
2269 | raw_spin_unlock_irqrestore(global_lock, flags); | 2283 | raw_spin_unlock_irqrestore(global_lock, flags); |
2270 | 2284 | ||
2285 | if (!entry->scheduled && !next_eligible_slack_server()) { | ||
2286 | TRACE_SUB("A slack server has dissapeared!"); | ||
2287 | } | ||
2288 | |||
2271 | return entry->scheduled; | 2289 | return entry->scheduled; |
2272 | } | 2290 | } |
2273 | 2291 | ||
diff --git a/litmus/sched_edf_hsb_noslack.c b/litmus/sched_edf_hsb_noslack.c index e6e8d7dd0e8b..7782f72ed7ea 100644 --- a/litmus/sched_edf_hsb_noslack.c +++ b/litmus/sched_edf_hsb_noslack.c | |||
@@ -262,8 +262,10 @@ static void add_slack(server_t *slack) | |||
262 | 262 | ||
263 | TRACE_SERVER_SUB(slack, "slack added"); | 263 | TRACE_SERVER_SUB(slack, "slack added"); |
264 | 264 | ||
265 | if (head_in_list(&slack->list)) | 265 | if (head_in_list(&slack->list)) { |
266 | TRACE_SERVER_SUB(slack, "already in list"); | ||
266 | return; | 267 | return; |
268 | } | ||
267 | 269 | ||
268 | list_for_each_prev(pos, &slack_queue) { | 270 | list_for_each_prev(pos, &slack_queue) { |
269 | queued = list_entry(pos, server_t, list); | 271 | queued = list_entry(pos, server_t, list); |
@@ -401,17 +403,19 @@ static void check_slack_candidate(struct task_struct *task) | |||
401 | static noinline server_t* next_eligible_slack_server(void) | 403 | static noinline server_t* next_eligible_slack_server(void) |
402 | { | 404 | { |
403 | server_t *next_slack = NULL; | 405 | server_t *next_slack = NULL; |
406 | lt_t now = litmus_clock(); | ||
404 | 407 | ||
405 | while (!list_empty(&slack_queue)) { | 408 | while (!list_empty(&slack_queue)) { |
406 | next_slack = list_entry(slack_queue.next, server_t, list); | 409 | next_slack = list_entry(slack_queue.next, server_t, list); |
407 | BUG_ON(!next_slack); | 410 | BUG_ON(!next_slack); |
408 | 411 | ||
409 | if (lt_after(next_slack->deadline, litmus_clock()) && | 412 | if (lt_after(next_slack->deadline, now) && |
410 | lt_after(next_slack->budget, SLACK_MIN) && | 413 | lt_after(next_slack->budget, SLACK_MIN) && |
411 | !is_server_linked(next_slack)) { | 414 | !is_server_linked(next_slack)) { |
412 | break; | 415 | break; |
413 | } else { | 416 | } else { |
414 | /* Slack has expired or has too little time */ | 417 | /* Slack has expired or has too little time */ |
418 | BUG_ON(next_slack->id == 1001); | ||
415 | remove_slack(next_slack); | 419 | remove_slack(next_slack); |
416 | next_slack = NULL; | 420 | next_slack = NULL; |
417 | } | 421 | } |
@@ -625,8 +629,13 @@ static void requeue_server(server_t *server, lt_t now) | |||
625 | int added = 0; | 629 | int added = 0; |
626 | hrt_server_t *hrt_server; | 630 | hrt_server_t *hrt_server; |
627 | 631 | ||
628 | if (server->type == S_SRT || server->type == S_SLACK) | 632 | if (server->type == S_SRT) |
633 | return; | ||
634 | |||
635 | if (server->type == S_SLACK) { | ||
636 | add_slack(server); | ||
629 | return; | 637 | return; |
638 | } | ||
630 | 639 | ||
631 | if (lt_before(now, server->release)) { | 640 | if (lt_before(now, server->release)) { |
632 | added = add_server_release(server, &server_domain); | 641 | added = add_server_release(server, &server_domain); |
@@ -2203,6 +2212,10 @@ static struct task_struct* edf_hsb_schedule(struct task_struct *prev) | |||
2203 | 2212 | ||
2204 | curr = entry->scheduled; | 2213 | curr = entry->scheduled; |
2205 | 2214 | ||
2215 | if (entry->scheduled && !is_realtime(prev)) { | ||
2216 | TRACE_TASK_SUB(entry->scheduled, "Stack deadlock!"); | ||
2217 | } | ||
2218 | |||
2206 | TRACE("server_budget: %llu, server_deadline: %llu, " | 2219 | TRACE("server_budget: %llu, server_deadline: %llu, " |
2207 | "curr_time: %llu, no_slack: %d, ready: %d\n", | 2220 | "curr_time: %llu, no_slack: %d, ready: %d\n", |
2208 | TIME(entry->hrt_server.server.budget), | 2221 | TIME(entry->hrt_server.server.budget), |
@@ -2265,6 +2278,10 @@ static struct task_struct* edf_hsb_schedule(struct task_struct *prev) | |||
2265 | 2278 | ||
2266 | raw_spin_unlock_irqrestore(global_lock, flags); | 2279 | raw_spin_unlock_irqrestore(global_lock, flags); |
2267 | 2280 | ||
2281 | if (!entry->scheduled && !next_eligible_slack_server()) { | ||
2282 | TRACE_SUB("A slack server has dissapeared!"); | ||
2283 | } | ||
2284 | |||
2268 | return entry->scheduled; | 2285 | return entry->scheduled; |
2269 | } | 2286 | } |
2270 | 2287 | ||