Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 044330c1 authored by Matt Fleming's avatar Matt Fleming Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Add per-pkg format file parsing

The .per-pkg file indicates that all but one value per socket should be
discarded. Adding support to check up this file and set event flag
accordingly.

This patch is part of Matt's original patch:

http://marc.info/?l=linux-kernel&m=141527675002139&w=2

 only the file
parsing part, the rest is solved differently.

Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
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: Jiri Olsa <jolsa@kernel.org>
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-9-git-send-email-jolsa@kernel.org


Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 011dccbd
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,7 @@ struct perf_evsel {
	bool			immediate;
	bool			immediate;
	bool			system_wide;
	bool			system_wide;
	bool			tracking;
	bool			tracking;
	bool			per_pkg;
	/* parse modifier helper */
	/* parse modifier helper */
	int			exclude_GH;
	int			exclude_GH;
	int			nr_members;
	int			nr_members;
+1 −0
Original line number Original line Diff line number Diff line
@@ -681,6 +681,7 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
	if (evsel) {
	if (evsel) {
		evsel->unit = info.unit;
		evsel->unit = info.unit;
		evsel->scale = info.scale;
		evsel->scale = info.scale;
		evsel->per_pkg = info.per_pkg;
	}
	}


	return evsel ? 0 : -ENOMEM;
	return evsel ? 0 : -ENOMEM;
+27 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,24 @@ static int perf_pmu__parse_unit(struct perf_pmu_alias *alias, char *dir, char *n
	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__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 +199,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 +213,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);


	list_add_tail(&alias->list, list);
	list_add_tail(&alias->list, list);


@@ -209,6 +229,8 @@ 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;


	return false;
	return false;
}
}
@@ -649,6 +671,8 @@ 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)
@@ -668,6 +692,9 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
		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);
	}
	}
+2 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ struct perf_pmu {
struct perf_pmu_info {
struct perf_pmu_info {
	const char *unit;
	const char *unit;
	double scale;
	double scale;
	bool per_pkg;
};
};


#define UNIT_MAX_LEN	31 /* max length for event unit name */
#define UNIT_MAX_LEN	31 /* max length for event unit name */
@@ -39,6 +40,7 @@ struct perf_pmu_alias {
	struct list_head list;  /* ELEM */
	struct list_head list;  /* ELEM */
	char unit[UNIT_MAX_LEN+1];
	char unit[UNIT_MAX_LEN+1];
	double scale;
	double scale;
	bool per_pkg;
};
};


struct perf_pmu *perf_pmu__find(const char *name);
struct perf_pmu *perf_pmu__find(const char *name);