Commit 46f392c9 authored by Ingo Molnar's avatar Ingo Molnar

perf sched: Clean up latency and replay sub-commands

- Separate the latency and the replay commands more cleanly

 - Use consistent naming

 - Display help page on 'perf sched' outlining comments,
   instead of aborting

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: default avatarIngo Molnar <mingo@elte.hu>
parent cdce9d73
...@@ -543,24 +543,7 @@ static void wait_for_tasks(void) ...@@ -543,24 +543,7 @@ static void wait_for_tasks(void)
} }
} }
static int __cmd_sched(void); static int read_events(void);
static void parse_trace(void)
{
__cmd_sched();
printf("nr_run_events: %ld\n", nr_run_events);
printf("nr_sleep_events: %ld\n", nr_sleep_events);
printf("nr_wakeup_events: %ld\n", nr_wakeup_events);
if (targetless_wakeups)
printf("target-less wakeups: %ld\n", targetless_wakeups);
if (multitarget_wakeups)
printf("multi-target wakeups: %ld\n", multitarget_wakeups);
if (nr_run_events_optimized)
printf("run events optimized: %ld\n",
nr_run_events_optimized);
}
static unsigned long nr_runs; static unsigned long nr_runs;
static nsec_t sum_runtime; static nsec_t sum_runtime;
...@@ -637,6 +620,38 @@ static void test_calibrations(void) ...@@ -637,6 +620,38 @@ static void test_calibrations(void)
printf("the sleep test took %Ld nsecs\n", T1-T0); printf("the sleep test took %Ld nsecs\n", T1-T0);
} }
static void __cmd_replay(void)
{
long nr_iterations = 10, i;
calibrate_run_measurement_overhead();
calibrate_sleep_measurement_overhead();
test_calibrations();
read_events();
printf("nr_run_events: %ld\n", nr_run_events);
printf("nr_sleep_events: %ld\n", nr_sleep_events);
printf("nr_wakeup_events: %ld\n", nr_wakeup_events);
if (targetless_wakeups)
printf("target-less wakeups: %ld\n", targetless_wakeups);
if (multitarget_wakeups)
printf("multi-target wakeups: %ld\n", multitarget_wakeups);
if (nr_run_events_optimized)
printf("run events optimized: %ld\n",
nr_run_events_optimized);
print_task_traces();
add_cross_task_wakeups();
create_tasks();
printf("------------------------------------------------------------\n");
for (i = 0; i < nr_iterations; i++)
run_one_test();
}
static int static int
process_comm_event(event_t *event, unsigned long offset, unsigned long head) process_comm_event(event_t *event, unsigned long offset, unsigned long head)
{ {
...@@ -1091,10 +1106,13 @@ static void output_lat_thread(struct thread_latency *lat) ...@@ -1091,10 +1106,13 @@ static void output_lat_thread(struct thread_latency *lat)
printf("%5d %10llu %10llu %10llu\n", count, total, avg, max); printf("%5d %10llu %10llu %10llu\n", count, total, avg, max);
} }
static void output_lat_results(void) static void __cmd_lat(void)
{ {
struct rb_node *next; struct rb_node *next;
setup_pager();
read_events();
printf(" Tasks"); printf(" Tasks");
printf(" count"); printf(" count");
printf(" total"); printf(" total");
...@@ -1312,7 +1330,7 @@ process_event(event_t *event, unsigned long offset, unsigned long head) ...@@ -1312,7 +1330,7 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
return 0; return 0;
} }
static int __cmd_sched(void) static int read_events(void)
{ {
int ret, rc = EXIT_FAILURE; int ret, rc = EXIT_FAILURE;
unsigned long offset = 0; unsigned long offset = 0;
...@@ -1408,8 +1426,8 @@ static int __cmd_sched(void) ...@@ -1408,8 +1426,8 @@ static int __cmd_sched(void)
return rc; return rc;
} }
static const char * const annotate_usage[] = { static const char * const sched_usage[] = {
"perf trace [<options>] <command>", "perf sched [<options>] <command>",
NULL NULL
}; };
...@@ -1427,49 +1445,30 @@ static const struct option options[] = { ...@@ -1427,49 +1445,30 @@ static const struct option options[] = {
int cmd_sched(int argc, const char **argv, const char *prefix __used) int cmd_sched(int argc, const char **argv, const char *prefix __used)
{ {
long nr_iterations = 10, i;
symbol__init(); symbol__init();
page_size = getpagesize(); page_size = getpagesize();
argc = parse_options(argc, argv, options, annotate_usage, 0); argc = parse_options(argc, argv, options, sched_usage, 0);
if (argc) { if (argc) {
/* /*
* Special case: if there's an argument left then assume tha * Special case: if there's an argument left then assume tha
* it's a symbol filter: * it's a symbol filter:
*/ */
if (argc > 1) if (argc > 1)
usage_with_options(annotate_usage, options); usage_with_options(sched_usage, options);
} }
// setup_pager();
if (replay_mode) if (replay_mode)
trace_handler = &replay_ops; trace_handler = &replay_ops;
else if (lat_mode) else if (lat_mode)
trace_handler = &lat_ops; trace_handler = &lat_ops;
else /* We may need a default subcommand (perf trace?) */ else
die("Please select a sub command (-r)\n"); usage_with_options(sched_usage, options);
if (replay_mode) { if (replay_mode)
calibrate_run_measurement_overhead(); __cmd_replay();
calibrate_sleep_measurement_overhead(); else if (lat_mode)
__cmd_lat();
test_calibrations();
parse_trace();
print_task_traces();
add_cross_task_wakeups();
create_tasks();
printf("------------------------------------------------------------\n");
for (i = 0; i < nr_iterations; i++)
run_one_test();
} else if (lat_mode) {
setup_pager();
__cmd_sched();
output_lat_results();
}
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment