diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-10-25 15:51:28 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-12-17 18:38:19 +0100 |
commit | 6742434261158ad9678bf15b165304e0200cc324 (patch) | |
tree | 3a48df11cbb597dcbe5e56fdfe59875023bb55fc /tools/perf/util/event.c | |
parent | perf tools: Add stat config user level event (diff) | |
download | linux-6742434261158ad9678bf15b165304e0200cc324.tar.xz linux-6742434261158ad9678bf15b165304e0200cc324.zip |
perf tools: Add stat config event synthesize function
Introduce the perf_event__synthesize_stat_config to synthesize a 'struct
perf_stat_config'.
Storing the stat config in the form of tag-value pairs will, I believe,
sort out future version extensibility issues.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Kan Liang <kan.liang@intel.com>
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/1445784728-21732-13-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r-- | tools/perf/util/event.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 43e2dfc2c73b..1ea693c2a14b 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -10,6 +10,8 @@ #include "thread.h" #include "thread_map.h" #include "symbol/kallsyms.h" +#include "asm/bug.h" +#include "stat.h" static const char *perf_event__names[] = { [0] = "TOTAL", @@ -869,6 +871,44 @@ int perf_event__synthesize_cpu_map(struct perf_tool *tool, return err; } +int perf_event__synthesize_stat_config(struct perf_tool *tool, + struct perf_stat_config *config, + perf_event__handler_t process, + struct machine *machine) +{ + struct stat_config_event *event; + int size, i = 0, err; + + size = sizeof(*event); + size += (PERF_STAT_CONFIG_TERM__MAX * sizeof(event->data[0])); + + event = zalloc(size); + if (!event) + return -ENOMEM; + + event->header.type = PERF_RECORD_STAT_CONFIG; + event->header.size = size; + event->nr = PERF_STAT_CONFIG_TERM__MAX; + +#define ADD(__term, __val) \ + event->data[i].tag = PERF_STAT_CONFIG_TERM__##__term; \ + event->data[i].val = __val; \ + i++; + + ADD(AGGR_MODE, config->aggr_mode) + ADD(INTERVAL, config->interval) + ADD(SCALE, config->scale) + + WARN_ONCE(i != PERF_STAT_CONFIG_TERM__MAX, + "stat config terms unbalanced\n"); +#undef ADD + + err = process(tool, (union perf_event *) event, NULL, machine); + + free(event); + return err; +} + size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp) { const char *s; |