aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-11-05 09:40:54 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-12-17 14:00:33 -0500
commit7b60a7e3a687481553d2b6ec7e6390a6e82f1849 (patch)
tree843c5313ed5291065166ce458ce76d2c0d62cb05 /tools
parente9d6db8e8df42a38f79f264ab58c104e1678b12c (diff)
perf stat record: Synthesize event update events
Synthesize other events stuff not carried within attr event - unit, scale, name. Reported-by: Kan Liang <kan.liang@intel.com> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1446734469-11352-11-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-stat.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 10f86a6d7b15..575e2535ea03 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -351,8 +351,19 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf
351 workload_exec_errno = info->si_value.sival_int; 351 workload_exec_errno = info->si_value.sival_int;
352} 352}
353 353
354static bool has_unit(struct perf_evsel *counter)
355{
356 return counter->unit && *counter->unit;
357}
358
359static bool has_scale(struct perf_evsel *counter)
360{
361 return counter->scale != 1;
362}
363
354static int perf_stat_synthesize_config(bool is_pipe) 364static int perf_stat_synthesize_config(bool is_pipe)
355{ 365{
366 struct perf_evsel *counter;
356 int err; 367 int err;
357 368
358 if (is_pipe) { 369 if (is_pipe) {
@@ -364,6 +375,54 @@ static int perf_stat_synthesize_config(bool is_pipe)
364 } 375 }
365 } 376 }
366 377
378 /*
379 * Synthesize other events stuff not carried within
380 * attr event - unit, scale, name
381 */
382 evlist__for_each(evsel_list, counter) {
383 if (!counter->supported)
384 continue;
385
386 /*
387 * Synthesize unit and scale only if it's defined.
388 */
389 if (has_unit(counter)) {
390 err = perf_event__synthesize_event_update_unit(NULL, counter, process_synthesized_event);
391 if (err < 0) {
392 pr_err("Couldn't synthesize evsel unit.\n");
393 return err;
394 }
395 }
396
397 if (has_scale(counter)) {
398 err = perf_event__synthesize_event_update_scale(NULL, counter, process_synthesized_event);
399 if (err < 0) {
400 pr_err("Couldn't synthesize evsel scale.\n");
401 return err;
402 }
403 }
404
405 if (counter->own_cpus) {
406 err = perf_event__synthesize_event_update_cpus(NULL, counter, process_synthesized_event);
407 if (err < 0) {
408 pr_err("Couldn't synthesize evsel scale.\n");
409 return err;
410 }
411 }
412
413 /*
414 * Name is needed only for pipe output,
415 * perf.data carries event names.
416 */
417 if (is_pipe) {
418 err = perf_event__synthesize_event_update_name(NULL, counter, process_synthesized_event);
419 if (err < 0) {
420 pr_err("Couldn't synthesize evsel name.\n");
421 return err;
422 }
423 }
424 }
425
367 err = perf_event__synthesize_thread_map2(NULL, evsel_list->threads, 426 err = perf_event__synthesize_thread_map2(NULL, evsel_list->threads,
368 process_synthesized_event, 427 process_synthesized_event,
369 NULL); 428 NULL);