diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2013-01-10 16:21:07 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2013-01-10 16:21:07 -0500 |
commit | 8d00682ce5ddaedfb62287773d21c727f08fda69 (patch) | |
tree | 61a4b7bac5960c6f0ab25fe087404e9ca1725e05 /litmus/sched_task_trace.c | |
parent | fdf0a6b73001976c5d02d631ebdd0927819d7c91 (diff) | |
parent | 1235a665a5e00dc762e6646c01381b3ed5019d86 (diff) |
Merge branch 'wip-gpu-cleanup' into wip-2012.3-gpu
Conflicts:
include/litmus/fpmath.h
include/litmus/litmus.h
include/litmus/rt_param.h
include/litmus/trace.h
kernel/sched.c
kernel/softirq.c
litmus/edf_common.c
litmus/jobs.c
litmus/litmus.c
litmus/locking.c
litmus/preempt.c
litmus/sched_cedf.c
litmus/sched_gsn_edf.c
litmus/sched_litmus.c
litmus/sync.c
Diffstat (limited to 'litmus/sched_task_trace.c')
-rw-r--r-- | litmus/sched_task_trace.c | 282 |
1 files changed, 275 insertions, 7 deletions
diff --git a/litmus/sched_task_trace.c b/litmus/sched_task_trace.c index 5ef8d09ab41f..f7f575346b54 100644 --- a/litmus/sched_task_trace.c +++ b/litmus/sched_task_trace.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/sched.h> | 8 | #include <linux/sched.h> |
9 | #include <linux/percpu.h> | 9 | #include <linux/percpu.h> |
10 | #include <linux/hardirq.h> | ||
10 | 11 | ||
11 | #include <litmus/ftdev.h> | 12 | #include <litmus/ftdev.h> |
12 | #include <litmus/litmus.h> | 13 | #include <litmus/litmus.h> |
@@ -16,13 +17,13 @@ | |||
16 | #include <litmus/ftdev.h> | 17 | #include <litmus/ftdev.h> |
17 | 18 | ||
18 | 19 | ||
19 | #define NO_EVENTS (1 << CONFIG_SCHED_TASK_TRACE_SHIFT) | 20 | #define NUM_EVENTS (1 << (CONFIG_SCHED_TASK_TRACE_SHIFT+11)) |
20 | 21 | ||
21 | #define now() litmus_clock() | 22 | #define now() litmus_clock() |
22 | 23 | ||
23 | struct local_buffer { | 24 | struct local_buffer { |
24 | struct st_event_record record[NO_EVENTS]; | 25 | struct st_event_record record[NUM_EVENTS]; |
25 | char flag[NO_EVENTS]; | 26 | char flag[NUM_EVENTS]; |
26 | struct ft_buffer ftbuf; | 27 | struct ft_buffer ftbuf; |
27 | }; | 28 | }; |
28 | 29 | ||
@@ -41,7 +42,7 @@ static int __init init_sched_task_trace(void) | |||
41 | int i, ok = 0, err; | 42 | int i, ok = 0, err; |
42 | printk("Allocated %u sched_trace_xxx() events per CPU " | 43 | printk("Allocated %u sched_trace_xxx() events per CPU " |
43 | "(buffer size: %d bytes)\n", | 44 | "(buffer size: %d bytes)\n", |
44 | NO_EVENTS, (int) sizeof(struct local_buffer)); | 45 | NUM_EVENTS, (int) sizeof(struct local_buffer)); |
45 | 46 | ||
46 | err = ftdev_init(&st_dev, THIS_MODULE, | 47 | err = ftdev_init(&st_dev, THIS_MODULE, |
47 | num_online_cpus(), "sched_trace"); | 48 | num_online_cpus(), "sched_trace"); |
@@ -50,7 +51,7 @@ static int __init init_sched_task_trace(void) | |||
50 | 51 | ||
51 | for (i = 0; i < st_dev.minor_cnt; i++) { | 52 | for (i = 0; i < st_dev.minor_cnt; i++) { |
52 | buf = &per_cpu(st_event_buffer, i); | 53 | buf = &per_cpu(st_event_buffer, i); |
53 | ok += init_ft_buffer(&buf->ftbuf, NO_EVENTS, | 54 | ok += init_ft_buffer(&buf->ftbuf, NUM_EVENTS, |
54 | sizeof(struct st_event_record), | 55 | sizeof(struct st_event_record), |
55 | buf->flag, | 56 | buf->flag, |
56 | buf->record); | 57 | buf->record); |
@@ -154,7 +155,8 @@ feather_callback void do_sched_trace_task_switch_to(unsigned long id, | |||
154 | { | 155 | { |
155 | struct task_struct *t = (struct task_struct*) _task; | 156 | struct task_struct *t = (struct task_struct*) _task; |
156 | struct st_event_record* rec; | 157 | struct st_event_record* rec; |
157 | if (is_realtime(t)) { | 158 | //if (is_realtime(t)) /* comment out to trace EVERYTHING */ |
159 | { | ||
158 | rec = get_record(ST_SWITCH_TO, t); | 160 | rec = get_record(ST_SWITCH_TO, t); |
159 | if (rec) { | 161 | if (rec) { |
160 | rec->data.switch_to.when = now(); | 162 | rec->data.switch_to.when = now(); |
@@ -169,7 +171,8 @@ feather_callback void do_sched_trace_task_switch_away(unsigned long id, | |||
169 | { | 171 | { |
170 | struct task_struct *t = (struct task_struct*) _task; | 172 | struct task_struct *t = (struct task_struct*) _task; |
171 | struct st_event_record* rec; | 173 | struct st_event_record* rec; |
172 | if (is_realtime(t)) { | 174 | //if (is_realtime(t)) /* comment out to trace EVERYTHING */ |
175 | { | ||
173 | rec = get_record(ST_SWITCH_AWAY, t); | 176 | rec = get_record(ST_SWITCH_AWAY, t); |
174 | if (rec) { | 177 | if (rec) { |
175 | rec->data.switch_away.when = now(); | 178 | rec->data.switch_away.when = now(); |
@@ -188,6 +191,9 @@ feather_callback void do_sched_trace_task_completion(unsigned long id, | |||
188 | if (rec) { | 191 | if (rec) { |
189 | rec->data.completion.when = now(); | 192 | rec->data.completion.when = now(); |
190 | rec->data.completion.forced = forced; | 193 | rec->data.completion.forced = forced; |
194 | #ifdef LITMUS_NVIDIA | ||
195 | rec->data.completion.nv_int_count = (u16)atomic_read(&tsk_rt(t)->nv_int_count); | ||
196 | #endif | ||
191 | put_record(rec); | 197 | put_record(rec); |
192 | } | 198 | } |
193 | } | 199 | } |
@@ -239,3 +245,265 @@ feather_callback void do_sched_trace_action(unsigned long id, | |||
239 | put_record(rec); | 245 | put_record(rec); |
240 | } | 246 | } |
241 | } | 247 | } |
248 | |||
249 | |||
250 | |||
251 | |||
252 | feather_callback void do_sched_trace_prediction_err(unsigned long id, | ||
253 | unsigned long _task, | ||
254 | unsigned long _distance, | ||
255 | unsigned long _rel_err) | ||
256 | { | ||
257 | struct task_struct *t = (struct task_struct*) _task; | ||
258 | struct st_event_record *rec = get_record(ST_PREDICTION_ERR, t); | ||
259 | |||
260 | if (rec) { | ||
261 | gpu_migration_dist_t* distance = (gpu_migration_dist_t*) _distance; | ||
262 | fp_t* rel_err = (fp_t*) _rel_err; | ||
263 | |||
264 | rec->data.prediction_err.distance = *distance; | ||
265 | rec->data.prediction_err.rel_err = rel_err->val; | ||
266 | put_record(rec); | ||
267 | } | ||
268 | } | ||
269 | |||
270 | |||
271 | feather_callback void do_sched_trace_migration(unsigned long id, | ||
272 | unsigned long _task, | ||
273 | unsigned long _mig_info) | ||
274 | { | ||
275 | struct task_struct *t = (struct task_struct*) _task; | ||
276 | struct st_event_record *rec = get_record(ST_MIGRATION, t); | ||
277 | |||
278 | if (rec) { | ||
279 | struct migration_info* mig_info = (struct migration_info*) _mig_info; | ||
280 | |||
281 | rec->hdr.extra = mig_info->distance; | ||
282 | rec->data.migration.observed = mig_info->observed; | ||
283 | rec->data.migration.estimated = mig_info->estimated; | ||
284 | |||
285 | put_record(rec); | ||
286 | } | ||
287 | } | ||
288 | |||
289 | |||
290 | |||
291 | |||
292 | |||
293 | |||
294 | |||
295 | |||
296 | |||
297 | feather_callback void do_sched_trace_tasklet_release(unsigned long id, | ||
298 | unsigned long _owner) | ||
299 | { | ||
300 | struct task_struct *t = (struct task_struct*) _owner; | ||
301 | struct st_event_record *rec = get_record(ST_TASKLET_RELEASE, t); | ||
302 | |||
303 | if (rec) { | ||
304 | rec->data.tasklet_release.when = now(); | ||
305 | put_record(rec); | ||
306 | } | ||
307 | } | ||
308 | |||
309 | |||
310 | feather_callback void do_sched_trace_tasklet_begin(unsigned long id, | ||
311 | unsigned long _owner) | ||
312 | { | ||
313 | struct task_struct *t = (struct task_struct*) _owner; | ||
314 | struct st_event_record *rec = get_record(ST_TASKLET_BEGIN, t); | ||
315 | |||
316 | if (rec) { | ||
317 | rec->data.tasklet_begin.when = now(); | ||
318 | |||
319 | if(!in_interrupt()) | ||
320 | rec->data.tasklet_begin.exe_pid = current->pid; | ||
321 | else | ||
322 | rec->data.tasklet_begin.exe_pid = 0; | ||
323 | |||
324 | put_record(rec); | ||
325 | } | ||
326 | } | ||
327 | EXPORT_SYMBOL(do_sched_trace_tasklet_begin); | ||
328 | |||
329 | |||
330 | feather_callback void do_sched_trace_tasklet_end(unsigned long id, | ||
331 | unsigned long _owner, | ||
332 | unsigned long _flushed) | ||
333 | { | ||
334 | struct task_struct *t = (struct task_struct*) _owner; | ||
335 | struct st_event_record *rec = get_record(ST_TASKLET_END, t); | ||
336 | |||
337 | if (rec) { | ||
338 | rec->data.tasklet_end.when = now(); | ||
339 | rec->data.tasklet_end.flushed = _flushed; | ||
340 | |||
341 | if(!in_interrupt()) | ||
342 | rec->data.tasklet_end.exe_pid = current->pid; | ||
343 | else | ||
344 | rec->data.tasklet_end.exe_pid = 0; | ||
345 | |||
346 | put_record(rec); | ||
347 | } | ||
348 | } | ||
349 | EXPORT_SYMBOL(do_sched_trace_tasklet_end); | ||
350 | |||
351 | |||
352 | feather_callback void do_sched_trace_work_release(unsigned long id, | ||
353 | unsigned long _owner) | ||
354 | { | ||
355 | struct task_struct *t = (struct task_struct*) _owner; | ||
356 | struct st_event_record *rec = get_record(ST_WORK_RELEASE, t); | ||
357 | |||
358 | if (rec) { | ||
359 | rec->data.work_release.when = now(); | ||
360 | put_record(rec); | ||
361 | } | ||
362 | } | ||
363 | |||
364 | |||
365 | feather_callback void do_sched_trace_work_begin(unsigned long id, | ||
366 | unsigned long _owner, | ||
367 | unsigned long _exe) | ||
368 | { | ||
369 | struct task_struct *t = (struct task_struct*) _owner; | ||
370 | struct st_event_record *rec = get_record(ST_WORK_BEGIN, t); | ||
371 | |||
372 | if (rec) { | ||
373 | struct task_struct *exe = (struct task_struct*) _exe; | ||
374 | rec->data.work_begin.exe_pid = exe->pid; | ||
375 | rec->data.work_begin.when = now(); | ||
376 | put_record(rec); | ||
377 | } | ||
378 | } | ||
379 | EXPORT_SYMBOL(do_sched_trace_work_begin); | ||
380 | |||
381 | |||
382 | feather_callback void do_sched_trace_work_end(unsigned long id, | ||
383 | unsigned long _owner, | ||
384 | unsigned long _exe, | ||
385 | unsigned long _flushed) | ||
386 | { | ||
387 | struct task_struct *t = (struct task_struct*) _owner; | ||
388 | struct st_event_record *rec = get_record(ST_WORK_END, t); | ||
389 | |||
390 | if (rec) { | ||
391 | struct task_struct *exe = (struct task_struct*) _exe; | ||
392 | rec->data.work_end.exe_pid = exe->pid; | ||
393 | rec->data.work_end.flushed = _flushed; | ||
394 | rec->data.work_end.when = now(); | ||
395 | put_record(rec); | ||
396 | } | ||
397 | } | ||
398 | EXPORT_SYMBOL(do_sched_trace_work_end); | ||
399 | |||
400 | |||
401 | feather_callback void do_sched_trace_eff_prio_change(unsigned long id, | ||
402 | unsigned long _task, | ||
403 | unsigned long _inh) | ||
404 | { | ||
405 | struct task_struct *t = (struct task_struct*) _task; | ||
406 | struct st_event_record *rec = get_record(ST_EFF_PRIO_CHANGE, t); | ||
407 | |||
408 | if (rec) { | ||
409 | struct task_struct *inh = (struct task_struct*) _inh; | ||
410 | rec->data.effective_priority_change.when = now(); | ||
411 | rec->data.effective_priority_change.inh_pid = (inh != NULL) ? | ||
412 | inh->pid : | ||
413 | 0xffff; | ||
414 | |||
415 | put_record(rec); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | /* pray for no nesting of nv interrupts on same CPU... */ | ||
420 | struct tracing_interrupt_map | ||
421 | { | ||
422 | int active; | ||
423 | int count; | ||
424 | unsigned long data[128]; // assume nesting less than 128... | ||
425 | unsigned long serial[128]; | ||
426 | }; | ||
427 | DEFINE_PER_CPU(struct tracing_interrupt_map, active_interrupt_tracing); | ||
428 | |||
429 | |||
430 | DEFINE_PER_CPU(u32, intCounter); | ||
431 | |||
432 | feather_callback void do_sched_trace_nv_interrupt_begin(unsigned long id, | ||
433 | unsigned long _device) | ||
434 | { | ||
435 | struct st_event_record *rec; | ||
436 | u32 serialNum; | ||
437 | |||
438 | { | ||
439 | u32* serial; | ||
440 | struct tracing_interrupt_map* int_map = &per_cpu(active_interrupt_tracing, smp_processor_id()); | ||
441 | if(!int_map->active == 0xcafebabe) | ||
442 | { | ||
443 | int_map->count++; | ||
444 | } | ||
445 | else | ||
446 | { | ||
447 | int_map->active = 0xcafebabe; | ||
448 | int_map->count = 1; | ||
449 | } | ||
450 | //int_map->data[int_map->count-1] = _device; | ||
451 | |||
452 | serial = &per_cpu(intCounter, smp_processor_id()); | ||
453 | *serial += num_online_cpus(); | ||
454 | serialNum = *serial; | ||
455 | int_map->serial[int_map->count-1] = serialNum; | ||
456 | } | ||
457 | |||
458 | rec = get_record(ST_NV_INTERRUPT_BEGIN, NULL); | ||
459 | if(rec) { | ||
460 | u32 device = _device; | ||
461 | rec->data.nv_interrupt_begin.when = now(); | ||
462 | rec->data.nv_interrupt_begin.device = device; | ||
463 | rec->data.nv_interrupt_begin.serialNumber = serialNum; | ||
464 | put_record(rec); | ||
465 | } | ||
466 | } | ||
467 | EXPORT_SYMBOL(do_sched_trace_nv_interrupt_begin); | ||
468 | |||
469 | /* | ||
470 | int is_interrupt_tracing_active(void) | ||
471 | { | ||
472 | struct tracing_interrupt_map* int_map = &per_cpu(active_interrupt_tracing, smp_processor_id()); | ||
473 | if(int_map->active == 0xcafebabe) | ||
474 | return 1; | ||
475 | return 0; | ||
476 | } | ||
477 | */ | ||
478 | |||
479 | feather_callback void do_sched_trace_nv_interrupt_end(unsigned long id, unsigned long _device) | ||
480 | { | ||
481 | struct tracing_interrupt_map* int_map = &per_cpu(active_interrupt_tracing, smp_processor_id()); | ||
482 | if(int_map->active == 0xcafebabe) | ||
483 | { | ||
484 | struct st_event_record *rec = get_record(ST_NV_INTERRUPT_END, NULL); | ||
485 | |||
486 | int_map->count--; | ||
487 | if(int_map->count == 0) | ||
488 | int_map->active = 0; | ||
489 | |||
490 | if(rec) { | ||
491 | u32 device = _device; | ||
492 | rec->data.nv_interrupt_end.when = now(); | ||
493 | //rec->data.nv_interrupt_end.device = int_map->data[int_map->count]; | ||
494 | rec->data.nv_interrupt_end.device = device; | ||
495 | rec->data.nv_interrupt_end.serialNumber = int_map->serial[int_map->count]; | ||
496 | put_record(rec); | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | EXPORT_SYMBOL(do_sched_trace_nv_interrupt_end); | ||
501 | |||
502 | |||
503 | |||
504 | |||
505 | |||
506 | |||
507 | |||
508 | |||
509 | |||