diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-10-09 02:57:51 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-10-09 02:57:51 -0400 |
commit | a744599d42a19e0b74c95a77abec6ee79f869b0f (patch) | |
tree | b181c4376f8f840272ab05fec0604f4b8a1d9508 /litmus | |
parent | b26432a616a3aaad55ea404cd88d37fd1e345af1 (diff) |
Integrated color chunking into the mc plugin.
Diffstat (limited to 'litmus')
-rw-r--r-- | litmus/jobs.c | 36 | ||||
-rw-r--r-- | litmus/sched_mc.c | 38 |
2 files changed, 59 insertions, 15 deletions
diff --git a/litmus/jobs.c b/litmus/jobs.c index fa55283e2134..d5556f547f6f 100644 --- a/litmus/jobs.c +++ b/litmus/jobs.c | |||
@@ -12,6 +12,10 @@ | |||
12 | #include <litmus/event_group.h> | 12 | #include <litmus/event_group.h> |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | #ifdef CONFIG_PLUGIN_COLOR | ||
16 | #include <litmus/color.h> | ||
17 | #endif | ||
18 | |||
15 | #ifdef CONFIG_PLUGIN_MC | 19 | #ifdef CONFIG_PLUGIN_MC |
16 | #include <litmus/sched_mc.h> | 20 | #include <litmus/sched_mc.h> |
17 | #else | 21 | #else |
@@ -32,15 +36,18 @@ static inline void setup_release(struct task_struct *t, struct rt_job *job, | |||
32 | 36 | ||
33 | static inline void setup_kernel_release(struct task_struct *t, lt_t release) | 37 | static inline void setup_kernel_release(struct task_struct *t, lt_t release) |
34 | { | 38 | { |
35 | lt_t now = litmus_clock(); | ||
36 | |||
37 | BUG_ON(!t); | 39 | BUG_ON(!t); |
38 | 40 | ||
41 | #ifdef CONFIG_PLUGIN_COLOR | ||
42 | if (tsk_rt(t)->orig_cost) | ||
43 | get_exec_cost(t) = color_chunk; | ||
44 | #endif | ||
45 | |||
39 | /* Record lateness before we set up the next job's | 46 | /* Record lateness before we set up the next job's |
40 | * release and deadline. Lateness may be negative. | 47 | * release and deadline. Lateness may be negative. |
41 | */ | 48 | */ |
42 | t->rt_param.job_params.lateness = | 49 | t->rt_param.job_params.lateness = |
43 | (long long)now - | 50 | (long long)litmus_clock() - |
44 | (long long)t->rt_param.job_params.deadline; | 51 | (long long)t->rt_param.job_params.deadline; |
45 | 52 | ||
46 | t->rt.time_slice = 1; | 53 | t->rt.time_slice = 1; |
@@ -66,6 +73,29 @@ void setup_user_release(struct task_struct *t, lt_t release) | |||
66 | 73 | ||
67 | void prepare_for_next_period(struct task_struct *t) | 74 | void prepare_for_next_period(struct task_struct *t) |
68 | { | 75 | { |
76 | lt_t rem, exec, orig; | ||
77 | |||
78 | #ifdef CONFIG_PLUGIN_COLOR | ||
79 | if (tsk_rt(t)->orig_cost) { | ||
80 | /* Task is chunked */ | ||
81 | tsk_rt(t)->last_exec_time += get_exec_time(t); | ||
82 | |||
83 | exec = tsk_rt(t)->last_exec_time; | ||
84 | orig = tsk_rt(t)->orig_cost; | ||
85 | rem = orig - exec; | ||
86 | |||
87 | if (lt_before(exec, orig)) { | ||
88 | /* Don't increment period if there is user-space work to | ||
89 | * perform and we haven't exhausted our original budget | ||
90 | */ | ||
91 | get_exec_time(t) = 0; | ||
92 | /* The last chunk is a remainder */ | ||
93 | if (rem < get_exec_cost(t)) | ||
94 | get_exec_cost(t) = rem; | ||
95 | return; | ||
96 | } | ||
97 | } | ||
98 | #endif | ||
69 | setup_kernel_release(t, get_release(t) + get_rt_period(t)); | 99 | setup_kernel_release(t, get_release(t) + get_rt_period(t)); |
70 | } | 100 | } |
71 | 101 | ||
diff --git a/litmus/sched_mc.c b/litmus/sched_mc.c index b34ec4ee9e59..76479fd08d3a 100644 --- a/litmus/sched_mc.c +++ b/litmus/sched_mc.c | |||
@@ -336,7 +336,7 @@ static void link_task_to_crit(struct crit_entry *ce, | |||
336 | /* Block if task cannot acquire resources */ | 336 | /* Block if task cannot acquire resources */ |
337 | task->rt_param.linked_on = crit_cpu(ce)->cpu; | 337 | task->rt_param.linked_on = crit_cpu(ce)->cpu; |
338 | 338 | ||
339 | if (is_ghost(task) || ce->domain->acquire_resources(task)) | 339 | if (ce->domain->acquire_resources(task)) |
340 | start_crit(ce); | 340 | start_crit(ce); |
341 | else | 341 | else |
342 | ce->state = CS_BLOCKED; | 342 | ce->state = CS_BLOCKED; |
@@ -684,7 +684,6 @@ static void job_completion(struct task_struct *task, int forced) | |||
684 | 684 | ||
685 | /* Logically stop the task execution */ | 685 | /* Logically stop the task execution */ |
686 | set_rt_flags(task, RT_F_SLEEP); | 686 | set_rt_flags(task, RT_F_SLEEP); |
687 | remove_from_all(task); | ||
688 | 687 | ||
689 | if (!forced) { | 688 | if (!forced) { |
690 | /* Userspace signaled job completion */ | 689 | /* Userspace signaled job completion */ |
@@ -716,9 +715,16 @@ static void job_completion(struct task_struct *task, int forced) | |||
716 | set_rt_flags(task, RT_F_RUNNING); | 715 | set_rt_flags(task, RT_F_RUNNING); |
717 | } | 716 | } |
718 | 717 | ||
719 | /* Requeue non-blocking tasks */ | 718 | /* If the server was not released, then the task's priority remains |
720 | if (is_running(task)) | 719 | * unchanged and it should be left where it is |
721 | job_arrival(task); | 720 | */ |
721 | if (release_server) { | ||
722 | remove_from_all(task); | ||
723 | if (is_running(task)) { | ||
724 | /* Requeue non-blocking tasks */ | ||
725 | job_arrival(task); | ||
726 | } | ||
727 | } | ||
722 | } | 728 | } |
723 | 729 | ||
724 | /** | 730 | /** |
@@ -885,6 +891,21 @@ static void mc_task_new(struct task_struct *t, int on_rq, int running) | |||
885 | entry = &per_cpu(cpus, task_cpu(t)); | 891 | entry = &per_cpu(cpus, task_cpu(t)); |
886 | t->rt_param._domain = entry->crit_entries[level].domain; | 892 | t->rt_param._domain = entry->crit_entries[level].domain; |
887 | 893 | ||
894 | /* Userspace and kernelspace view of task state may differ. | ||
895 | * Model kernel state as an additional container | ||
896 | */ | ||
897 | sched_trace_container_param(t->pid, t->comm); | ||
898 | sched_trace_server_param(-t->pid, t->pid, | ||
899 | get_exec_cost(t), get_rt_period(t)); | ||
900 | |||
901 | /* Apply chunking */ | ||
902 | if (level == CRIT_LEVEL_B) { | ||
903 | tsk_rt(t)->task_params.budget_policy = PRECISE_ENFORCEMENT; | ||
904 | if (color_chunk && level == CRIT_LEVEL_B && | ||
905 | lt_after(get_exec_cost(t), color_chunk)) | ||
906 | tsk_rt(t)->orig_cost = get_exec_cost(t); | ||
907 | } | ||
908 | |||
888 | /* Setup color request */ | 909 | /* Setup color request */ |
889 | req = kmalloc(sizeof(*req), GFP_ATOMIC); | 910 | req = kmalloc(sizeof(*req), GFP_ATOMIC); |
890 | req->task = t; | 911 | req->task = t; |
@@ -897,13 +918,6 @@ static void mc_task_new(struct task_struct *t, int on_rq, int running) | |||
897 | set_req(&group_lock, req, ccp->colors[i], ccp->pages[i]); | 918 | set_req(&group_lock, req, ccp->colors[i], ccp->pages[i]); |
898 | } | 919 | } |
899 | 920 | ||
900 | /* Userspace and kernelspace view of task state may differ. | ||
901 | * Model kernel state as an additional container | ||
902 | */ | ||
903 | sched_trace_container_param(t->pid, t->comm); | ||
904 | sched_trace_server_param(-t->pid, t->pid, | ||
905 | get_exec_cost(t), get_rt_period(t)); | ||
906 | |||
907 | /* Setup job params */ | 921 | /* Setup job params */ |
908 | release_at(t, litmus_clock()); | 922 | release_at(t, litmus_clock()); |
909 | if (running) { | 923 | if (running) { |