aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/pmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/pmu.c')
-rw-r--r--tools/perf/util/pmu.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index bc9d8069d376..c232d8dd410b 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -4,7 +4,7 @@
4#include <unistd.h> 4#include <unistd.h>
5#include <stdio.h> 5#include <stdio.h>
6#include <dirent.h> 6#include <dirent.h>
7#include "sysfs.h" 7#include "fs.h"
8#include "util.h" 8#include "util.h"
9#include "pmu.h" 9#include "pmu.h"
10#include "parse-events.h" 10#include "parse-events.h"
@@ -77,9 +77,8 @@ static int pmu_format(const char *name, struct list_head *format)
77{ 77{
78 struct stat st; 78 struct stat st;
79 char path[PATH_MAX]; 79 char path[PATH_MAX];
80 const char *sysfs; 80 const char *sysfs = sysfs__mountpoint();
81 81
82 sysfs = sysfs_find_mountpoint();
83 if (!sysfs) 82 if (!sysfs)
84 return -1; 83 return -1;
85 84
@@ -166,9 +165,8 @@ static int pmu_aliases(const char *name, struct list_head *head)
166{ 165{
167 struct stat st; 166 struct stat st;
168 char path[PATH_MAX]; 167 char path[PATH_MAX];
169 const char *sysfs; 168 const char *sysfs = sysfs__mountpoint();
170 169
171 sysfs = sysfs_find_mountpoint();
172 if (!sysfs) 170 if (!sysfs)
173 return -1; 171 return -1;
174 172
@@ -212,11 +210,10 @@ static int pmu_type(const char *name, __u32 *type)
212{ 210{
213 struct stat st; 211 struct stat st;
214 char path[PATH_MAX]; 212 char path[PATH_MAX];
215 const char *sysfs;
216 FILE *file; 213 FILE *file;
217 int ret = 0; 214 int ret = 0;
215 const char *sysfs = sysfs__mountpoint();
218 216
219 sysfs = sysfs_find_mountpoint();
220 if (!sysfs) 217 if (!sysfs)
221 return -1; 218 return -1;
222 219
@@ -241,11 +238,10 @@ static int pmu_type(const char *name, __u32 *type)
241static void pmu_read_sysfs(void) 238static void pmu_read_sysfs(void)
242{ 239{
243 char path[PATH_MAX]; 240 char path[PATH_MAX];
244 const char *sysfs;
245 DIR *dir; 241 DIR *dir;
246 struct dirent *dent; 242 struct dirent *dent;
243 const char *sysfs = sysfs__mountpoint();
247 244
248 sysfs = sysfs_find_mountpoint();
249 if (!sysfs) 245 if (!sysfs)
250 return; 246 return;
251 247
@@ -270,11 +266,10 @@ static struct cpu_map *pmu_cpumask(const char *name)
270{ 266{
271 struct stat st; 267 struct stat st;
272 char path[PATH_MAX]; 268 char path[PATH_MAX];
273 const char *sysfs;
274 FILE *file; 269 FILE *file;
275 struct cpu_map *cpus; 270 struct cpu_map *cpus;
271 const char *sysfs = sysfs__mountpoint();
276 272
277 sysfs = sysfs_find_mountpoint();
278 if (!sysfs) 273 if (!sysfs)
279 return NULL; 274 return NULL;
280 275
@@ -637,3 +632,19 @@ void print_pmu_events(const char *event_glob, bool name_only)
637 printf("\n"); 632 printf("\n");
638 free(aliases); 633 free(aliases);
639} 634}
635
636bool pmu_have_event(const char *pname, const char *name)
637{
638 struct perf_pmu *pmu;
639 struct perf_pmu_alias *alias;
640
641 pmu = NULL;
642 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
643 if (strcmp(pname, pmu->name))
644 continue;
645 list_for_each_entry(alias, &pmu->aliases, list)
646 if (!strcmp(alias->name, name))
647 return true;
648 }
649 return false;
650}