mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
perf sched: Add 'perf sched latency' and 'perf sched replay'
Separate the option parsing cleanly and add two variants: - 'perf sched latency' (can be abbreviated via 'perf sched lat') - 'perf sched replay' (can be abbreviated via 'perf sched rep') Also add a repeat count option to replay and add a separation set of options for replay. Do the sorting setup only in the latency sub-command. Display separate help screens for 'perf sched' and 'perf sched replay -h' - i.e. further separation of the sub-commands. 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>
This commit is contained in:
parent
daa1d7a5ea
commit
f2858d8ad9
1 changed files with 59 additions and 33 deletions
|
@ -30,9 +30,6 @@ static struct thread *last_match;
|
||||||
static struct perf_header *header;
|
static struct perf_header *header;
|
||||||
static u64 sample_type;
|
static u64 sample_type;
|
||||||
|
|
||||||
static int replay_mode;
|
|
||||||
static int lat_mode;
|
|
||||||
|
|
||||||
static char default_sort_order[] = "avg, max, switch, runtime";
|
static char default_sort_order[] = "avg, max, switch, runtime";
|
||||||
static char *sort_order = default_sort_order;
|
static char *sort_order = default_sort_order;
|
||||||
|
|
||||||
|
@ -623,9 +620,11 @@ 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 unsigned long replay_repeat = 10;
|
||||||
|
|
||||||
static void __cmd_replay(void)
|
static void __cmd_replay(void)
|
||||||
{
|
{
|
||||||
long nr_iterations = 10, i;
|
unsigned long i;
|
||||||
|
|
||||||
calibrate_run_measurement_overhead();
|
calibrate_run_measurement_overhead();
|
||||||
calibrate_sleep_measurement_overhead();
|
calibrate_sleep_measurement_overhead();
|
||||||
|
@ -651,7 +650,7 @@ static void __cmd_replay(void)
|
||||||
|
|
||||||
create_tasks();
|
create_tasks();
|
||||||
printf("------------------------------------------------------------\n");
|
printf("------------------------------------------------------------\n");
|
||||||
for (i = 0; i < nr_iterations; i++)
|
for (i = 0; i < replay_repeat; i++)
|
||||||
run_one_test();
|
run_one_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1623,21 +1622,45 @@ more:
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * const sched_usage[] = {
|
static const char * const sched_usage[] = {
|
||||||
"perf sched [<options>] <command>",
|
"perf sched [<options>] {record|latency|replay}",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option sched_options[] = {
|
||||||
|
OPT_BOOLEAN('v', "verbose", &verbose,
|
||||||
|
"be more verbose (show symbol address, etc)"),
|
||||||
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
|
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
|
||||||
"dump raw trace in ASCII"),
|
"dump raw trace in ASCII"),
|
||||||
OPT_BOOLEAN('r', "replay", &replay_mode,
|
OPT_END()
|
||||||
"replay sched behaviour from traces"),
|
};
|
||||||
OPT_BOOLEAN('l', "latency", &lat_mode,
|
|
||||||
"measure various latencies"),
|
static const char * const latency_usage[] = {
|
||||||
|
"perf sched latency [<options>]",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct option latency_options[] = {
|
||||||
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
|
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
|
||||||
"sort by key(s): runtime, switch, avg, max"),
|
"sort by key(s): runtime, switch, avg, max"),
|
||||||
OPT_BOOLEAN('v', "verbose", &verbose,
|
OPT_BOOLEAN('v', "verbose", &verbose,
|
||||||
"be more verbose (show symbol address, etc)"),
|
"be more verbose (show symbol address, etc)"),
|
||||||
|
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
|
||||||
|
"dump raw trace in ASCII"),
|
||||||
|
OPT_END()
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char * const replay_usage[] = {
|
||||||
|
"perf sched replay [<options>]",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct option replay_options[] = {
|
||||||
|
OPT_INTEGER('r', "repeat", &replay_repeat,
|
||||||
|
"repeat the workload replay N times (-1: infinite)"),
|
||||||
|
OPT_BOOLEAN('v', "verbose", &verbose,
|
||||||
|
"be more verbose (show symbol address, etc)"),
|
||||||
|
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
|
||||||
|
"dump raw trace in ASCII"),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1649,7 +1672,7 @@ static void setup_sorting(void)
|
||||||
tok; tok = strtok_r(NULL, ", ", &tmp)) {
|
tok; tok = strtok_r(NULL, ", ", &tmp)) {
|
||||||
if (sort_dimension__add(tok, &sort_list) < 0) {
|
if (sort_dimension__add(tok, &sort_list) < 0) {
|
||||||
error("Unknown --sort key: `%s'", tok);
|
error("Unknown --sort key: `%s'", tok);
|
||||||
usage_with_options(sched_usage, options);
|
usage_with_options(latency_usage, latency_options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1663,29 +1686,32 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used)
|
||||||
symbol__init();
|
symbol__init();
|
||||||
page_size = getpagesize();
|
page_size = getpagesize();
|
||||||
|
|
||||||
argc = parse_options(argc, argv, options, sched_usage, 0);
|
argc = parse_options(argc, argv, sched_options, sched_usage,
|
||||||
if (argc) {
|
PARSE_OPT_STOP_AT_NON_OPTION);
|
||||||
/*
|
if (!argc)
|
||||||
* Special case: if there's an argument left then assume tha
|
usage_with_options(sched_usage, sched_options);
|
||||||
* it's a symbol filter:
|
|
||||||
*/
|
if (!strncmp(argv[0], "lat", 3)) {
|
||||||
if (argc > 1)
|
trace_handler = &lat_ops;
|
||||||
usage_with_options(sched_usage, options);
|
if (argc > 1) {
|
||||||
|
argc = parse_options(argc, argv, latency_options, latency_usage, 0);
|
||||||
|
if (argc)
|
||||||
|
usage_with_options(latency_usage, latency_options);
|
||||||
|
setup_sorting();
|
||||||
|
}
|
||||||
|
__cmd_lat();
|
||||||
|
} else if (!strncmp(argv[0], "rep", 3)) {
|
||||||
|
trace_handler = &replay_ops;
|
||||||
|
if (argc) {
|
||||||
|
argc = parse_options(argc, argv, replay_options, replay_usage, 0);
|
||||||
|
if (argc)
|
||||||
|
usage_with_options(replay_usage, replay_options);
|
||||||
|
}
|
||||||
|
__cmd_replay();
|
||||||
|
} else {
|
||||||
|
usage_with_options(sched_usage, sched_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replay_mode)
|
|
||||||
trace_handler = &replay_ops;
|
|
||||||
else if (lat_mode)
|
|
||||||
trace_handler = &lat_ops;
|
|
||||||
else
|
|
||||||
usage_with_options(sched_usage, options);
|
|
||||||
|
|
||||||
setup_sorting();
|
|
||||||
|
|
||||||
if (replay_mode)
|
|
||||||
__cmd_replay();
|
|
||||||
else if (lat_mode)
|
|
||||||
__cmd_lat();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue