perf stat: Move 'walltime_*' data to 'struct perf_stat_config'
Move the static variables 'walltime_*' to 'struct perf_stat_config', so that it can be passed around and used outside 'perf stat' command. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20180830063252.23729-42-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
be54d59325
commit
54ac0b1bd2
|
@ -158,13 +158,11 @@ static const char *post_cmd = NULL;
|
||||||
static bool sync_run = false;
|
static bool sync_run = false;
|
||||||
static bool forever = false;
|
static bool forever = false;
|
||||||
static bool force_metric_only = false;
|
static bool force_metric_only = false;
|
||||||
static bool walltime_run_table = false;
|
|
||||||
static struct timespec ref_time;
|
static struct timespec ref_time;
|
||||||
static bool append_file;
|
static bool append_file;
|
||||||
static bool interval_count;
|
static bool interval_count;
|
||||||
static const char *output_name;
|
static const char *output_name;
|
||||||
static int output_fd;
|
static int output_fd;
|
||||||
static u64 *walltime_run;
|
|
||||||
|
|
||||||
struct perf_stat {
|
struct perf_stat {
|
||||||
bool record;
|
bool record;
|
||||||
|
@ -604,8 +602,8 @@ try_again:
|
||||||
|
|
||||||
t1 = rdclock();
|
t1 = rdclock();
|
||||||
|
|
||||||
if (walltime_run_table)
|
if (stat_config.walltime_run_table)
|
||||||
walltime_run[run_idx] = t1 - t0;
|
stat_config.walltime_run[run_idx] = t1 - t0;
|
||||||
|
|
||||||
update_stats(&walltime_nsecs_stats, t1 - t0);
|
update_stats(&walltime_nsecs_stats, t1 - t0);
|
||||||
|
|
||||||
|
@ -1646,7 +1644,7 @@ static void print_table(struct perf_stat_config *config,
|
||||||
fprintf(output, "%*s# Table of individual measurements:\n", indent, "");
|
fprintf(output, "%*s# Table of individual measurements:\n", indent, "");
|
||||||
|
|
||||||
for (idx = 0; idx < config->run_count; idx++) {
|
for (idx = 0; idx < config->run_count; idx++) {
|
||||||
double run = (double) walltime_run[idx] / NSEC_PER_SEC;
|
double run = (double) config->walltime_run[idx] / NSEC_PER_SEC;
|
||||||
int h, n = 1 + abs((int) (100.0 * (run - avg)/run) / 5);
|
int h, n = 1 + abs((int) (100.0 * (run - avg)/run) / 5);
|
||||||
|
|
||||||
fprintf(output, " %17.*f (%+.*f) ",
|
fprintf(output, " %17.*f (%+.*f) ",
|
||||||
|
@ -1694,7 +1692,7 @@ static void print_footer(struct perf_stat_config *config)
|
||||||
*/
|
*/
|
||||||
int precision = get_precision(sd) + 2;
|
int precision = get_precision(sd) + 2;
|
||||||
|
|
||||||
if (walltime_run_table)
|
if (config->walltime_run_table)
|
||||||
print_table(config, output, precision, avg);
|
print_table(config, output, precision, avg);
|
||||||
|
|
||||||
fprintf(output, " %17.*f +- %.*f seconds time elapsed",
|
fprintf(output, " %17.*f +- %.*f seconds time elapsed",
|
||||||
|
@ -1888,7 +1886,7 @@ static const struct option stat_options[] = {
|
||||||
"be more verbose (show counter open errors, etc)"),
|
"be more verbose (show counter open errors, etc)"),
|
||||||
OPT_INTEGER('r', "repeat", &stat_config.run_count,
|
OPT_INTEGER('r', "repeat", &stat_config.run_count,
|
||||||
"repeat command and print average + stddev (max: 100, forever: 0)"),
|
"repeat command and print average + stddev (max: 100, forever: 0)"),
|
||||||
OPT_BOOLEAN(0, "table", &walltime_run_table,
|
OPT_BOOLEAN(0, "table", &stat_config.walltime_run_table,
|
||||||
"display details about each run (only with -r option)"),
|
"display details about each run (only with -r option)"),
|
||||||
OPT_BOOLEAN('n', "null", &stat_config.null_run,
|
OPT_BOOLEAN('n', "null", &stat_config.null_run,
|
||||||
"null run - dont start any counters"),
|
"null run - dont start any counters"),
|
||||||
|
@ -2802,7 +2800,7 @@ int cmd_stat(int argc, const char **argv)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walltime_run_table && stat_config.run_count <= 1) {
|
if (stat_config.walltime_run_table && stat_config.run_count <= 1) {
|
||||||
fprintf(stderr, "--table is only supported with -r\n");
|
fprintf(stderr, "--table is only supported with -r\n");
|
||||||
parse_options_usage(stat_usage, stat_options, "r", 1);
|
parse_options_usage(stat_usage, stat_options, "r", 1);
|
||||||
parse_options_usage(NULL, stat_options, "table", 0);
|
parse_options_usage(NULL, stat_options, "table", 0);
|
||||||
|
@ -2870,9 +2868,9 @@ int cmd_stat(int argc, const char **argv)
|
||||||
stat_config.run_count = 1;
|
stat_config.run_count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walltime_run_table) {
|
if (stat_config.walltime_run_table) {
|
||||||
walltime_run = zalloc(stat_config.run_count * sizeof(walltime_run[0]));
|
stat_config.walltime_run = zalloc(stat_config.run_count * sizeof(stat_config.walltime_run[0]));
|
||||||
if (!walltime_run) {
|
if (!stat_config.walltime_run) {
|
||||||
pr_err("failed to setup -r option");
|
pr_err("failed to setup -r option");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -3052,7 +3050,7 @@ int cmd_stat(int argc, const char **argv)
|
||||||
perf_stat__exit_aggr_mode();
|
perf_stat__exit_aggr_mode();
|
||||||
perf_evlist__free_stats(evsel_list);
|
perf_evlist__free_stats(evsel_list);
|
||||||
out:
|
out:
|
||||||
free(walltime_run);
|
free(stat_config.walltime_run);
|
||||||
|
|
||||||
if (smi_cost && smi_reset)
|
if (smi_cost && smi_reset)
|
||||||
sysfs__write_int(FREEZE_ON_SMI_PATH, 0);
|
sysfs__write_int(FREEZE_ON_SMI_PATH, 0);
|
||||||
|
|
|
@ -105,6 +105,7 @@ struct perf_stat_config {
|
||||||
bool ru_display;
|
bool ru_display;
|
||||||
bool big_num;
|
bool big_num;
|
||||||
bool no_merge;
|
bool no_merge;
|
||||||
|
bool walltime_run_table;
|
||||||
FILE *output;
|
FILE *output;
|
||||||
unsigned int interval;
|
unsigned int interval;
|
||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
|
@ -123,6 +124,7 @@ struct perf_stat_config {
|
||||||
struct cpu_map *aggr_map;
|
struct cpu_map *aggr_map;
|
||||||
aggr_get_id_t aggr_get_id;
|
aggr_get_id_t aggr_get_id;
|
||||||
struct cpu_map *cpus_aggr_map;
|
struct cpu_map *cpus_aggr_map;
|
||||||
|
u64 *walltime_run;
|
||||||
};
|
};
|
||||||
|
|
||||||
void update_stats(struct stats *stats, u64 val);
|
void update_stats(struct stats *stats, u64 val);
|
||||||
|
|
Loading…
Reference in New Issue