diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-09-11 06:12:54 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-13 04:22:39 -0400 |
commit | ad236fd23b6d6372dcacd549983cce051d2ccff6 (patch) | |
tree | 576d766c199a6416a2029ab14d7e20028f63a295 /tools/perf/builtin-sched.c | |
parent | fbf9482911825f965829567aea8acff3bbc5279c (diff) |
perf sched: Tighten up the code
Various small cleanups - removal of debug printks and dead
functions, etc.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r-- | tools/perf/builtin-sched.c | 236 |
1 files changed, 47 insertions, 189 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 6ec4f51d536b..de93a2604528 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -61,29 +61,6 @@ static u64 sample_type; | |||
61 | 61 | ||
62 | typedef unsigned long long nsec_t; | 62 | typedef unsigned long long nsec_t; |
63 | 63 | ||
64 | #define printk(x...) do { printf(x); fflush(stdout); } while (0) | ||
65 | |||
66 | nsec_t prev_printk; | ||
67 | |||
68 | #define __dprintk(x,y...) do { \ | ||
69 | nsec_t __now = get_nsecs(), __delta = __now - prev_printk; \ | ||
70 | \ | ||
71 | prev_printk = __now; \ | ||
72 | \ | ||
73 | printf("%.3f [%Ld] [%.3f]: " x, (double)__now/1e6, __now, (double)__delta/1e6, y);\ | ||
74 | } while (0) | ||
75 | |||
76 | #if !DEBUG | ||
77 | # define dprintk(x...) do { } while (0) | ||
78 | #else | ||
79 | # define dprintk(x...) __dprintk(x) | ||
80 | #endif | ||
81 | |||
82 | #define __DP() __dprintk("parent: line %d\n", __LINE__) | ||
83 | #define DP() dprintk("parent: line %d\n", __LINE__) | ||
84 | #define D() dprintk("task %ld: line %d\n", this_task->nr, __LINE__) | ||
85 | |||
86 | |||
87 | static nsec_t run_measurement_overhead; | 64 | static nsec_t run_measurement_overhead; |
88 | static nsec_t sleep_measurement_overhead; | 65 | static nsec_t sleep_measurement_overhead; |
89 | 66 | ||
@@ -129,7 +106,7 @@ static void calibrate_run_measurement_overhead(void) | |||
129 | } | 106 | } |
130 | run_measurement_overhead = min_delta; | 107 | run_measurement_overhead = min_delta; |
131 | 108 | ||
132 | printk("run measurement overhead: %Ld nsecs\n", min_delta); | 109 | printf("run measurement overhead: %Ld nsecs\n", min_delta); |
133 | } | 110 | } |
134 | 111 | ||
135 | static void calibrate_sleep_measurement_overhead(void) | 112 | static void calibrate_sleep_measurement_overhead(void) |
@@ -147,7 +124,7 @@ static void calibrate_sleep_measurement_overhead(void) | |||
147 | min_delta -= 10000; | 124 | min_delta -= 10000; |
148 | sleep_measurement_overhead = min_delta; | 125 | sleep_measurement_overhead = min_delta; |
149 | 126 | ||
150 | printk("sleep measurement overhead: %Ld nsecs\n", min_delta); | 127 | printf("sleep measurement overhead: %Ld nsecs\n", min_delta); |
151 | } | 128 | } |
152 | 129 | ||
153 | #define COMM_LEN 20 | 130 | #define COMM_LEN 20 |
@@ -293,7 +270,7 @@ add_sched_event_wakeup(struct task_desc *task, nsec_t timestamp, | |||
293 | 270 | ||
294 | static void | 271 | static void |
295 | add_sched_event_sleep(struct task_desc *task, nsec_t timestamp, | 272 | add_sched_event_sleep(struct task_desc *task, nsec_t timestamp, |
296 | unsigned long uninterruptible __used) | 273 | u64 task_state __used) |
297 | { | 274 | { |
298 | struct sched_event *event = get_new_event(task, timestamp); | 275 | struct sched_event *event = get_new_event(task, timestamp); |
299 | 276 | ||
@@ -329,77 +306,13 @@ static struct task_desc *register_pid(unsigned long pid, const char *comm) | |||
329 | BUG_ON(!tasks); | 306 | BUG_ON(!tasks); |
330 | tasks[task->nr] = task; | 307 | tasks[task->nr] = task; |
331 | 308 | ||
332 | printk("registered task #%ld, PID %ld (%s)\n", nr_tasks, pid, comm); | 309 | if (verbose) |
310 | printf("registered task #%ld, PID %ld (%s)\n", nr_tasks, pid, comm); | ||
333 | 311 | ||
334 | return task; | 312 | return task; |
335 | } | 313 | } |
336 | 314 | ||
337 | 315 | ||
338 | static int first_trace_line = 1; | ||
339 | |||
340 | static nsec_t first_timestamp; | ||
341 | static nsec_t prev_timestamp; | ||
342 | |||
343 | void parse_line(char *line); | ||
344 | |||
345 | void parse_line(char *line) | ||
346 | { | ||
347 | unsigned long param1 = 0, param2 = 0; | ||
348 | char comm[COMM_LEN], comm2[COMM_LEN]; | ||
349 | unsigned long pid, pid2, timestamp0; | ||
350 | struct task_desc *task, *task2; | ||
351 | char func_str[SYM_LEN]; | ||
352 | nsec_t timestamp; | ||
353 | int ret; | ||
354 | |||
355 | //" <idle> 0 0D.s3 0us+: try_to_wake_up <events/0 9> (1 0)" | ||
356 | ret = sscanf(line, "%20s %5ld %*s %ldus%*c:" | ||
357 | " %128s <%20s %ld> (%ld %ld)\n", | ||
358 | comm, &pid, ×tamp0, | ||
359 | func_str, comm2, &pid2, ¶m1, ¶m2); | ||
360 | dprintk("ret: %d\n", ret); | ||
361 | if (ret != 8) | ||
362 | return; | ||
363 | |||
364 | timestamp = timestamp0 * 1000LL; | ||
365 | |||
366 | if (first_trace_line) { | ||
367 | first_trace_line = 0; | ||
368 | first_timestamp = timestamp; | ||
369 | } | ||
370 | |||
371 | timestamp -= first_timestamp; | ||
372 | BUG_ON(timestamp < prev_timestamp); | ||
373 | prev_timestamp = timestamp; | ||
374 | |||
375 | dprintk("parsed: %s - %ld %Ld: %s - <%s %ld> (%ld %ld)\n", | ||
376 | comm, | ||
377 | pid, | ||
378 | timestamp, | ||
379 | func_str, | ||
380 | comm2, | ||
381 | pid2, | ||
382 | param1, | ||
383 | param2); | ||
384 | |||
385 | task = register_pid(pid, comm); | ||
386 | task2 = register_pid(pid2, comm2); | ||
387 | |||
388 | if (!strcmp(func_str, "update_curr")) { | ||
389 | dprintk("%Ld: task %ld runs for %ld nsecs\n", | ||
390 | timestamp, task->nr, param1); | ||
391 | add_sched_event_run(task, timestamp, param1); | ||
392 | } else if (!strcmp(func_str, "try_to_wake_up")) { | ||
393 | dprintk("%Ld: task %ld wakes up task %ld\n", | ||
394 | timestamp, task->nr, task2->nr); | ||
395 | add_sched_event_wakeup(task, timestamp, task2); | ||
396 | } else if (!strcmp(func_str, "deactivate_task")) { | ||
397 | dprintk("%Ld: task %ld goes to sleep (uninterruptible: %ld)\n", | ||
398 | timestamp, task->nr, param1); | ||
399 | add_sched_event_sleep(task, timestamp, param1); | ||
400 | } | ||
401 | } | ||
402 | |||
403 | static void print_task_traces(void) | 316 | static void print_task_traces(void) |
404 | { | 317 | { |
405 | struct task_desc *task; | 318 | struct task_desc *task; |
@@ -407,7 +320,7 @@ static void print_task_traces(void) | |||
407 | 320 | ||
408 | for (i = 0; i < nr_tasks; i++) { | 321 | for (i = 0; i < nr_tasks; i++) { |
409 | task = tasks[i]; | 322 | task = tasks[i]; |
410 | printk("task %6ld (%20s:%10ld), nr_events: %ld\n", | 323 | printf("task %6ld (%20s:%10ld), nr_events: %ld\n", |
411 | task->nr, task->comm, task->pid, task->nr_events); | 324 | task->nr, task->comm, task->pid, task->nr_events); |
412 | } | 325 | } |
413 | } | 326 | } |
@@ -437,40 +350,16 @@ process_sched_event(struct task_desc *this_task __used, struct sched_event *even | |||
437 | now = get_nsecs(); | 350 | now = get_nsecs(); |
438 | delta = start_time + event->timestamp - now; | 351 | delta = start_time + event->timestamp - now; |
439 | 352 | ||
440 | dprintk("task %ld, event #%ld, %Ld, delta: %.3f (%Ld)\n", | ||
441 | this_task->nr, event->nr, event->timestamp, | ||
442 | (double)delta/1e6, delta); | ||
443 | |||
444 | if (0 && delta > 0) { | ||
445 | dprintk("%.3f: task %ld FIX %.3f\n", | ||
446 | (double)event->timestamp/1e6, | ||
447 | this_task->nr, | ||
448 | (double)delta/1e6); | ||
449 | sleep_nsecs(start_time + event->timestamp - now); | ||
450 | nr_sleep_corrections++; | ||
451 | } | ||
452 | |||
453 | switch (event->type) { | 353 | switch (event->type) { |
454 | case SCHED_EVENT_RUN: | 354 | case SCHED_EVENT_RUN: |
455 | dprintk("%.3f: task %ld RUN for %.3f\n", | ||
456 | (double)event->timestamp/1e6, | ||
457 | this_task->nr, | ||
458 | (double)event->duration/1e6); | ||
459 | burn_nsecs(event->duration); | 355 | burn_nsecs(event->duration); |
460 | break; | 356 | break; |
461 | case SCHED_EVENT_SLEEP: | 357 | case SCHED_EVENT_SLEEP: |
462 | dprintk("%.3f: task %ld %s SLEEP\n", | ||
463 | (double)event->timestamp/1e6, | ||
464 | this_task->nr, event->wait_sem ? "" : "SKIP"); | ||
465 | if (event->wait_sem) | 358 | if (event->wait_sem) |
466 | ret = sem_wait(event->wait_sem); | 359 | ret = sem_wait(event->wait_sem); |
467 | BUG_ON(ret); | 360 | BUG_ON(ret); |
468 | break; | 361 | break; |
469 | case SCHED_EVENT_WAKEUP: | 362 | case SCHED_EVENT_WAKEUP: |
470 | dprintk("%.3f: task %ld WAKEUP => task %ld\n", | ||
471 | (double)event->timestamp/1e6, | ||
472 | this_task->nr, | ||
473 | event->wakee->nr); | ||
474 | if (event->wait_sem) | 363 | if (event->wait_sem) |
475 | ret = sem_post(event->wait_sem); | 364 | ret = sem_post(event->wait_sem); |
476 | BUG_ON(ret); | 365 | BUG_ON(ret); |
@@ -511,14 +400,10 @@ static nsec_t get_cpu_usage_nsec_self(void) | |||
511 | BUG_ON(!file); | 400 | BUG_ON(!file); |
512 | 401 | ||
513 | while ((chars = getline(&line, &len, file)) != -1) { | 402 | while ((chars = getline(&line, &len, file)) != -1) { |
514 | dprintk("got line with length %zu :\n", chars); | ||
515 | dprintk("%s", line); | ||
516 | ret = sscanf(line, "se.sum_exec_runtime : %ld.%06ld\n", | 403 | ret = sscanf(line, "se.sum_exec_runtime : %ld.%06ld\n", |
517 | &msecs, &nsecs); | 404 | &msecs, &nsecs); |
518 | if (ret == 2) { | 405 | if (ret == 2) { |
519 | total = msecs*1e6 + nsecs; | 406 | total = msecs*1e6 + nsecs; |
520 | dprintk("total: (%ld.%06ld) %Ld\n", | ||
521 | msecs, nsecs, total); | ||
522 | break; | 407 | break; |
523 | } | 408 | } |
524 | } | 409 | } |
@@ -536,19 +421,16 @@ static void *thread_func(void *ctx) | |||
536 | unsigned long i, ret; | 421 | unsigned long i, ret; |
537 | char comm2[22]; | 422 | char comm2[22]; |
538 | 423 | ||
539 | dprintk("task %ld started up.\n", this_task->nr); | ||
540 | sprintf(comm2, ":%s", this_task->comm); | 424 | sprintf(comm2, ":%s", this_task->comm); |
541 | prctl(PR_SET_NAME, comm2); | 425 | prctl(PR_SET_NAME, comm2); |
542 | 426 | ||
543 | again: | 427 | again: |
544 | ret = sem_post(&this_task->ready_for_work); | 428 | ret = sem_post(&this_task->ready_for_work); |
545 | BUG_ON(ret); | 429 | BUG_ON(ret); |
546 | D(); | ||
547 | ret = pthread_mutex_lock(&start_work_mutex); | 430 | ret = pthread_mutex_lock(&start_work_mutex); |
548 | BUG_ON(ret); | 431 | BUG_ON(ret); |
549 | ret = pthread_mutex_unlock(&start_work_mutex); | 432 | ret = pthread_mutex_unlock(&start_work_mutex); |
550 | BUG_ON(ret); | 433 | BUG_ON(ret); |
551 | D(); | ||
552 | 434 | ||
553 | cpu_usage_0 = get_cpu_usage_nsec_self(); | 435 | cpu_usage_0 = get_cpu_usage_nsec_self(); |
554 | 436 | ||
@@ -560,19 +442,13 @@ again: | |||
560 | cpu_usage_1 = get_cpu_usage_nsec_self(); | 442 | cpu_usage_1 = get_cpu_usage_nsec_self(); |
561 | this_task->cpu_usage = cpu_usage_1 - cpu_usage_0; | 443 | this_task->cpu_usage = cpu_usage_1 - cpu_usage_0; |
562 | 444 | ||
563 | dprintk("task %ld cpu usage: %0.3f msecs\n", | ||
564 | this_task->nr, (double)this_task->cpu_usage / 1e6); | ||
565 | |||
566 | D(); | ||
567 | ret = sem_post(&this_task->work_done_sem); | 445 | ret = sem_post(&this_task->work_done_sem); |
568 | BUG_ON(ret); | 446 | BUG_ON(ret); |
569 | D(); | ||
570 | 447 | ||
571 | ret = pthread_mutex_lock(&work_done_wait_mutex); | 448 | ret = pthread_mutex_lock(&work_done_wait_mutex); |
572 | BUG_ON(ret); | 449 | BUG_ON(ret); |
573 | ret = pthread_mutex_unlock(&work_done_wait_mutex); | 450 | ret = pthread_mutex_unlock(&work_done_wait_mutex); |
574 | BUG_ON(ret); | 451 | BUG_ON(ret); |
575 | D(); | ||
576 | 452 | ||
577 | goto again; | 453 | goto again; |
578 | } | 454 | } |
@@ -614,9 +490,7 @@ static void wait_for_tasks(void) | |||
614 | struct task_desc *task; | 490 | struct task_desc *task; |
615 | unsigned long i, ret; | 491 | unsigned long i, ret; |
616 | 492 | ||
617 | DP(); | ||
618 | start_time = get_nsecs(); | 493 | start_time = get_nsecs(); |
619 | DP(); | ||
620 | cpu_usage = 0; | 494 | cpu_usage = 0; |
621 | pthread_mutex_unlock(&work_done_wait_mutex); | 495 | pthread_mutex_unlock(&work_done_wait_mutex); |
622 | 496 | ||
@@ -633,24 +507,6 @@ static void wait_for_tasks(void) | |||
633 | 507 | ||
634 | pthread_mutex_unlock(&start_work_mutex); | 508 | pthread_mutex_unlock(&start_work_mutex); |
635 | 509 | ||
636 | #if 0 | ||
637 | for (i = 0; i < nr_tasks; i++) { | ||
638 | unsigned long missed; | ||
639 | |||
640 | task = tasks[i]; | ||
641 | while (task->curr_event + 1 < task->nr_events) { | ||
642 | dprintk("parent waiting for %ld (%ld != %ld)\n", | ||
643 | i, task->curr_event, task->nr_events); | ||
644 | sleep_nsecs(100000000); | ||
645 | } | ||
646 | missed = task->nr_events - 1 - task->curr_event; | ||
647 | if (missed) | ||
648 | printk("task %ld missed events: %ld\n", i, missed); | ||
649 | ret = sem_post(&task->sleep_sem); | ||
650 | BUG_ON(ret); | ||
651 | } | ||
652 | #endif | ||
653 | DP(); | ||
654 | for (i = 0; i < nr_tasks; i++) { | 510 | for (i = 0; i < nr_tasks; i++) { |
655 | task = tasks[i]; | 511 | task = tasks[i]; |
656 | ret = sem_wait(&task->work_done_sem); | 512 | ret = sem_wait(&task->work_done_sem); |
@@ -687,16 +543,16 @@ static void parse_trace(void) | |||
687 | { | 543 | { |
688 | __cmd_sched(); | 544 | __cmd_sched(); |
689 | 545 | ||
690 | printk("nr_run_events: %ld\n", nr_run_events); | 546 | printf("nr_run_events: %ld\n", nr_run_events); |
691 | printk("nr_sleep_events: %ld\n", nr_sleep_events); | 547 | printf("nr_sleep_events: %ld\n", nr_sleep_events); |
692 | printk("nr_wakeup_events: %ld\n", nr_wakeup_events); | 548 | printf("nr_wakeup_events: %ld\n", nr_wakeup_events); |
693 | 549 | ||
694 | if (targetless_wakeups) | 550 | if (targetless_wakeups) |
695 | printk("target-less wakeups: %ld\n", targetless_wakeups); | 551 | printf("target-less wakeups: %ld\n", targetless_wakeups); |
696 | if (multitarget_wakeups) | 552 | if (multitarget_wakeups) |
697 | printk("multi-target wakeups: %ld\n", multitarget_wakeups); | 553 | printf("multi-target wakeups: %ld\n", multitarget_wakeups); |
698 | if (nr_run_events_optimized) | 554 | if (nr_run_events_optimized) |
699 | printk("run events optimized: %ld\n", | 555 | printf("run events optimized: %ld\n", |
700 | nr_run_events_optimized); | 556 | nr_run_events_optimized); |
701 | } | 557 | } |
702 | 558 | ||
@@ -728,17 +584,17 @@ static void run_one_test(void) | |||
728 | run_avg = delta; | 584 | run_avg = delta; |
729 | run_avg = (run_avg*9 + delta)/10; | 585 | run_avg = (run_avg*9 + delta)/10; |
730 | 586 | ||
731 | printk("#%-3ld: %0.3f, ", | 587 | printf("#%-3ld: %0.3f, ", |
732 | nr_runs, (double)delta/1000000.0); | 588 | nr_runs, (double)delta/1000000.0); |
733 | 589 | ||
734 | #if 0 | 590 | #if 0 |
735 | printk("%0.2f +- %0.2f, ", | 591 | printf("%0.2f +- %0.2f, ", |
736 | (double)avg_delta/1e6, (double)std_dev/1e6); | 592 | (double)avg_delta/1e6, (double)std_dev/1e6); |
737 | #endif | 593 | #endif |
738 | printk("ravg: %0.2f, ", | 594 | printf("ravg: %0.2f, ", |
739 | (double)run_avg/1e6); | 595 | (double)run_avg/1e6); |
740 | 596 | ||
741 | printk("cpu: %0.2f / %0.2f", | 597 | printf("cpu: %0.2f / %0.2f", |
742 | (double)cpu_usage/1e6, (double)runavg_cpu_usage/1e6); | 598 | (double)cpu_usage/1e6, (double)runavg_cpu_usage/1e6); |
743 | 599 | ||
744 | #if 0 | 600 | #if 0 |
@@ -746,15 +602,15 @@ static void run_one_test(void) | |||
746 | * rusage statistics done by the parent, these are less | 602 | * rusage statistics done by the parent, these are less |
747 | * accurate than the sum_exec_runtime based statistics: | 603 | * accurate than the sum_exec_runtime based statistics: |
748 | */ | 604 | */ |
749 | printk(" [%0.2f / %0.2f]", | 605 | printf(" [%0.2f / %0.2f]", |
750 | (double)parent_cpu_usage/1e6, | 606 | (double)parent_cpu_usage/1e6, |
751 | (double)runavg_parent_cpu_usage/1e6); | 607 | (double)runavg_parent_cpu_usage/1e6); |
752 | #endif | 608 | #endif |
753 | 609 | ||
754 | printk("\n"); | 610 | printf("\n"); |
755 | 611 | ||
756 | if (nr_sleep_corrections) | 612 | if (nr_sleep_corrections) |
757 | printk(" (%ld sleep corrections)\n", nr_sleep_corrections); | 613 | printf(" (%ld sleep corrections)\n", nr_sleep_corrections); |
758 | nr_sleep_corrections = 0; | 614 | nr_sleep_corrections = 0; |
759 | } | 615 | } |
760 | 616 | ||
@@ -766,13 +622,13 @@ static void test_calibrations(void) | |||
766 | burn_nsecs(1e6); | 622 | burn_nsecs(1e6); |
767 | T1 = get_nsecs(); | 623 | T1 = get_nsecs(); |
768 | 624 | ||
769 | printk("the run test took %Ld nsecs\n", T1-T0); | 625 | printf("the run test took %Ld nsecs\n", T1-T0); |
770 | 626 | ||
771 | T0 = get_nsecs(); | 627 | T0 = get_nsecs(); |
772 | sleep_nsecs(1e6); | 628 | sleep_nsecs(1e6); |
773 | T1 = get_nsecs(); | 629 | T1 = get_nsecs(); |
774 | 630 | ||
775 | printk("the sleep test took %Ld nsecs\n", T1-T0); | 631 | printf("the sleep test took %Ld nsecs\n", T1-T0); |
776 | } | 632 | } |
777 | 633 | ||
778 | static int | 634 | static int |
@@ -820,12 +676,14 @@ process_sched_wakeup_event(struct trace_wakeup_event *wakeup_event, struct event | |||
820 | { | 676 | { |
821 | struct task_desc *waker, *wakee; | 677 | struct task_desc *waker, *wakee; |
822 | 678 | ||
823 | printf("sched_wakeup event %p\n", event); | 679 | if (verbose) { |
680 | printf("sched_wakeup event %p\n", event); | ||
824 | 681 | ||
825 | printf(" ... pid %d woke up %s/%d\n", | 682 | printf(" ... pid %d woke up %s/%d\n", |
826 | wakeup_event->common_pid, | 683 | wakeup_event->common_pid, |
827 | wakeup_event->comm, | 684 | wakeup_event->comm, |
828 | wakeup_event->pid); | 685 | wakeup_event->pid); |
686 | } | ||
829 | 687 | ||
830 | waker = register_pid(wakeup_event->common_pid, "<unknown>"); | 688 | waker = register_pid(wakeup_event->common_pid, "<unknown>"); |
831 | wakee = register_pid(wakeup_event->pid, wakeup_event->comm); | 689 | wakee = register_pid(wakeup_event->pid, wakeup_event->comm); |
@@ -863,7 +721,9 @@ process_sched_switch_event(struct trace_switch_event *switch_event, struct event | |||
863 | u64 timestamp0; | 721 | u64 timestamp0; |
864 | s64 delta; | 722 | s64 delta; |
865 | 723 | ||
866 | printf("sched_switch event %p\n", event); | 724 | if (verbose) |
725 | printf("sched_switch event %p\n", event); | ||
726 | |||
867 | if (cpu >= MAX_CPUS || cpu < 0) | 727 | if (cpu >= MAX_CPUS || cpu < 0) |
868 | return; | 728 | return; |
869 | 729 | ||
@@ -876,10 +736,12 @@ process_sched_switch_event(struct trace_switch_event *switch_event, struct event | |||
876 | if (delta < 0) | 736 | if (delta < 0) |
877 | die("hm, delta: %Ld < 0 ?\n", delta); | 737 | die("hm, delta: %Ld < 0 ?\n", delta); |
878 | 738 | ||
879 | printf(" ... switch from %s/%d to %s/%d [ran %Ld nsecs]\n", | 739 | if (verbose) { |
880 | switch_event->prev_comm, switch_event->prev_pid, | 740 | printf(" ... switch from %s/%d to %s/%d [ran %Ld nsecs]\n", |
881 | switch_event->next_comm, switch_event->next_pid, | 741 | switch_event->prev_comm, switch_event->prev_pid, |
882 | delta); | 742 | switch_event->next_comm, switch_event->next_pid, |
743 | delta); | ||
744 | } | ||
883 | 745 | ||
884 | prev = register_pid(switch_event->prev_pid, switch_event->prev_comm); | 746 | prev = register_pid(switch_event->prev_pid, switch_event->prev_comm); |
885 | next = register_pid(switch_event->next_pid, switch_event->next_comm); | 747 | next = register_pid(switch_event->next_pid, switch_event->next_comm); |
@@ -887,6 +749,7 @@ process_sched_switch_event(struct trace_switch_event *switch_event, struct event | |||
887 | cpu_last_switched[cpu] = timestamp; | 749 | cpu_last_switched[cpu] = timestamp; |
888 | 750 | ||
889 | add_sched_event_run(prev, timestamp, delta); | 751 | add_sched_event_run(prev, timestamp, delta); |
752 | add_sched_event_sleep(prev, timestamp, switch_event->prev_state); | ||
890 | } | 753 | } |
891 | 754 | ||
892 | struct trace_fork_event { | 755 | struct trace_fork_event { |
@@ -908,9 +771,11 @@ static void | |||
908 | process_sched_fork_event(struct trace_fork_event *fork_event, struct event *event, | 771 | process_sched_fork_event(struct trace_fork_event *fork_event, struct event *event, |
909 | int cpu __used, u64 timestamp __used, struct thread *thread __used) | 772 | int cpu __used, u64 timestamp __used, struct thread *thread __used) |
910 | { | 773 | { |
911 | printf("sched_fork event %p\n", event); | 774 | if (verbose) { |
912 | printf("... parent: %s/%d\n", fork_event->parent_comm, fork_event->parent_pid); | 775 | printf("sched_fork event %p\n", event); |
913 | printf("... child: %s/%d\n", fork_event->child_comm, fork_event->child_pid); | 776 | printf("... parent: %s/%d\n", fork_event->parent_comm, fork_event->parent_pid); |
777 | printf("... child: %s/%d\n", fork_event->child_comm, fork_event->child_pid); | ||
778 | } | ||
914 | register_pid(fork_event->parent_pid, fork_event->parent_comm); | 779 | register_pid(fork_event->parent_pid, fork_event->parent_comm); |
915 | register_pid(fork_event->child_pid, fork_event->child_comm); | 780 | register_pid(fork_event->child_pid, fork_event->child_comm); |
916 | } | 781 | } |
@@ -918,11 +783,12 @@ process_sched_fork_event(struct trace_fork_event *fork_event, struct event *even | |||
918 | static void process_sched_exit_event(struct event *event, | 783 | static void process_sched_exit_event(struct event *event, |
919 | int cpu __used, u64 timestamp __used, struct thread *thread __used) | 784 | int cpu __used, u64 timestamp __used, struct thread *thread __used) |
920 | { | 785 | { |
921 | printf("sched_exit event %p\n", event); | 786 | if (verbose) |
787 | printf("sched_exit event %p\n", event); | ||
922 | } | 788 | } |
923 | 789 | ||
924 | static void | 790 | static void |
925 | process_raw_event(event_t *raw_event, void *more_data, | 791 | process_raw_event(event_t *raw_event __used, void *more_data, |
926 | int cpu, u64 timestamp, struct thread *thread) | 792 | int cpu, u64 timestamp, struct thread *thread) |
927 | { | 793 | { |
928 | struct { | 794 | struct { |
@@ -935,14 +801,6 @@ process_raw_event(event_t *raw_event, void *more_data, | |||
935 | type = trace_parse_common_type(raw->data); | 801 | type = trace_parse_common_type(raw->data); |
936 | event = trace_find_event(type); | 802 | event = trace_find_event(type); |
937 | 803 | ||
938 | /* | ||
939 | * FIXME: better resolve from pid from the struct trace_entry | ||
940 | * field, although it should be the same than this perf | ||
941 | * event pid | ||
942 | */ | ||
943 | printf("id %d, type: %d, event: %s\n", | ||
944 | raw_event->header.type, type, event->name); | ||
945 | |||
946 | if (!strcmp(event->name, "sched_switch")) | 804 | if (!strcmp(event->name, "sched_switch")) |
947 | process_sched_switch_event(more_data, event, cpu, timestamp, thread); | 805 | process_sched_switch_event(more_data, event, cpu, timestamp, thread); |
948 | if (!strcmp(event->name, "sched_wakeup")) | 806 | if (!strcmp(event->name, "sched_wakeup")) |
@@ -1197,7 +1055,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used) | |||
1197 | add_cross_task_wakeups(); | 1055 | add_cross_task_wakeups(); |
1198 | 1056 | ||
1199 | create_tasks(); | 1057 | create_tasks(); |
1200 | printk("------------------------------------------------------------\n"); | 1058 | printf("------------------------------------------------------------\n"); |
1201 | for (i = 0; i < nr_iterations; i++) | 1059 | for (i = 0; i < nr_iterations; i++) |
1202 | run_one_test(); | 1060 | run_one_test(); |
1203 | 1061 | ||