aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2014-11-21 04:31:12 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-11-24 16:03:51 -0500
commit044330c1840e1ece97136d78a15484c867e2faaa (patch)
tree877360bb750795f59a84508b9b9c97c34f3880d5
parent011dccbdd93b7022c5c67e7c55fa8b5030b5e03d (diff)
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: Matt 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: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/evsel.h1
-rw-r--r--tools/perf/util/parse-events.c1
-rw-r--r--tools/perf/util/pmu.c27
-rw-r--r--tools/perf/util/pmu.h2
4 files changed, 31 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 5c93bed8e8d9..792b0ea8a8b8 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -91,6 +91,7 @@ struct perf_evsel {
91 bool immediate; 91 bool immediate;
92 bool system_wide; 92 bool system_wide;
93 bool tracking; 93 bool tracking;
94 bool per_pkg;
94 /* parse modifier helper */ 95 /* parse modifier helper */
95 int exclude_GH; 96 int exclude_GH;
96 int nr_members; 97 int nr_members;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index c659a3ca1283..5a373483f0e4 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -681,6 +681,7 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
681 if (evsel) { 681 if (evsel) {
682 evsel->unit = info.unit; 682 evsel->unit = info.unit;
683 evsel->scale = info.scale; 683 evsel->scale = info.scale;
684 evsel->per_pkg = info.per_pkg;
684 } 685 }
685 686
686 return evsel ? 0 : -ENOMEM; 687 return evsel ? 0 : -ENOMEM;
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 881b75490533..f003b5a9e059 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -163,6 +163,24 @@ error:
163 return -1; 163 return -1;
164} 164}
165 165
166static int
167perf_pmu__parse_per_pkg(struct perf_pmu_alias *alias, char *dir, char *name)
168{
169 char path[PATH_MAX];
170 int fd;
171
172 snprintf(path, PATH_MAX, "%s/%s.per-pkg", dir, name);
173
174 fd = open(path, O_RDONLY);
175 if (fd == -1)
176 return -1;
177
178 close(fd);
179
180 alias->per_pkg = true;
181 return 0;
182}
183
166static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file) 184static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file)
167{ 185{
168 struct perf_pmu_alias *alias; 186 struct perf_pmu_alias *alias;
@@ -181,6 +199,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
181 INIT_LIST_HEAD(&alias->terms); 199 INIT_LIST_HEAD(&alias->terms);
182 alias->scale = 1.0; 200 alias->scale = 1.0;
183 alias->unit[0] = '\0'; 201 alias->unit[0] = '\0';
202 alias->per_pkg = false;
184 203
185 ret = parse_events_terms(&alias->terms, buf); 204 ret = parse_events_terms(&alias->terms, buf);
186 if (ret) { 205 if (ret) {
@@ -194,6 +213,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
194 */ 213 */
195 perf_pmu__parse_unit(alias, dir, name); 214 perf_pmu__parse_unit(alias, dir, name);
196 perf_pmu__parse_scale(alias, dir, name); 215 perf_pmu__parse_scale(alias, dir, name);
216 perf_pmu__parse_per_pkg(alias, dir, name);
197 217
198 list_add_tail(&alias->list, list); 218 list_add_tail(&alias->list, list);
199 219
@@ -209,6 +229,8 @@ static inline bool pmu_alias_info_file(char *name)
209 return true; 229 return true;
210 if (len > 6 && !strcmp(name + len - 6, ".scale")) 230 if (len > 6 && !strcmp(name + len - 6, ".scale"))
211 return true; 231 return true;
232 if (len > 8 && !strcmp(name + len - 8, ".per-pkg"))
233 return true;
212 234
213 return false; 235 return false;
214} 236}
@@ -649,6 +671,8 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
649 struct perf_pmu_alias *alias; 671 struct perf_pmu_alias *alias;
650 int ret; 672 int ret;
651 673
674 info->per_pkg = false;
675
652 /* 676 /*
653 * Mark unit and scale as not set 677 * Mark unit and scale as not set
654 * (different from default values, see below) 678 * (different from default values, see below)
@@ -668,6 +692,9 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
668 if (ret) 692 if (ret)
669 return ret; 693 return ret;
670 694
695 if (alias->per_pkg)
696 info->per_pkg = true;
697
671 list_del(&term->list); 698 list_del(&term->list);
672 free(term); 699 free(term);
673 } 700 }
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 8092de78e818..c3a74e0e17a2 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -29,6 +29,7 @@ struct perf_pmu {
29struct perf_pmu_info { 29struct perf_pmu_info {
30 const char *unit; 30 const char *unit;
31 double scale; 31 double scale;
32 bool per_pkg;
32}; 33};
33 34
34#define UNIT_MAX_LEN 31 /* max length for event unit name */ 35#define UNIT_MAX_LEN 31 /* max length for event unit name */
@@ -39,6 +40,7 @@ struct perf_pmu_alias {
39 struct list_head list; /* ELEM */ 40 struct list_head list; /* ELEM */
40 char unit[UNIT_MAX_LEN+1]; 41 char unit[UNIT_MAX_LEN+1];
41 double scale; 42 double scale;
43 bool per_pkg;
42}; 44};
43 45
44struct perf_pmu *perf_pmu__find(const char *name); 46struct perf_pmu *perf_pmu__find(const char *name);