aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-08-07 15:21:44 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-08-08 14:55:58 -0400
commitd3d1c4bdf5a793ab10c448f9cf5aa5b19ce026d3 (patch)
tree25f441c735a466d97804aeebba1c8dfc5a61cbba /tools/perf
parent78e890ea8683f7d570f911637b23b23d27be4aed (diff)
perf trace: Setup the augmented syscalls bpf-output event fields
The payload that is put in place by the eBPF script attached to syscalls:sys_enter_openat (and other syscalls with pointers, in the future) can be consumed by the existing sys_enter beautifiers if evsel->priv is setup with a struct syscall_tp with struct tp_fields for the 'syscall_id' and 'args' fields expected by the beautifiers, this patch does just that. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-xfjyog8oveg2fjys9r1yy1es@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-trace.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 43a699cfcadf..06215acb1481 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -77,7 +77,8 @@ struct trace {
77 struct syscall *table; 77 struct syscall *table;
78 struct { 78 struct {
79 struct perf_evsel *sys_enter, 79 struct perf_evsel *sys_enter,
80 *sys_exit; 80 *sys_exit,
81 *augmented;
81 } events; 82 } events;
82 } syscalls; 83 } syscalls;
83 struct record_opts opts; 84 struct record_opts opts;
@@ -263,6 +264,30 @@ out_delete:
263 return -ENOENT; 264 return -ENOENT;
264} 265}
265 266
267static int perf_evsel__init_augmented_syscall_tp(struct perf_evsel *evsel)
268{
269 struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp));
270
271 if (evsel->priv != NULL) { /* field, sizeof_field, offsetof_field */
272 if (__tp_field__init_uint(&sc->id, sizeof(long), sizeof(long long), evsel->needs_swap))
273 goto out_delete;
274
275 return 0;
276 }
277
278 return -ENOMEM;
279out_delete:
280 zfree(&evsel->priv);
281 return -EINVAL;
282}
283
284static int perf_evsel__init_augmented_syscall_tp_args(struct perf_evsel *evsel)
285{
286 struct syscall_tp *sc = evsel->priv;
287
288 return __tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64));
289}
290
266static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler) 291static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler)
267{ 292{
268 evsel->priv = malloc(sizeof(struct syscall_tp)); 293 evsel->priv = malloc(sizeof(struct syscall_tp));
@@ -3248,6 +3273,13 @@ int cmd_trace(int argc, const char **argv)
3248 goto out; 3273 goto out;
3249 } 3274 }
3250 3275
3276 if (evsel) {
3277 if (perf_evsel__init_augmented_syscall_tp(evsel) ||
3278 perf_evsel__init_augmented_syscall_tp_args(evsel))
3279 goto out;
3280 trace.syscalls.events.augmented = evsel;
3281 }
3282
3251 err = bpf__setup_stdout(trace.evlist); 3283 err = bpf__setup_stdout(trace.evlist);
3252 if (err) { 3284 if (err) {
3253 bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); 3285 bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf));