aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2012-03-30 16:49:30 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2012-03-30 17:24:13 -0400
commit4e0ddf86bc72293cd80ffc7995ed968c53671d09 (patch)
tree07b89fcab146246b38f48c75d2f5f319e8647981
parent4562e075e2933a083dac4818654dac01ec9247af (diff)
sched_trace: allow tasks to block on a lock id
Conflicts: litmus/Makefile litmus/sched_gsn_edf.c
-rw-r--r--include/litmus/locking.h1
-rw-r--r--include/litmus/sched_trace.h18
-rw-r--r--include/trace/events/litmus.h67
-rw-r--r--litmus/Makefile5
-rw-r--r--litmus/locking.c6
-rw-r--r--litmus/sched_gsn_edf.c6
-rw-r--r--litmus/sched_litmus.c4
-rw-r--r--litmus/sched_psn_edf.c2
8 files changed, 92 insertions, 17 deletions
diff --git a/include/litmus/locking.h b/include/litmus/locking.h
index 4d7b870cb443..41991d5af01b 100644
--- a/include/litmus/locking.h
+++ b/include/litmus/locking.h
@@ -9,6 +9,7 @@ struct litmus_lock_ops;
9struct litmus_lock { 9struct litmus_lock {
10 struct litmus_lock_ops *ops; 10 struct litmus_lock_ops *ops;
11 int type; 11 int type;
12 int id;
12}; 13};
13 14
14struct litmus_lock_ops { 15struct litmus_lock_ops {
diff --git a/include/litmus/sched_trace.h b/include/litmus/sched_trace.h
index c6897f799867..49972d75ef38 100644
--- a/include/litmus/sched_trace.h
+++ b/include/litmus/sched_trace.h
@@ -233,18 +233,28 @@ feather_callback void do_sched_trace_sys_release(unsigned long id,
233 trace_litmus_task_completion(t, forced); \ 233 trace_litmus_task_completion(t, forced); \
234 } while (0) 234 } while (0)
235 235
236#define sched_trace_task_block(t) \ 236#define sched_trace_task_block(t, i) \
237 do { \ 237 do { \
238 SCHED_TRACE(SCHED_TRACE_BASE_ID + 7, \ 238 SCHED_TRACE(SCHED_TRACE_BASE_ID + 7, \
239 do_sched_trace_task_block, t); \ 239 do_sched_trace_task_block, t); \
240 trace_litmus_task_block(t); \ 240 trace_litmus_task_block(t, i); \
241 } while (0) 241 } while (0)
242 242
243#define sched_trace_task_resume(t) \ 243#define sched_trace_task_resume(t, i) \
244 do { \ 244 do { \
245 SCHED_TRACE(SCHED_TRACE_BASE_ID + 8, \ 245 SCHED_TRACE(SCHED_TRACE_BASE_ID + 8, \
246 do_sched_trace_task_resume, t); \ 246 do_sched_trace_task_resume, t); \
247 trace_litmus_task_resume(t); \ 247 trace_litmus_task_resume(t, i); \
248 } while (0)
249
250#define sched_trace_resource_acquire(t, i) \
251 do { \
252 trace_litmus_resource_acquire(t, i); \
253 } while (0)
254
255#define sched_trace_resource_released(t, i) \
256 do { \
257 trace_litmus_resource_released(t, i); \
248 } while (0) 258 } while (0)
249 259
250#define sched_trace_action(t, action) \ 260#define sched_trace_action(t, action) \
diff --git a/include/trace/events/litmus.h b/include/trace/events/litmus.h
index 4ad053eac27d..b3a8f166e65f 100644
--- a/include/trace/events/litmus.h
+++ b/include/trace/events/litmus.h
@@ -157,21 +157,71 @@ TRACE_EVENT(litmus_task_completion,
157 */ 157 */
158TRACE_EVENT(litmus_task_block, 158TRACE_EVENT(litmus_task_block,
159 159
160 TP_PROTO(struct task_struct *t), 160 TP_PROTO(struct task_struct *t, int lid),
161 161
162 TP_ARGS(t), 162 TP_ARGS(t, lid),
163
164 TP_STRUCT__entry(
165 __field( pid_t, pid )
166 __field( int, lid )
167 __field( unsigned long long, when )
168 ),
169
170 TP_fast_assign(
171 __entry->pid = t ? t->pid : 0;
172 __entry->lid = lid;
173 __entry->when = litmus_clock();
174 ),
175
176 TP_printk("(%u) blocks on %d: %Lu\n", __entry->pid,
177 __entry->lid, __entry->when)
178);
179
180/*
181 * Lock events
182 */
183TRACE_EVENT(litmus_resource_acquire,
184
185 TP_PROTO(struct task_struct *t, int lid),
186
187 TP_ARGS(t, lid),
188
189 TP_STRUCT__entry(
190 __field( pid_t, pid )
191 __field( int, lid )
192 __field( unsigned long long, when )
193 ),
194
195 TP_fast_assign(
196 __entry->pid = t ? t->pid : 0;
197 __entry->lid = lid;
198 __entry->when = litmus_clock();
199 ),
200
201 TP_printk("(%u) acquires %d: %Lu\n", __entry->pid,
202 __entry->lid, __entry->when)
203);
204
205TRACE_EVENT(litmus_resource_release,
206
207 TP_PROTO(struct task_struct *t, int lid),
208
209 TP_ARGS(t, lid),
163 210
164 TP_STRUCT__entry( 211 TP_STRUCT__entry(
165 __field( pid_t, pid ) 212 __field( pid_t, pid )
213 __field( int, lid )
166 __field( unsigned long long, when ) 214 __field( unsigned long long, when )
167 ), 215 ),
168 216
169 TP_fast_assign( 217 TP_fast_assign(
170 __entry->pid = t ? t->pid : 0; 218 __entry->pid = t ? t->pid : 0;
219 __entry->lid = lid;
171 __entry->when = litmus_clock(); 220 __entry->when = litmus_clock();
172 ), 221 ),
173 222
174 TP_printk("(%u) blocks: %Lu\n", __entry->pid, __entry->when) 223 TP_printk("(%u) releases %d: %Lu\n", __entry->pid,
224 __entry->lid, __entry->when)
175); 225);
176 226
177/* 227/*
@@ -179,12 +229,13 @@ TRACE_EVENT(litmus_task_block,
179 */ 229 */
180TRACE_EVENT(litmus_task_resume, 230TRACE_EVENT(litmus_task_resume,
181 231
182 TP_PROTO(struct task_struct *t), 232 TP_PROTO(struct task_struct *t, int lid),
183 233
184 TP_ARGS(t), 234 TP_ARGS(t, lid),
185 235
186 TP_STRUCT__entry( 236 TP_STRUCT__entry(
187 __field( pid_t, pid ) 237 __field( pid_t, pid )
238 __field( int, lid )
188 __field( unsigned int, job ) 239 __field( unsigned int, job )
189 __field( unsigned long long, when ) 240 __field( unsigned long long, when )
190 ), 241 ),
@@ -193,10 +244,12 @@ TRACE_EVENT(litmus_task_resume,
193 __entry->pid = t ? t->pid : 0; 244 __entry->pid = t ? t->pid : 0;
194 __entry->job = t ? t->rt_param.job_params.job_no : 0; 245 __entry->job = t ? t->rt_param.job_params.job_no : 0;
195 __entry->when = litmus_clock(); 246 __entry->when = litmus_clock();
247 __entry->lid = lid;
196 ), 248 ),
197 249
198 TP_printk("resume(job(%u, %u)): %Lu\n", 250 TP_printk("resume(job(%u, %u)) on %d: %Lu\n",
199 __entry->pid, __entry->job, __entry->when) 251 __entry->pid, __entry->job,
252 __entry->lid, __entry->when)
200); 253);
201 254
202/* 255/*
diff --git a/litmus/Makefile b/litmus/Makefile
index 7338180f196f..3487dfe8df05 100644
--- a/litmus/Makefile
+++ b/litmus/Makefile
@@ -16,8 +16,9 @@ obj-y = sched_plugin.o litmus.o \
16 srp.o \ 16 srp.o \
17 bheap.o \ 17 bheap.o \
18 ctrldev.o \ 18 ctrldev.o \
19 sched_gsn_edf.o \ 19 domain.o \
20 sched_psn_edf.o 20 sched_psn_edf.o \
21 sched_gsn_edf.o
21 22
22obj-$(CONFIG_PLUGIN_CEDF) += sched_cedf.o 23obj-$(CONFIG_PLUGIN_CEDF) += sched_cedf.o
23obj-$(CONFIG_PLUGIN_PFAIR) += sched_pfair.o 24obj-$(CONFIG_PLUGIN_PFAIR) += sched_pfair.o
diff --git a/litmus/locking.c b/litmus/locking.c
index 0c1aa6aa40b7..447b8aaee8dc 100644
--- a/litmus/locking.c
+++ b/litmus/locking.c
@@ -28,14 +28,18 @@ static inline struct litmus_lock* get_lock(struct od_table_entry* entry)
28 return (struct litmus_lock*) entry->obj->obj; 28 return (struct litmus_lock*) entry->obj->obj;
29} 29}
30 30
31atomic_t lock_id = ATOMIC_INIT(0);
32
31static int create_generic_lock(void** obj_ref, obj_type_t type, void* __user arg) 33static int create_generic_lock(void** obj_ref, obj_type_t type, void* __user arg)
32{ 34{
33 struct litmus_lock* lock; 35 struct litmus_lock* lock;
34 int err; 36 int err;
35 37
36 err = litmus->allocate_lock(&lock, type, arg); 38 err = litmus->allocate_lock(&lock, type, arg);
37 if (err == 0) 39 if (err == 0) {
40 lock->id = atomic_add_return(1, &lock_id);
38 *obj_ref = lock; 41 *obj_ref = lock;
42 }
39 return err; 43 return err;
40} 44}
41 45
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c
index 6ed504f4750e..f50b58c37b31 100644
--- a/litmus/sched_gsn_edf.c
+++ b/litmus/sched_gsn_edf.c
@@ -805,6 +805,8 @@ int gsnedf_fmlp_lock(struct litmus_lock* l)
805 /* release lock before sleeping */ 805 /* release lock before sleeping */
806 spin_unlock_irqrestore(&sem->wait.lock, flags); 806 spin_unlock_irqrestore(&sem->wait.lock, flags);
807 807
808 sched_trace_task_block(t, l->id);
809
808 /* We depend on the FIFO order. Thus, we don't need to recheck 810 /* We depend on the FIFO order. Thus, we don't need to recheck
809 * when we wake up; we are guaranteed to have the lock since 811 * when we wake up; we are guaranteed to have the lock since
810 * there is only one wake up per release. 812 * there is only one wake up per release.
@@ -812,7 +814,11 @@ int gsnedf_fmlp_lock(struct litmus_lock* l)
812 814
813 schedule(); 815 schedule();
814 816
817<<<<<<< HEAD
815 TS_LOCK_RESUME; 818 TS_LOCK_RESUME;
819=======
820 sched_trace_task_resume(t, l->id);
821>>>>>>> d47039b... sched_trace: allow tasks to block on a lock id
816 822
817 /* Since we hold the lock, no other task will change 823 /* Since we hold the lock, no other task will change
818 * ->owner. We can thus check it without acquiring the spin 824 * ->owner. We can thus check it without acquiring the spin
diff --git a/litmus/sched_litmus.c b/litmus/sched_litmus.c
index 5a15ce938984..659dc13d3fa9 100644
--- a/litmus/sched_litmus.c
+++ b/litmus/sched_litmus.c
@@ -160,7 +160,7 @@ static void enqueue_task_litmus(struct rq *rq, struct task_struct *p,
160 int flags) 160 int flags)
161{ 161{
162 if (flags & ENQUEUE_WAKEUP) { 162 if (flags & ENQUEUE_WAKEUP) {
163 sched_trace_task_resume(p); 163 sched_trace_task_resume(p, 0);
164 tsk_rt(p)->present = 1; 164 tsk_rt(p)->present = 1;
165 /* LITMUS^RT plugins need to update the state 165 /* LITMUS^RT plugins need to update the state
166 * _before_ making it available in global structures. 166 * _before_ making it available in global structures.
@@ -185,7 +185,7 @@ static void dequeue_task_litmus(struct rq *rq, struct task_struct *p,
185 if (flags & DEQUEUE_SLEEP) { 185 if (flags & DEQUEUE_SLEEP) {
186 litmus->task_block(p); 186 litmus->task_block(p);
187 tsk_rt(p)->present = 0; 187 tsk_rt(p)->present = 0;
188 sched_trace_task_block(p); 188 sched_trace_task_block(p, 0);
189 189
190 rq->litmus.nr_running--; 190 rq->litmus.nr_running--;
191 } else 191 } else
diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c
index a4ffb9bb9970..eaaec38f43da 100644
--- a/litmus/sched_psn_edf.c
+++ b/litmus/sched_psn_edf.c
@@ -284,7 +284,7 @@ static void psnedf_task_new(struct task_struct * t, int on_rq, int running)
284 TRACE_TASK(t, "psn edf: task new, cpu = %d\n", 284 TRACE_TASK(t, "psn edf: task new, cpu = %d\n",
285 t->rt_param.task_params.cpu); 285 t->rt_param.task_params.cpu);
286 286
287 trace_litmus_server_param(0 - t->pid, -1 - get_partition(task), 287 trace_litmus_server_param(0 - t->pid, -1 - get_partition(t),
288 get_exec_time(t), get_rt_period(t)); 288 get_exec_time(t), get_rt_period(t));
289 289
290 /* setup job parameters */ 290 /* setup job parameters */