aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/tests/open-syscall-all-cpus.c7
-rw-r--r--tools/perf/tests/open-syscall.c7
-rw-r--r--tools/perf/tests/parse-events.c13
-rw-r--r--tools/perf/util/cache.h1
-rw-r--r--tools/perf/util/evlist.c1
-rw-r--r--tools/perf/util/parse-events.h2
-rw-r--r--tools/perf/util/probe-event.c24
-rw-r--r--tools/perf/util/util.c60
-rw-r--r--tools/perf/util/util.h1
9 files changed, 91 insertions, 25 deletions
diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c
index 8fa82d1700c7..3ec885c48f8f 100644
--- a/tools/perf/tests/open-syscall-all-cpus.c
+++ b/tools/perf/tests/open-syscall-all-cpus.c
@@ -29,7 +29,12 @@ int test__open_syscall_event_on_all_cpus(void)
29 29
30 evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); 30 evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
31 if (evsel == NULL) { 31 if (evsel == NULL) {
32 pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); 32 if (tracefs_configured())
33 pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
34 else if (debugfs_configured())
35 pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
36 else
37 pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
33 goto out_thread_map_delete; 38 goto out_thread_map_delete;
34 } 39 }
35 40
diff --git a/tools/perf/tests/open-syscall.c b/tools/perf/tests/open-syscall.c
index a33b2daae40f..07aa319bf334 100644
--- a/tools/perf/tests/open-syscall.c
+++ b/tools/perf/tests/open-syscall.c
@@ -18,7 +18,12 @@ int test__open_syscall_event(void)
18 18
19 evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); 19 evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
20 if (evsel == NULL) { 20 if (evsel == NULL) {
21 pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); 21 if (tracefs_configured())
22 pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
23 else if (debugfs_configured())
24 pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
25 else
26 pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
22 goto out_thread_map_delete; 27 goto out_thread_map_delete;
23 } 28 }
24 29
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 1cdab0ce00e2..ac243ebcb20a 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -3,6 +3,7 @@
3#include "evsel.h" 3#include "evsel.h"
4#include "evlist.h" 4#include "evlist.h"
5#include <api/fs/fs.h> 5#include <api/fs/fs.h>
6#include <api/fs/tracefs.h>
6#include <api/fs/debugfs.h> 7#include <api/fs/debugfs.h>
7#include "tests.h" 8#include "tests.h"
8#include "debug.h" 9#include "debug.h"
@@ -1192,11 +1193,19 @@ static int count_tracepoints(void)
1192{ 1193{
1193 char events_path[PATH_MAX]; 1194 char events_path[PATH_MAX];
1194 struct dirent *events_ent; 1195 struct dirent *events_ent;
1196 const char *mountpoint;
1195 DIR *events_dir; 1197 DIR *events_dir;
1196 int cnt = 0; 1198 int cnt = 0;
1197 1199
1198 scnprintf(events_path, PATH_MAX, "%s/tracing/events", 1200 mountpoint = tracefs_find_mountpoint();
1199 debugfs_find_mountpoint()); 1201 if (mountpoint) {
1202 scnprintf(events_path, PATH_MAX, "%s/events",
1203 mountpoint);
1204 } else {
1205 mountpoint = debugfs_find_mountpoint();
1206 scnprintf(events_path, PATH_MAX, "%s/tracing/events",
1207 mountpoint);
1208 }
1200 1209
1201 events_dir = opendir(events_path); 1210 events_dir = opendir(events_path);
1202 1211
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index d04d770d90f6..fbcca21d66ab 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -17,6 +17,7 @@
17#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH" 17#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
18#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf" 18#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
19#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" 19#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
20#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
20 21
21typedef int (*config_fn_t)(const char *, const char *, void *); 22typedef int (*config_fn_t)(const char *, const char *, void *);
22extern int perf_default_config(const char *, const char *, void *); 23extern int perf_default_config(const char *, const char *, void *);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index c602ebb5b991..a8b2c5726aba 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -7,7 +7,6 @@
7 * Released under the GPL v2. (and only v2, not any later version) 7 * Released under the GPL v2. (and only v2, not any later version)
8 */ 8 */
9#include "util.h" 9#include "util.h"
10#include <api/fs/debugfs.h>
11#include <api/fs/fs.h> 10#include <api/fs/fs.h>
12#include <poll.h> 11#include <poll.h>
13#include "cpumap.h" 12#include "cpumap.h"
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index ff6e1fa4111e..39c3b57965d1 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -122,6 +122,6 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
122int print_hwcache_events(const char *event_glob, bool name_only); 122int print_hwcache_events(const char *event_glob, bool name_only);
123extern int is_valid_tracepoint(const char *event_string); 123extern int is_valid_tracepoint(const char *event_string);
124 124
125extern int valid_debugfs_mount(const char *debugfs); 125int valid_event_mount(const char *eventfs);
126 126
127#endif /* __PERF_PARSE_EVENTS_H */ 127#endif /* __PERF_PARSE_EVENTS_H */
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 919937eb0be2..9dfbed96bf39 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -41,6 +41,7 @@
41#include "symbol.h" 41#include "symbol.h"
42#include "thread.h" 42#include "thread.h"
43#include <api/fs/debugfs.h> 43#include <api/fs/debugfs.h>
44#include <api/fs/tracefs.h>
44#include "trace-event.h" /* For __maybe_unused */ 45#include "trace-event.h" /* For __maybe_unused */
45#include "probe-event.h" 46#include "probe-event.h"
46#include "probe-finder.h" 47#include "probe-finder.h"
@@ -1805,7 +1806,7 @@ static void print_open_warning(int err, bool is_kprobe)
1805 " - please rebuild kernel with %s.\n", 1806 " - please rebuild kernel with %s.\n",
1806 is_kprobe ? 'k' : 'u', config); 1807 is_kprobe ? 'k' : 'u', config);
1807 } else if (err == -ENOTSUP) 1808 } else if (err == -ENOTSUP)
1808 pr_warning("Debugfs is not mounted.\n"); 1809 pr_warning("Tracefs or debugfs is not mounted.\n");
1809 else 1810 else
1810 pr_warning("Failed to open %cprobe_events: %s\n", 1811 pr_warning("Failed to open %cprobe_events: %s\n",
1811 is_kprobe ? 'k' : 'u', 1812 is_kprobe ? 'k' : 'u',
@@ -1816,7 +1817,7 @@ static void print_both_open_warning(int kerr, int uerr)
1816{ 1817{
1817 /* Both kprobes and uprobes are disabled, warn it. */ 1818 /* Both kprobes and uprobes are disabled, warn it. */
1818 if (kerr == -ENOTSUP && uerr == -ENOTSUP) 1819 if (kerr == -ENOTSUP && uerr == -ENOTSUP)
1819 pr_warning("Debugfs is not mounted.\n"); 1820 pr_warning("Tracefs or debugfs is not mounted.\n");
1820 else if (kerr == -ENOENT && uerr == -ENOENT) 1821 else if (kerr == -ENOENT && uerr == -ENOENT)
1821 pr_warning("Please rebuild kernel with CONFIG_KPROBE_EVENTS " 1822 pr_warning("Please rebuild kernel with CONFIG_KPROBE_EVENTS "
1822 "or/and CONFIG_UPROBE_EVENTS.\n"); 1823 "or/and CONFIG_UPROBE_EVENTS.\n");
@@ -1833,13 +1834,20 @@ static int open_probe_events(const char *trace_file, bool readwrite)
1833{ 1834{
1834 char buf[PATH_MAX]; 1835 char buf[PATH_MAX];
1835 const char *__debugfs; 1836 const char *__debugfs;
1837 const char *tracing_dir = "";
1836 int ret; 1838 int ret;
1837 1839
1838 __debugfs = debugfs_find_mountpoint(); 1840 __debugfs = tracefs_find_mountpoint();
1839 if (__debugfs == NULL) 1841 if (__debugfs == NULL) {
1840 return -ENOTSUP; 1842 tracing_dir = "tracing/";
1841 1843
1842 ret = e_snprintf(buf, PATH_MAX, "%s/%s", __debugfs, trace_file); 1844 __debugfs = debugfs_find_mountpoint();
1845 if (__debugfs == NULL)
1846 return -ENOTSUP;
1847 }
1848
1849 ret = e_snprintf(buf, PATH_MAX, "%s/%s%s",
1850 __debugfs, tracing_dir, trace_file);
1843 if (ret >= 0) { 1851 if (ret >= 0) {
1844 pr_debug("Opening %s write=%d\n", buf, readwrite); 1852 pr_debug("Opening %s write=%d\n", buf, readwrite);
1845 if (readwrite && !probe_event_dry_run) 1853 if (readwrite && !probe_event_dry_run)
@@ -1855,12 +1863,12 @@ static int open_probe_events(const char *trace_file, bool readwrite)
1855 1863
1856static int open_kprobe_events(bool readwrite) 1864static int open_kprobe_events(bool readwrite)
1857{ 1865{
1858 return open_probe_events("tracing/kprobe_events", readwrite); 1866 return open_probe_events("kprobe_events", readwrite);
1859} 1867}
1860 1868
1861static int open_uprobe_events(bool readwrite) 1869static int open_uprobe_events(bool readwrite)
1862{ 1870{
1863 return open_probe_events("tracing/uprobe_events", readwrite); 1871 return open_probe_events("uprobe_events", readwrite);
1864} 1872}
1865 1873
1866/* Get raw string list of current kprobe_events or uprobe_events */ 1874/* Get raw string list of current kprobe_events or uprobe_events */
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;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 027a5153495c..73c2f8e557ab 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -75,6 +75,7 @@
75#include <linux/types.h> 75#include <linux/types.h>
76#include <sys/ttydefaults.h> 76#include <sys/ttydefaults.h>
77#include <api/fs/debugfs.h> 77#include <api/fs/debugfs.h>
78#include <api/fs/tracefs.h>
78#include <termios.h> 79#include <termios.h>
79#include <linux/bitops.h> 80#include <linux/bitops.h>
80#include <termios.h> 81#include <termios.h>