aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/sync.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2013-04-15 20:11:39 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2013-04-15 20:11:39 -0400
commitb7724735827a2e44bfea8863b66eba3d9c4a8d67 (patch)
tree064583fb530da6e6debe350df63b1c01f9d520f6 /litmus/sync.c
parent4770feaf298591fc6751d135ed2ac4f5f7df44f0 (diff)
Cleanup budget tracking in wait_for_release.
Also added logic for real-time tasks to prevent worker threads (klmirqd and aux tasks) from inheriting from tasks waiting for release.
Diffstat (limited to 'litmus/sync.c')
-rw-r--r--litmus/sync.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/litmus/sync.c b/litmus/sync.c
index 749ae62c2b87..dfd9e40ab28d 100644
--- a/litmus/sync.c
+++ b/litmus/sync.c
@@ -15,6 +15,7 @@
15#include <litmus/jobs.h> 15#include <litmus/jobs.h>
16 16
17#include <litmus/sched_trace.h> 17#include <litmus/sched_trace.h>
18#include <litmus/budget.h>
18 19
19struct ts_release_wait { 20struct ts_release_wait {
20 struct list_head list; 21 struct list_head list;
@@ -39,6 +40,13 @@ static long do_wait_for_ts_release(struct timespec *wake)
39 40
40 long ret = -ERESTARTSYS; 41 long ret = -ERESTARTSYS;
41 42
43 struct task_struct *t = current;
44 int is_rt = is_realtime(t);
45
46#if defined(CONFIG_REALTIME_AUX_TASKS) || defined(CONFIG_LITMUS_NVIDIA)
47 DECLARE_WORKER_VIS_FLAGS(vis_flags);
48#endif
49
42 if (mutex_lock_interruptible(&task_release_lock)) 50 if (mutex_lock_interruptible(&task_release_lock))
43 goto out; 51 goto out;
44 52
@@ -46,29 +54,45 @@ static long do_wait_for_ts_release(struct timespec *wake)
46 54
47 mutex_unlock(&task_release_lock); 55 mutex_unlock(&task_release_lock);
48 56
57 if (is_rt) {
58#if defined(CONFIG_REALTIME_AUX_TASKS) || defined(CONFIG_LITMUS_NVIDIA)
59 hide_from_workers(t, &vis_flags);
60#endif
61 bt_flag_set(t, BTF_WAITING_FOR_RELEASE);
62 mb();
63 }
64
49 /* We are enqueued, now we wait for someone to wake us up. */ 65 /* We are enqueued, now we wait for someone to wake us up. */
50 ret = wait_for_completion_interruptible(&wait.completion); 66 ret = wait_for_completion_interruptible(&wait.completion);
51 67
68 if (is_rt) {
69 bt_flag_clear(t, BTF_WAITING_FOR_RELEASE);
70#if defined(CONFIG_REALTIME_AUX_TASKS) || defined(CONFIG_LITMUS_NVIDIA)
71 show_to_workers(t, &vis_flags);
72#endif
73 }
74
52 if (!ret) { 75 if (!ret) {
53 if (is_realtime(current)) { 76 if (is_rt) {
54 lt_t phasedRelease = wait.ts_release_time 77 lt_t phasedRelease = wait.ts_release_time
55 + current->rt_param.task_params.phase; 78 + t->rt_param.task_params.phase;
56 *wake = ns_to_timespec(phasedRelease); 79 *wake = ns_to_timespec(phasedRelease);
57 80
58 /* Setting this flag before releasing ensures that this CPU 81 /* Setting this flag before releasing ensures that this CPU
59 * will be the next CPU to requeue the task on a ready or 82 * will be the next CPU to requeue the task on a ready or
60 * release queue. 83 * release queue.
61 */ 84 */
62 tsk_rt(current)->completed = 1; 85 tsk_rt(t)->completed = 1;
63 tsk_rt(current)->job_params.backlog = 0; 86 tsk_rt(t)->job_params.backlog = 0;
64 bt_flags_reset(current); 87 tsk_rt(t)->job_params.is_backlogged_job = 0;
88 tsk_rt(t)->budget.suspend_timestamp = 0;
89 bt_flag_clear(t, BTF_BUDGET_EXHAUSTED);
65 mb(); 90 mb();
66 91
67 /* completion succeeded, set up release. subtract off 92 /* completion succeeded, set up release. subtract off
68 * period because schedule()->job_completion() will 93 * period because schedule()->job_completion() will
69 * advances us to the correct time */ 94 * advances us to the correct time */
70 litmus->release_at(current, 95 litmus->release_at(t, phasedRelease - t->rt_param.task_params.period);
71 phasedRelease - current->rt_param.task_params.period);
72 schedule(); 96 schedule();
73 } 97 }
74 else { 98 else {