Commit 1d9e446b authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tools: Add snapshot format file parsing

The .snapshot file indicates that the provided event value is a snapshot
value and we have to bypass the delta computation logic.

Adding support to check up this file and set event flag accordingly.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Matt Fleming <matt.fleming@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1416562275-12404-10-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 044330c1
...@@ -73,6 +73,7 @@ struct perf_evsel { ...@@ -73,6 +73,7 @@ struct perf_evsel {
char *name; char *name;
double scale; double scale;
const char *unit; const char *unit;
bool snapshot;
struct event_format *tp_format; struct event_format *tp_format;
union { union {
void *priv; void *priv;
......
...@@ -682,6 +682,7 @@ int parse_events_add_pmu(struct list_head *list, int *idx, ...@@ -682,6 +682,7 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
evsel->unit = info.unit; evsel->unit = info.unit;
evsel->scale = info.scale; evsel->scale = info.scale;
evsel->per_pkg = info.per_pkg; evsel->per_pkg = info.per_pkg;
evsel->snapshot = info.snapshot;
} }
return evsel ? 0 : -ENOMEM; return evsel ? 0 : -ENOMEM;
......
...@@ -181,6 +181,23 @@ perf_pmu__parse_per_pkg(struct perf_pmu_alias *alias, char *dir, char *name) ...@@ -181,6 +181,23 @@ perf_pmu__parse_per_pkg(struct perf_pmu_alias *alias, char *dir, char *name)
return 0; return 0;
} }
static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
char *dir, char *name)
{
char path[PATH_MAX];
int fd;
snprintf(path, PATH_MAX, "%s/%s.snapshot", dir, name);
fd = open(path, O_RDONLY);
if (fd == -1)
return -1;
alias->snapshot = true;
close(fd);
return 0;
}
static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file) static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file)
{ {
struct perf_pmu_alias *alias; struct perf_pmu_alias *alias;
...@@ -214,6 +231,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI ...@@ -214,6 +231,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
perf_pmu__parse_unit(alias, dir, name); perf_pmu__parse_unit(alias, dir, name);
perf_pmu__parse_scale(alias, dir, name); perf_pmu__parse_scale(alias, dir, name);
perf_pmu__parse_per_pkg(alias, dir, name); perf_pmu__parse_per_pkg(alias, dir, name);
perf_pmu__parse_snapshot(alias, dir, name);
list_add_tail(&alias->list, list); list_add_tail(&alias->list, list);
...@@ -231,6 +249,8 @@ static inline bool pmu_alias_info_file(char *name) ...@@ -231,6 +249,8 @@ static inline bool pmu_alias_info_file(char *name)
return true; return true;
if (len > 8 && !strcmp(name + len - 8, ".per-pkg")) if (len > 8 && !strcmp(name + len - 8, ".per-pkg"))
return true; return true;
if (len > 9 && !strcmp(name + len - 9, ".snapshot"))
return true;
return false; return false;
} }
...@@ -639,23 +659,27 @@ static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu, ...@@ -639,23 +659,27 @@ static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu,
} }
static int check_unit_scale(struct perf_pmu_alias *alias, static int check_info_data(struct perf_pmu_alias *alias,
const char **unit, double *scale) struct perf_pmu_info *info)
{ {
/* /*
* Only one term in event definition can * Only one term in event definition can
* define unit and scale, fail if there's * define unit, scale and snapshot, fail
* more than one. * if there's more than one.
*/ */
if ((*unit && alias->unit) || if ((info->unit && alias->unit) ||
(*scale && alias->scale)) (info->scale && alias->scale) ||
(info->snapshot && alias->snapshot))
return -EINVAL; return -EINVAL;
if (alias->unit) if (alias->unit)
*unit = alias->unit; info->unit = alias->unit;
if (alias->scale) if (alias->scale)
*scale = alias->scale; info->scale = alias->scale;
if (alias->snapshot)
info->snapshot = alias->snapshot;
return 0; return 0;
} }
...@@ -679,6 +703,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, ...@@ -679,6 +703,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
*/ */
info->unit = NULL; info->unit = NULL;
info->scale = 0.0; info->scale = 0.0;
info->snapshot = false;
list_for_each_entry_safe(term, h, head_terms, list) { list_for_each_entry_safe(term, h, head_terms, list) {
alias = pmu_find_alias(pmu, term); alias = pmu_find_alias(pmu, term);
...@@ -688,7 +713,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, ...@@ -688,7 +713,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
if (ret) if (ret)
return ret; return ret;
ret = check_unit_scale(alias, &info->unit, &info->scale); ret = check_info_data(alias, info);
if (ret) if (ret)
return ret; return ret;
......
...@@ -30,6 +30,7 @@ struct perf_pmu_info { ...@@ -30,6 +30,7 @@ struct perf_pmu_info {
const char *unit; const char *unit;
double scale; double scale;
bool per_pkg; bool per_pkg;
bool snapshot;
}; };
#define UNIT_MAX_LEN 31 /* max length for event unit name */ #define UNIT_MAX_LEN 31 /* max length for event unit name */
...@@ -41,6 +42,7 @@ struct perf_pmu_alias { ...@@ -41,6 +42,7 @@ struct perf_pmu_alias {
char unit[UNIT_MAX_LEN+1]; char unit[UNIT_MAX_LEN+1];
double scale; double scale;
bool per_pkg; bool per_pkg;
bool snapshot;
}; };
struct perf_pmu *perf_pmu__find(const char *name); struct perf_pmu *perf_pmu__find(const char *name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment