|
@@ -163,6 +163,41 @@ error:
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int
|
|
|
|
+perf_pmu__parse_per_pkg(struct perf_pmu_alias *alias, char *dir, char *name)
|
|
|
|
+{
|
|
|
|
+ char path[PATH_MAX];
|
|
|
|
+ int fd;
|
|
|
|
+
|
|
|
|
+ snprintf(path, PATH_MAX, "%s/%s.per-pkg", dir, name);
|
|
|
|
+
|
|
|
|
+ fd = open(path, O_RDONLY);
|
|
|
|
+ if (fd == -1)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ close(fd);
|
|
|
|
+
|
|
|
|
+ alias->per_pkg = true;
|
|
|
|
+ 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;
|
|
@@ -181,6 +216,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
|
|
INIT_LIST_HEAD(&alias->terms);
|
|
INIT_LIST_HEAD(&alias->terms);
|
|
alias->scale = 1.0;
|
|
alias->scale = 1.0;
|
|
alias->unit[0] = '\0';
|
|
alias->unit[0] = '\0';
|
|
|
|
+ alias->per_pkg = false;
|
|
|
|
|
|
ret = parse_events_terms(&alias->terms, buf);
|
|
ret = parse_events_terms(&alias->terms, buf);
|
|
if (ret) {
|
|
if (ret) {
|
|
@@ -194,6 +230,8 @@ 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_snapshot(alias, dir, name);
|
|
|
|
|
|
list_add_tail(&alias->list, list);
|
|
list_add_tail(&alias->list, list);
|
|
|
|
|
|
@@ -209,6 +247,10 @@ static inline bool pmu_alias_info_file(char *name)
|
|
return true;
|
|
return true;
|
|
if (len > 6 && !strcmp(name + len - 6, ".scale"))
|
|
if (len > 6 && !strcmp(name + len - 6, ".scale"))
|
|
return true;
|
|
return true;
|
|
|
|
+ if (len > 8 && !strcmp(name + len - 8, ".per-pkg"))
|
|
|
|
+ return true;
|
|
|
|
+ if (len > 9 && !strcmp(name + len - 9, ".snapshot"))
|
|
|
|
+ return true;
|
|
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -617,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,
|
|
|
|
- const char **unit, double *scale)
|
|
|
|
|
|
+static int check_info_data(struct perf_pmu_alias *alias,
|
|
|
|
+ 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
|
|
|
|
- * more than one.
|
|
|
|
|
|
+ * define unit, scale and snapshot, fail
|
|
|
|
+ * if there's more than one.
|
|
*/
|
|
*/
|
|
- if ((*unit && alias->unit) ||
|
|
|
|
- (*scale && alias->scale))
|
|
|
|
|
|
+ if ((info->unit && alias->unit) ||
|
|
|
|
+ (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;
|
|
}
|
|
}
|
|
@@ -649,12 +695,15 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
|
|
struct perf_pmu_alias *alias;
|
|
struct perf_pmu_alias *alias;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
+ info->per_pkg = false;
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Mark unit and scale as not set
|
|
* Mark unit and scale as not set
|
|
* (different from default values, see below)
|
|
* (different from default values, see below)
|
|
*/
|
|
*/
|
|
- info->unit = NULL;
|
|
|
|
- info->scale = 0.0;
|
|
|
|
|
|
+ info->unit = NULL;
|
|
|
|
+ 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);
|
|
@@ -664,10 +713,13 @@ 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;
|
|
|
|
|
|
|
|
+ if (alias->per_pkg)
|
|
|
|
+ info->per_pkg = true;
|
|
|
|
+
|
|
list_del(&term->list);
|
|
list_del(&term->list);
|
|
free(term);
|
|
free(term);
|
|
}
|
|
}
|