aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-sched.c99
1 files changed, 49 insertions, 50 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 4f9e943181a3..84699cf036ab 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -543,24 +543,7 @@ static void wait_for_tasks(void)
543 } 543 }
544} 544}
545 545
546static int __cmd_sched(void); 546static int read_events(void);
547
548static void parse_trace(void)
549{
550 __cmd_sched();
551
552 printf("nr_run_events: %ld\n", nr_run_events);
553 printf("nr_sleep_events: %ld\n", nr_sleep_events);
554 printf("nr_wakeup_events: %ld\n", nr_wakeup_events);
555
556 if (targetless_wakeups)
557 printf("target-less wakeups: %ld\n", targetless_wakeups);
558 if (multitarget_wakeups)
559 printf("multi-target wakeups: %ld\n", multitarget_wakeups);
560 if (nr_run_events_optimized)
561 printf("run events optimized: %ld\n",
562 nr_run_events_optimized);
563}
564 547
565static unsigned long nr_runs; 548static unsigned long nr_runs;
566static nsec_t sum_runtime; 549static nsec_t sum_runtime;
@@ -637,6 +620,38 @@ static void test_calibrations(void)
637 printf("the sleep test took %Ld nsecs\n", T1-T0); 620 printf("the sleep test took %Ld nsecs\n", T1-T0);
638} 621}
639 622
623static void __cmd_replay(void)
624{
625 long nr_iterations = 10, i;
626
627 calibrate_run_measurement_overhead();
628 calibrate_sleep_measurement_overhead();
629
630 test_calibrations();
631
632 read_events();
633
634 printf("nr_run_events: %ld\n", nr_run_events);
635 printf("nr_sleep_events: %ld\n", nr_sleep_events);
636 printf("nr_wakeup_events: %ld\n", nr_wakeup_events);
637
638 if (targetless_wakeups)
639 printf("target-less wakeups: %ld\n", targetless_wakeups);
640 if (multitarget_wakeups)
641 printf("multi-target wakeups: %ld\n", multitarget_wakeups);
642 if (nr_run_events_optimized)
643 printf("run events optimized: %ld\n",
644 nr_run_events_optimized);
645
646 print_task_traces();
647 add_cross_task_wakeups();
648
649 create_tasks();
650 printf("------------------------------------------------------------\n");
651 for (i = 0; i < nr_iterations; i++)
652 run_one_test();
653}
654
640static int 655static int
641process_comm_event(event_t *event, unsigned long offset, unsigned long head) 656process_comm_event(event_t *event, unsigned long offset, unsigned long head)
642{ 657{
@@ -1091,10 +1106,13 @@ static void output_lat_thread(struct thread_latency *lat)
1091 printf("%5d %10llu %10llu %10llu\n", count, total, avg, max); 1106 printf("%5d %10llu %10llu %10llu\n", count, total, avg, max);
1092} 1107}
1093 1108
1094static void output_lat_results(void) 1109static void __cmd_lat(void)
1095{ 1110{
1096 struct rb_node *next; 1111 struct rb_node *next;
1097 1112
1113 setup_pager();
1114 read_events();
1115
1098 printf(" Tasks"); 1116 printf(" Tasks");
1099 printf(" count"); 1117 printf(" count");
1100 printf(" total"); 1118 printf(" total");
@@ -1312,7 +1330,7 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1312 return 0; 1330 return 0;
1313} 1331}
1314 1332
1315static int __cmd_sched(void) 1333static int read_events(void)
1316{ 1334{
1317 int ret, rc = EXIT_FAILURE; 1335 int ret, rc = EXIT_FAILURE;
1318 unsigned long offset = 0; 1336 unsigned long offset = 0;
@@ -1408,8 +1426,8 @@ more:
1408 return rc; 1426 return rc;
1409} 1427}
1410 1428
1411static const char * const annotate_usage[] = { 1429static const char * const sched_usage[] = {
1412 "perf trace [<options>] <command>", 1430 "perf sched [<options>] <command>",
1413 NULL 1431 NULL
1414}; 1432};
1415 1433
@@ -1427,49 +1445,30 @@ static const struct option options[] = {
1427 1445
1428int cmd_sched(int argc, const char **argv, const char *prefix __used) 1446int cmd_sched(int argc, const char **argv, const char *prefix __used)
1429{ 1447{
1430 long nr_iterations = 10, i;
1431
1432 symbol__init(); 1448 symbol__init();
1433 page_size = getpagesize(); 1449 page_size = getpagesize();
1434 1450
1435 argc = parse_options(argc, argv, options, annotate_usage, 0); 1451 argc = parse_options(argc, argv, options, sched_usage, 0);
1436 if (argc) { 1452 if (argc) {
1437 /* 1453 /*
1438 * Special case: if there's an argument left then assume tha 1454 * Special case: if there's an argument left then assume tha
1439 * it's a symbol filter: 1455 * it's a symbol filter:
1440 */ 1456 */
1441 if (argc > 1) 1457 if (argc > 1)
1442 usage_with_options(annotate_usage, options); 1458 usage_with_options(sched_usage, options);
1443 } 1459 }
1444 1460
1445// setup_pager();
1446
1447 if (replay_mode) 1461 if (replay_mode)
1448 trace_handler = &replay_ops; 1462 trace_handler = &replay_ops;
1449 else if (lat_mode) 1463 else if (lat_mode)
1450 trace_handler = &lat_ops; 1464 trace_handler = &lat_ops;
1451 else /* We may need a default subcommand (perf trace?) */ 1465 else
1452 die("Please select a sub command (-r)\n"); 1466 usage_with_options(sched_usage, options);
1453 1467
1454 if (replay_mode) { 1468 if (replay_mode)
1455 calibrate_run_measurement_overhead(); 1469 __cmd_replay();
1456 calibrate_sleep_measurement_overhead(); 1470 else if (lat_mode)
1457 1471 __cmd_lat();
1458 test_calibrations();
1459
1460 parse_trace();
1461 print_task_traces();
1462 add_cross_task_wakeups();
1463
1464 create_tasks();
1465 printf("------------------------------------------------------------\n");
1466 for (i = 0; i < nr_iterations; i++)
1467 run_one_test();
1468 } else if (lat_mode) {
1469 setup_pager();
1470 __cmd_sched();
1471 output_lat_results();
1472 }
1473 1472
1474 return 0; 1473 return 0;
1475} 1474}