aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2016-03-08 07:07:58 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-03-08 09:26:51 -0500
commit8db6123318df7021c858fb6b19675e1a04b934da (patch)
treeacf5105873817bf1b511e4cf6c1de5a41c00a070
parentb4a0eda68638100b06b4cfc875775568208cd15d (diff)
Don't preempt before time check in sleep_until_next_release()
Avoid preempting jobs that are about to go to sleep soon anyway.
-rw-r--r--include/litmus/jobs.h1
-rw-r--r--litmus/jobs.c8
2 files changed, 6 insertions, 3 deletions
diff --git a/include/litmus/jobs.h b/include/litmus/jobs.h
index 7db931b2b89f..1770e21b97c9 100644
--- a/include/litmus/jobs.h
+++ b/include/litmus/jobs.h
@@ -7,6 +7,5 @@ void release_at(struct task_struct *t, lt_t start);
7long default_wait_for_release_at(lt_t release_time); 7long default_wait_for_release_at(lt_t release_time);
8long complete_job(void); 8long complete_job(void);
9long complete_job_oneshot(void); 9long complete_job_oneshot(void);
10long sleep_until_next_release(void);
11 10
12#endif 11#endif
diff --git a/litmus/jobs.c b/litmus/jobs.c
index 80649d989499..6199423086f8 100644
--- a/litmus/jobs.c
+++ b/litmus/jobs.c
@@ -90,12 +90,15 @@ long complete_job(void)
90 return 0; 90 return 0;
91} 91}
92 92
93static long sleep_until_next_release(void);
93 94
94/* alternative job completion implementation that suspends the task */ 95/* alternative job completion implementation that suspends the task */
95long complete_job_oneshot(void) 96long complete_job_oneshot(void)
96{ 97{
97 struct task_struct *t = current; 98 struct task_struct *t = current;
98 99
100 preempt_disable();
101
99 TRACE_CUR("job completes at %llu (deadline: %llu)\n", litmus_clock(), 102 TRACE_CUR("job completes at %llu (deadline: %llu)\n", litmus_clock(),
100 get_deadline(t)); 103 get_deadline(t));
101 104
@@ -106,13 +109,14 @@ long complete_job_oneshot(void)
106 return sleep_until_next_release(); 109 return sleep_until_next_release();
107} 110}
108 111
109long sleep_until_next_release(void) 112/* assumes caller has disabled preemptions;
113 * re-enables preemptions before returning */
114static long sleep_until_next_release(void)
110{ 115{
111 struct task_struct *t = current; 116 struct task_struct *t = current;
112 ktime_t next_release; 117 ktime_t next_release;
113 long err; 118 long err;
114 119
115 preempt_disable();
116 next_release = ns_to_ktime(get_release(t)); 120 next_release = ns_to_ktime(get_release(t));
117 121
118 TRACE_CUR("next_release=%llu\n", get_release(t)); 122 TRACE_CUR("next_release=%llu\n", get_release(t));