diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-17 02:06:21 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-17 02:06:21 +0200 |
commit | 772c1d06bd402f7ee72c61a18c2db74cd74b6758 (patch) | |
tree | e362fc7e158b3580d810a26189ecf91ec8a4f141 /tools/perf/builtin-ftrace.c | |
parent | Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/k... (diff) | |
parent | kprobes: Prohibit probing on BUG() and WARN() address (diff) | |
download | linux-772c1d06bd402f7ee72c61a18c2db74cd74b6758.tar.xz linux-772c1d06bd402f7ee72c61a18c2db74cd74b6758.zip |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar:
"Kernel side changes:
- Improved kbprobes robustness
- Intel PEBS support for PT hardware tracing
- Other Intel PT improvements: high order pages memory footprint
reduction and various related cleanups
- Misc cleanups
The perf tooling side has been very busy in this cycle, with over 300
commits. This is an incomplete high-level summary of the many
improvements done by over 30 developers:
- Lots of updates to the following tools:
'perf c2c'
'perf config'
'perf record'
'perf report'
'perf script'
'perf test'
'perf top'
'perf trace'
- Updates to libperf and libtraceevent, and a consolidation of the
proliferation of x86 instruction decoder libraries.
- Vendor event updates for Intel and PowerPC CPUs,
- Updates to hardware tracing tooling for ARM and Intel CPUs,
- ... and lots of other changes and cleanups - see the shortlog and
Git log for details"
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (322 commits)
kprobes: Prohibit probing on BUG() and WARN() address
perf/x86: Make more stuff static
x86, perf: Fix the dependency of the x86 insn decoder selftest
objtool: Ignore intentional differences for the x86 insn decoder
objtool: Update sync-check.sh from perf's check-headers.sh
perf build: Ignore intentional differences for the x86 insn decoder
perf intel-pt: Use shared x86 insn decoder
perf intel-pt: Remove inat.c from build dependency list
perf: Update .gitignore file
objtool: Move x86 insn decoder to a common location
perf metricgroup: Support multiple events for metricgroup
perf metricgroup: Scale the metric result
perf pmu: Change convert_scale from static to global
perf symbols: Move mem_info and branch_info out of symbol.h
perf auxtrace: Uninline functions that touch perf_session
perf tools: Remove needless evlist.h include directives
perf tools: Remove needless evlist.h include directives
perf tools: Remove needless thread_map.h include directives
perf tools: Remove needless thread.h include directives
perf tools: Remove needless map.h include directives
...
Diffstat (limited to 'tools/perf/builtin-ftrace.c')
-rw-r--r-- | tools/perf/builtin-ftrace.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 019312810405..d5adc417a4ca 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -6,28 +6,31 @@ */ #include "builtin.h" -#include "perf.h" #include <errno.h> #include <unistd.h> #include <signal.h> +#include <stdlib.h> #include <fcntl.h> #include <poll.h> +#include <linux/capability.h> +#include <linux/string.h> #include "debug.h" +#include <subcmd/pager.h> #include <subcmd/parse-options.h> #include <api/fs/tracing_path.h> #include "evlist.h" #include "target.h" #include "cpumap.h" #include "thread_map.h" +#include "util/cap.h" #include "util/config.h" - #define DEFAULT_TRACER "function_graph" struct perf_ftrace { - struct perf_evlist *evlist; + struct evlist *evlist; struct target target; const char *tracer; struct list_head filters; @@ -156,16 +159,16 @@ static int set_tracing_pid(struct perf_ftrace *ftrace) if (target__has_cpu(&ftrace->target)) return 0; - for (i = 0; i < thread_map__nr(ftrace->evlist->threads); i++) { + for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) { scnprintf(buf, sizeof(buf), "%d", - ftrace->evlist->threads->map[i]); + ftrace->evlist->core.threads->map[i]); if (append_tracing_file("set_ftrace_pid", buf) < 0) return -1; } return 0; } -static int set_tracing_cpumask(struct cpu_map *cpumap) +static int set_tracing_cpumask(struct perf_cpu_map *cpumap) { char *cpumask; size_t mask_size; @@ -192,7 +195,7 @@ static int set_tracing_cpumask(struct cpu_map *cpumap) static int set_tracing_cpu(struct perf_ftrace *ftrace) { - struct cpu_map *cpumap = ftrace->evlist->cpus; + struct perf_cpu_map *cpumap = ftrace->evlist->core.cpus; if (!target__has_cpu(&ftrace->target)) return 0; @@ -202,11 +205,11 @@ static int set_tracing_cpu(struct perf_ftrace *ftrace) static int reset_tracing_cpu(void) { - struct cpu_map *cpumap = cpu_map__new(NULL); + struct perf_cpu_map *cpumap = perf_cpu_map__new(NULL); int ret; ret = set_tracing_cpumask(cpumap); - cpu_map__put(cpumap); + perf_cpu_map__put(cpumap); return ret; } @@ -281,8 +284,14 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) .events = POLLIN, }; - if (geteuid() != 0) { - pr_err("ftrace only works for root!\n"); + if (!perf_cap__capable(CAP_SYS_ADMIN)) { + pr_err("ftrace only works for %s!\n", +#ifdef HAVE_LIBCAP_SUPPORT + "users with the SYS_ADMIN capability" +#else + "root" +#endif + ); return -1; } @@ -495,7 +504,7 @@ int cmd_ftrace(int argc, const char **argv) goto out_delete_filters; } - ftrace.evlist = perf_evlist__new(); + ftrace.evlist = evlist__new(); if (ftrace.evlist == NULL) { ret = -ENOMEM; goto out_delete_filters; @@ -508,7 +517,7 @@ int cmd_ftrace(int argc, const char **argv) ret = __cmd_ftrace(&ftrace, argc, argv); out_delete_evlist: - perf_evlist__delete(ftrace.evlist); + evlist__delete(ftrace.evlist); out_delete_filters: delete_filter_func(&ftrace.filters); |