diff options
author | Andi Kleen <ak@linux.intel.com> | 2014-03-25 13:31:38 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@redhat.com> | 2014-04-14 06:56:06 -0400 |
commit | 90f6bb6c98ffef42125d7be6d4612505f561fbce (patch) | |
tree | ced6c6aec5b237776dc76df8b63d4c5912a00ebe | |
parent | 40ba93e3aa001246110320edbe8cf2eb488c1fe7 (diff) |
perf stat: Initialize statistics correctly
perf stat did initialize the stats structure used to compute
stddev etc. incorrectly. It merely zeroes it. But one member
(min) needs to be set to a non zero value. This causes min
to be not computed at all. Call init_stats() correctly.
It doesn't matter for stat currently because it doesn't use
min, but it's still better to do it correctly.
The other users of statistics are already correct.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1395768699-16060-1-git-send-email-andi@firstfloor.org
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
-rw-r--r-- | tools/perf/builtin-stat.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 8b0e1c9234d9..65a151e36067 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -174,13 +174,20 @@ static inline int perf_evsel__nr_cpus(struct perf_evsel *evsel) | |||
174 | 174 | ||
175 | static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) | 175 | static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) |
176 | { | 176 | { |
177 | memset(evsel->priv, 0, sizeof(struct perf_stat)); | 177 | int i; |
178 | struct perf_stat *ps = evsel->priv; | ||
179 | |||
180 | for (i = 0; i < 3; i++) | ||
181 | init_stats(&ps->res_stats[i]); | ||
178 | } | 182 | } |
179 | 183 | ||
180 | static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel) | 184 | static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel) |
181 | { | 185 | { |
182 | evsel->priv = zalloc(sizeof(struct perf_stat)); | 186 | evsel->priv = zalloc(sizeof(struct perf_stat)); |
183 | return evsel->priv == NULL ? -ENOMEM : 0; | 187 | if (evsel == NULL) |
188 | return -ENOMEM; | ||
189 | perf_evsel__reset_stat_priv(evsel); | ||
190 | return 0; | ||
184 | } | 191 | } |
185 | 192 | ||
186 | static void perf_evsel__free_stat_priv(struct perf_evsel *evsel) | 193 | static void perf_evsel__free_stat_priv(struct perf_evsel *evsel) |