diff options
author | Ingo Molnar <mingo@elte.hu> | 2011-04-26 22:36:37 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-04-26 14:04:56 -0400 |
commit | dcd9936a5a6d89512b5323c1145647f2dbe0236f (patch) | |
tree | 5ad83bc4f2a61e5ff65d4d0950cee6a36b65696d /tools | |
parent | 749141d926faf23ef811686a8050e7cf13dc223f (diff) |
perf stat: Factor our shadow stats
Create update_shadow_stats() which is then used in both read_counter_aggr()
and read_counter().
This not only simplifies the code but also fixes a bug: HW_CACHE_REFERENCES
was not updated in read_counter().
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/n/tip-9uc55z3g88r47exde7zxjm6p@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-stat.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 0de3a2002f49..e5e82f62c784 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -194,6 +194,23 @@ static inline int nsec_counter(struct perf_evsel *evsel) | |||
194 | } | 194 | } |
195 | 195 | ||
196 | /* | 196 | /* |
197 | * Update various tracking values we maintain to print | ||
198 | * more semantic information such as miss/hit ratios, | ||
199 | * instruction rates, etc: | ||
200 | */ | ||
201 | static void update_shadow_stats(struct perf_evsel *counter, u64 *count) | ||
202 | { | ||
203 | if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK)) | ||
204 | update_stats(&runtime_nsecs_stats[0], count[0]); | ||
205 | else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) | ||
206 | update_stats(&runtime_cycles_stats[0], count[0]); | ||
207 | else if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS)) | ||
208 | update_stats(&runtime_branches_stats[0], count[0]); | ||
209 | else if (perf_evsel__match(counter, HARDWARE, HW_CACHE_REFERENCES)) | ||
210 | update_stats(&runtime_cacherefs_stats[0], count[0]); | ||
211 | } | ||
212 | |||
213 | /* | ||
197 | * Read out the results of a single counter: | 214 | * Read out the results of a single counter: |
198 | * aggregate counts across CPUs in system-wide mode | 215 | * aggregate counts across CPUs in system-wide mode |
199 | */ | 216 | */ |
@@ -218,14 +235,7 @@ static int read_counter_aggr(struct perf_evsel *counter) | |||
218 | /* | 235 | /* |
219 | * Save the full runtime - to allow normalization during printout: | 236 | * Save the full runtime - to allow normalization during printout: |
220 | */ | 237 | */ |
221 | if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK)) | 238 | update_shadow_stats(counter, count); |
222 | update_stats(&runtime_nsecs_stats[0], count[0]); | ||
223 | else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) | ||
224 | update_stats(&runtime_cycles_stats[0], count[0]); | ||
225 | else if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS)) | ||
226 | update_stats(&runtime_branches_stats[0], count[0]); | ||
227 | else if (perf_evsel__match(counter, HARDWARE, HW_CACHE_REFERENCES)) | ||
228 | update_stats(&runtime_cacherefs_stats[0], count[0]); | ||
229 | 239 | ||
230 | return 0; | 240 | return 0; |
231 | } | 241 | } |
@@ -245,12 +255,7 @@ static int read_counter(struct perf_evsel *counter) | |||
245 | 255 | ||
246 | count = counter->counts->cpu[cpu].values; | 256 | count = counter->counts->cpu[cpu].values; |
247 | 257 | ||
248 | if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK)) | 258 | update_shadow_stats(counter, count); |
249 | update_stats(&runtime_nsecs_stats[cpu], count[0]); | ||
250 | if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) | ||
251 | update_stats(&runtime_cycles_stats[cpu], count[0]); | ||
252 | if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS)) | ||
253 | update_stats(&runtime_branches_stats[cpu], count[0]); | ||
254 | } | 259 | } |
255 | 260 | ||
256 | return 0; | 261 | return 0; |