aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2013-11-05 12:48:50 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-05 13:15:00 -0500
commitcf38fadade52df937521dd70d4437df1a9354cd9 (patch)
treee40d0b9b949de86c395bd189b9810790b28edc69 /tools
parent4299a549979783668d787959d61ba22b6b200877 (diff)
perf fs: Rename NAME_find_mountpoint() to NAME__mountpoint()
Shorten it, "finding" it is an implementation detail, what callers want is the pathname, not to ask for it to _always_ do the lookup. And the existing implementation already caches it, i.e. it doesn't "finds" it on every call. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-r24wa4bvtccg7mnkessrbbdj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/tests/parse-events.c4
-rw-r--r--tools/perf/util/cpumap.c4
-rw-r--r--tools/perf/util/fs.c12
-rw-r--r--tools/perf/util/fs.h2
-rw-r--r--tools/perf/util/pmu.c15
5 files changed, 16 insertions, 21 deletions
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index f47bf459c3f5..ef671cd41bb3 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1456,7 +1456,7 @@ static int test_pmu(void)
1456 int ret; 1456 int ret;
1457 1457
1458 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", 1458 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
1459 sysfs_find_mountpoint()); 1459 sysfs__mountpoint());
1460 1460
1461 ret = stat(path, &st); 1461 ret = stat(path, &st);
1462 if (ret) 1462 if (ret)
@@ -1473,7 +1473,7 @@ static int test_pmu_events(void)
1473 int ret; 1473 int ret;
1474 1474
1475 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", 1475 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
1476 sysfs_find_mountpoint()); 1476 sysfs__mountpoint());
1477 1477
1478 ret = stat(path, &st); 1478 ret = stat(path, &st);
1479 if (ret) { 1479 if (ret) {
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 4af5a23b2423..a9b48c42e81e 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -216,7 +216,7 @@ int cpu_map__get_socket(struct cpu_map *map, int idx)
216 216
217 cpu = map->map[idx]; 217 cpu = map->map[idx];
218 218
219 mnt = sysfs_find_mountpoint(); 219 mnt = sysfs__mountpoint();
220 if (!mnt) 220 if (!mnt)
221 return -1; 221 return -1;
222 222
@@ -279,7 +279,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx)
279 279
280 cpu = map->map[idx]; 280 cpu = map->map[idx];
281 281
282 mnt = sysfs_find_mountpoint(); 282 mnt = sysfs__mountpoint();
283 if (!mnt) 283 if (!mnt)
284 return -1; 284 return -1;
285 285
diff --git a/tools/perf/util/fs.c b/tools/perf/util/fs.c
index a2413e842a02..77bac4e4c115 100644
--- a/tools/perf/util/fs.c
+++ b/tools/perf/util/fs.c
@@ -88,7 +88,7 @@ static const char *fs__get_mountpoint(struct fs *fs)
88 return fs__read_mounts(fs) ? fs->path : NULL; 88 return fs__read_mounts(fs) ? fs->path : NULL;
89} 89}
90 90
91static const char *fs__find_mountpoint(int idx) 91static const char *fs__mountpoint(int idx)
92{ 92{
93 struct fs *fs = &fs__entries[idx]; 93 struct fs *fs = &fs__entries[idx];
94 94
@@ -98,10 +98,10 @@ static const char *fs__find_mountpoint(int idx)
98 return fs__get_mountpoint(fs); 98 return fs__get_mountpoint(fs);
99} 99}
100 100
101#define FIND_MOUNTPOINT(name, idx) \ 101#define FS__MOUNTPOINT(name, idx) \
102const char *name##_find_mountpoint(void) \ 102const char *name##__mountpoint(void) \
103{ \ 103{ \
104 return fs__find_mountpoint(idx); \ 104 return fs__mountpoint(idx); \
105} 105}
106 106
107FIND_MOUNTPOINT(sysfs, FS__SYSFS); 107FS__MOUNTPOINT(sysfs, FS__SYSFS);
diff --git a/tools/perf/util/fs.h b/tools/perf/util/fs.h
index 082edbd2159b..a7561c83c33c 100644
--- a/tools/perf/util/fs.h
+++ b/tools/perf/util/fs.h
@@ -1,6 +1,6 @@
1#ifndef __PERF_FS 1#ifndef __PERF_FS
2#define __PERF_FS 2#define __PERF_FS
3 3
4const char *sysfs_find_mountpoint(void); 4const char *sysfs__mountpoint(void);
5 5
6#endif /* __PERF_FS */ 6#endif /* __PERF_FS */
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 45b42dffcd70..c232d8dd410b 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -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