diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2018-08-30 02:32:50 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-08-30 14:52:25 -0400 |
| commit | 54ac0b1bd25cbdeda226b32a0459e09de46157b3 (patch) | |
| tree | 114277c331c0511753ca82d9083f33114b31343a | |
| parent | be54d59325314be9d4d53852cbfbeeaebc3b9239 (diff) | |
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>
| -rw-r--r-- | tools/perf/builtin-stat.c | 22 | ||||
| -rw-r--r-- | tools/perf/util/stat.h | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 486b0cf7818d..8a4979748cbb 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
| @@ -158,13 +158,11 @@ static const char *post_cmd = NULL; | |||
| 158 | static bool sync_run = false; | 158 | static bool sync_run = false; |
| 159 | static bool forever = false; | 159 | static bool forever = false; |
| 160 | static bool force_metric_only = false; | 160 | static bool force_metric_only = false; |
| 161 | static bool walltime_run_table = false; | ||
| 162 | static struct timespec ref_time; | 161 | static struct timespec ref_time; |
| 163 | static bool append_file; | 162 | static bool append_file; |
| 164 | static bool interval_count; | 163 | static bool interval_count; |
| 165 | static const char *output_name; | 164 | static const char *output_name; |
| 166 | static int output_fd; | 165 | static int output_fd; |
| 167 | static u64 *walltime_run; | ||
| 168 | 166 | ||
| 169 | struct perf_stat { | 167 | struct perf_stat { |
| 170 | bool record; | 168 | bool record; |
| @@ -604,8 +602,8 @@ try_again: | |||
| 604 | 602 | ||
| 605 | t1 = rdclock(); | 603 | t1 = rdclock(); |
| 606 | 604 | ||
| 607 | if (walltime_run_table) | 605 | if (stat_config.walltime_run_table) |
| 608 | walltime_run[run_idx] = t1 - t0; | 606 | stat_config.walltime_run[run_idx] = t1 - t0; |
| 609 | 607 | ||
| 610 | update_stats(&walltime_nsecs_stats, t1 - t0); | 608 | update_stats(&walltime_nsecs_stats, t1 - t0); |
| 611 | 609 | ||
| @@ -1646,7 +1644,7 @@ static void print_table(struct perf_stat_config *config, | |||
| 1646 | fprintf(output, "%*s# Table of individual measurements:\n", indent, ""); | 1644 | fprintf(output, "%*s# Table of individual measurements:\n", indent, ""); |
| 1647 | 1645 | ||
| 1648 | for (idx = 0; idx < config->run_count; idx++) { | 1646 | for (idx = 0; idx < config->run_count; idx++) { |
| 1649 | double run = (double) walltime_run[idx] / NSEC_PER_SEC; | 1647 | double run = (double) config->walltime_run[idx] / NSEC_PER_SEC; |
| 1650 | int h, n = 1 + abs((int) (100.0 * (run - avg)/run) / 5); | 1648 | int h, n = 1 + abs((int) (100.0 * (run - avg)/run) / 5); |
| 1651 | 1649 | ||
| 1652 | fprintf(output, " %17.*f (%+.*f) ", | 1650 | fprintf(output, " %17.*f (%+.*f) ", |
| @@ -1694,7 +1692,7 @@ static void print_footer(struct perf_stat_config *config) | |||
| 1694 | */ | 1692 | */ |
| 1695 | int precision = get_precision(sd) + 2; | 1693 | int precision = get_precision(sd) + 2; |
| 1696 | 1694 | ||
| 1697 | if (walltime_run_table) | 1695 | if (config->walltime_run_table) |
| 1698 | print_table(config, output, precision, avg); | 1696 | print_table(config, output, precision, avg); |
| 1699 | 1697 | ||
| 1700 | fprintf(output, " %17.*f +- %.*f seconds time elapsed", | 1698 | fprintf(output, " %17.*f +- %.*f seconds time elapsed", |
| @@ -1888,7 +1886,7 @@ static const struct option stat_options[] = { | |||
| 1888 | "be more verbose (show counter open errors, etc)"), | 1886 | "be more verbose (show counter open errors, etc)"), |
| 1889 | OPT_INTEGER('r', "repeat", &stat_config.run_count, | 1887 | OPT_INTEGER('r', "repeat", &stat_config.run_count, |
| 1890 | "repeat command and print average + stddev (max: 100, forever: 0)"), | 1888 | "repeat command and print average + stddev (max: 100, forever: 0)"), |
| 1891 | OPT_BOOLEAN(0, "table", &walltime_run_table, | 1889 | OPT_BOOLEAN(0, "table", &stat_config.walltime_run_table, |
| 1892 | "display details about each run (only with -r option)"), | 1890 | "display details about each run (only with -r option)"), |
| 1893 | OPT_BOOLEAN('n', "null", &stat_config.null_run, | 1891 | OPT_BOOLEAN('n', "null", &stat_config.null_run, |
| 1894 | "null run - dont start any counters"), | 1892 | "null run - dont start any counters"), |
| @@ -2802,7 +2800,7 @@ int cmd_stat(int argc, const char **argv) | |||
| 2802 | goto out; | 2800 | goto out; |
| 2803 | } | 2801 | } |
| 2804 | 2802 | ||
| 2805 | if (walltime_run_table && stat_config.run_count <= 1) { | 2803 | if (stat_config.walltime_run_table && stat_config.run_count <= 1) { |
| 2806 | fprintf(stderr, "--table is only supported with -r\n"); | 2804 | fprintf(stderr, "--table is only supported with -r\n"); |
| 2807 | parse_options_usage(stat_usage, stat_options, "r", 1); | 2805 | parse_options_usage(stat_usage, stat_options, "r", 1); |
| 2808 | parse_options_usage(NULL, stat_options, "table", 0); | 2806 | parse_options_usage(NULL, stat_options, "table", 0); |
| @@ -2870,9 +2868,9 @@ int cmd_stat(int argc, const char **argv) | |||
| 2870 | stat_config.run_count = 1; | 2868 | stat_config.run_count = 1; |
| 2871 | } | 2869 | } |
| 2872 | 2870 | ||
| 2873 | if (walltime_run_table) { | 2871 | if (stat_config.walltime_run_table) { |
| 2874 | walltime_run = zalloc(stat_config.run_count * sizeof(walltime_run[0])); | 2872 | stat_config.walltime_run = zalloc(stat_config.run_count * sizeof(stat_config.walltime_run[0])); |
| 2875 | if (!walltime_run) { | 2873 | if (!stat_config.walltime_run) { |
| 2876 | pr_err("failed to setup -r option"); | 2874 | pr_err("failed to setup -r option"); |
| 2877 | goto out; | 2875 | goto out; |
| 2878 | } | 2876 | } |
| @@ -3052,7 +3050,7 @@ int cmd_stat(int argc, const char **argv) | |||
| 3052 | perf_stat__exit_aggr_mode(); | 3050 | perf_stat__exit_aggr_mode(); |
| 3053 | perf_evlist__free_stats(evsel_list); | 3051 | perf_evlist__free_stats(evsel_list); |
| 3054 | out: | 3052 | out: |
| 3055 | free(walltime_run); | 3053 | free(stat_config.walltime_run); |
| 3056 | 3054 | ||
| 3057 | if (smi_cost && smi_reset) | 3055 | if (smi_cost && smi_reset) |
| 3058 | sysfs__write_int(FREEZE_ON_SMI_PATH, 0); | 3056 | sysfs__write_int(FREEZE_ON_SMI_PATH, 0); |
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 0758107fe56f..5193cbf6e4c6 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
| @@ -105,6 +105,7 @@ struct perf_stat_config { | |||
| 105 | bool ru_display; | 105 | bool ru_display; |
| 106 | bool big_num; | 106 | bool big_num; |
| 107 | bool no_merge; | 107 | bool no_merge; |
| 108 | bool walltime_run_table; | ||
| 108 | FILE *output; | 109 | FILE *output; |
| 109 | unsigned int interval; | 110 | unsigned int interval; |
| 110 | unsigned int timeout; | 111 | unsigned int timeout; |
| @@ -123,6 +124,7 @@ struct perf_stat_config { | |||
| 123 | struct cpu_map *aggr_map; | 124 | struct cpu_map *aggr_map; |
| 124 | aggr_get_id_t aggr_get_id; | 125 | aggr_get_id_t aggr_get_id; |
| 125 | struct cpu_map *cpus_aggr_map; | 126 | struct cpu_map *cpus_aggr_map; |
| 127 | u64 *walltime_run; | ||
| 126 | }; | 128 | }; |
| 127 | 129 | ||
| 128 | void update_stats(struct stats *stats, u64 val); | 130 | void update_stats(struct stats *stats, u64 val); |
