aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-02-02 14:35:07 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-02-11 10:37:08 -0500
commit23773ca18b399051eb94f98b689cf7a9173c795b (patch)
tree17629936892375049fd68b096389e8c24bc07a4a /tools/perf/util/util.c
parentdd6dda27a8be563eaebb3f38b1d1d50920bb7991 (diff)
perf tools: Make perf aware of tracefs
As tracefs may be mounted instead of debugfs to get to the event directories, have perf know about tracefs, and use that file system over debugfs if it is present. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20150202193553.340946602@goodmis.org [ Fixed up error messages about tracefs pointed out by Namhyung ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r--tools/perf/util/util.c60
1 files changed, 49 insertions, 11 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index b86744f29eef..92db3f156b63 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -303,13 +303,26 @@ void set_term_quiet_input(struct termios *old)
303 tcsetattr(0, TCSANOW, &tc); 303 tcsetattr(0, TCSANOW, &tc);
304} 304}
305 305
306static void set_tracing_events_path(const char *mountpoint) 306static void set_tracing_events_path(const char *tracing, const char *mountpoint)
307{ 307{
308 snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", 308 snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
309 mountpoint, "tracing/events"); 309 mountpoint, tracing, "events");
310} 310}
311 311
312const char *perf_debugfs_mount(const char *mountpoint) 312static const char *__perf_tracefs_mount(const char *mountpoint)
313{
314 const char *mnt;
315
316 mnt = tracefs_mount(mountpoint);
317 if (!mnt)
318 return NULL;
319
320 set_tracing_events_path("", mnt);
321
322 return mnt;
323}
324
325static const char *__perf_debugfs_mount(const char *mountpoint)
313{ 326{
314 const char *mnt; 327 const char *mnt;
315 328
@@ -317,7 +330,20 @@ const char *perf_debugfs_mount(const char *mountpoint)
317 if (!mnt) 330 if (!mnt)
318 return NULL; 331 return NULL;
319 332
320 set_tracing_events_path(mnt); 333 set_tracing_events_path("tracing/", mnt);
334
335 return mnt;
336}
337
338const char *perf_debugfs_mount(const char *mountpoint)
339{
340 const char *mnt;
341
342 mnt = __perf_tracefs_mount(mountpoint);
343 if (mnt)
344 return mnt;
345
346 mnt = __perf_debugfs_mount(mountpoint);
321 347
322 return mnt; 348 return mnt;
323} 349}
@@ -325,12 +351,19 @@ const char *perf_debugfs_mount(const char *mountpoint)
325void perf_debugfs_set_path(const char *mntpt) 351void perf_debugfs_set_path(const char *mntpt)
326{ 352{
327 snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt); 353 snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt);
328 set_tracing_events_path(mntpt); 354 set_tracing_events_path("tracing/", mntpt);
355}
356
357static const char *find_tracefs(void)
358{
359 const char *path = __perf_tracefs_mount(NULL);
360
361 return path;
329} 362}
330 363
331static const char *find_debugfs(void) 364static const char *find_debugfs(void)
332{ 365{
333 const char *path = perf_debugfs_mount(NULL); 366 const char *path = __perf_debugfs_mount(NULL);
334 367
335 if (!path) 368 if (!path)
336 fprintf(stderr, "Your kernel does not support the debugfs filesystem"); 369 fprintf(stderr, "Your kernel does not support the debugfs filesystem");
@@ -344,6 +377,7 @@ static const char *find_debugfs(void)
344 */ 377 */
345const char *find_tracing_dir(void) 378const char *find_tracing_dir(void)
346{ 379{
380 const char *tracing_dir = "";
347 static char *tracing; 381 static char *tracing;
348 static int tracing_found; 382 static int tracing_found;
349 const char *debugfs; 383 const char *debugfs;
@@ -351,11 +385,15 @@ const char *find_tracing_dir(void)
351 if (tracing_found) 385 if (tracing_found)
352 return tracing; 386 return tracing;
353 387
354 debugfs = find_debugfs(); 388 debugfs = find_tracefs();
355 if (!debugfs) 389 if (!debugfs) {
356 return NULL; 390 tracing_dir = "/tracing";
391 debugfs = find_debugfs();
392 if (!debugfs)
393 return NULL;
394 }
357 395
358 if (asprintf(&tracing, "%s/tracing", debugfs) < 0) 396 if (asprintf(&tracing, "%s%s", debugfs, tracing_dir) < 0)
359 return NULL; 397 return NULL;
360 398
361 tracing_found = 1; 399 tracing_found = 1;