diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-11-03 07:19:56 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-11-03 07:19:56 -0400 |
| commit | cd26ea6d50a207ee37e0364ecc2d196d6c9671e8 (patch) | |
| tree | 8031bd6a064f4ecb065ae6a8bffa64b80216b065 /tools | |
| parent | 3c5e3dabf3722a883227623a4adf61976c2224ff (diff) | |
perf trace: Fix setting of augmented payload when using eBPF + raw_syscalls
For now with BPF raw_augmented we hook into raw_syscalls:sys_enter and
there we get all 6 syscall args plus the tracepoint common fields
(sizeof(long)) and the syscall_nr (another long). So we check if that is
the case and if so don't look after the sc->args_size, but always after
the full raw_syscalls:sys_enter payload, which is fixed.
We'll revisit this later to pass s->args_size to the BPF augmenter (now
tools/perf/examples/bpf/augmented_raw_syscalls.c, so that it copies only
what we need for each syscall, like what happens when we use
syscalls:sys_enter_NAME, so that we reduce the kernel/userspace traffic
to just what is needed for each syscall.
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-nlslrg8apxdsobt4pwl3n7ur@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/builtin-trace.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f582ca575883..835619476370 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
| @@ -108,6 +108,7 @@ struct trace { | |||
| 108 | } stats; | 108 | } stats; |
| 109 | unsigned int max_stack; | 109 | unsigned int max_stack; |
| 110 | unsigned int min_stack; | 110 | unsigned int min_stack; |
| 111 | bool raw_augmented_syscalls; | ||
| 111 | bool not_ev_qualifier; | 112 | bool not_ev_qualifier; |
| 112 | bool live; | 113 | bool live; |
| 113 | bool full_time; | 114 | bool full_time; |
| @@ -1724,13 +1725,28 @@ static int trace__fprintf_sample(struct trace *trace, struct perf_evsel *evsel, | |||
| 1724 | return printed; | 1725 | return printed; |
| 1725 | } | 1726 | } |
| 1726 | 1727 | ||
| 1727 | static void *syscall__augmented_args(struct syscall *sc, struct perf_sample *sample, int *augmented_args_size) | 1728 | static void *syscall__augmented_args(struct syscall *sc, struct perf_sample *sample, int *augmented_args_size, bool raw_augmented) |
| 1728 | { | 1729 | { |
| 1729 | void *augmented_args = NULL; | 1730 | void *augmented_args = NULL; |
| 1731 | /* | ||
| 1732 | * For now with BPF raw_augmented we hook into raw_syscalls:sys_enter | ||
| 1733 | * and there we get all 6 syscall args plus the tracepoint common | ||
| 1734 | * fields (sizeof(long)) and the syscall_nr (another long). So we check | ||
| 1735 | * if that is the case and if so don't look after the sc->args_size, | ||
| 1736 | * but always after the full raw_syscalls:sys_enter payload, which is | ||
| 1737 | * fixed. | ||
| 1738 | * | ||
| 1739 | * We'll revisit this later to pass s->args_size to the BPF augmenter | ||
| 1740 | * (now tools/perf/examples/bpf/augmented_raw_syscalls.c, so that it | ||
| 1741 | * copies only what we need for each syscall, like what happens when we | ||
| 1742 | * use syscalls:sys_enter_NAME, so that we reduce the kernel/userspace | ||
| 1743 | * traffic to just what is needed for each syscall. | ||
| 1744 | */ | ||
| 1745 | int args_size = raw_augmented ? (8 * (int)sizeof(long)) : sc->args_size; | ||
| 1730 | 1746 | ||
| 1731 | *augmented_args_size = sample->raw_size - sc->args_size; | 1747 | *augmented_args_size = sample->raw_size - args_size; |
| 1732 | if (*augmented_args_size > 0) | 1748 | if (*augmented_args_size > 0) |
| 1733 | augmented_args = sample->raw_data + sc->args_size; | 1749 | augmented_args = sample->raw_data + args_size; |
| 1734 | 1750 | ||
| 1735 | return augmented_args; | 1751 | return augmented_args; |
| 1736 | } | 1752 | } |
| @@ -1780,7 +1796,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, | |||
| 1780 | * here and avoid using augmented syscalls when the evsel is the raw_syscalls one. | 1796 | * here and avoid using augmented syscalls when the evsel is the raw_syscalls one. |
| 1781 | */ | 1797 | */ |
| 1782 | if (evsel != trace->syscalls.events.sys_enter) | 1798 | if (evsel != trace->syscalls.events.sys_enter) |
| 1783 | augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size); | 1799 | augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls); |
| 1784 | ttrace->entry_time = sample->time; | 1800 | ttrace->entry_time = sample->time; |
| 1785 | msg = ttrace->entry_str; | 1801 | msg = ttrace->entry_str; |
| 1786 | printed += scnprintf(msg + printed, trace__entry_str_size - printed, "%s(", sc->name); | 1802 | printed += scnprintf(msg + printed, trace__entry_str_size - printed, "%s(", sc->name); |
| @@ -1833,7 +1849,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evse | |||
| 1833 | goto out_put; | 1849 | goto out_put; |
| 1834 | 1850 | ||
| 1835 | args = perf_evsel__sc_tp_ptr(evsel, args, sample); | 1851 | args = perf_evsel__sc_tp_ptr(evsel, args, sample); |
| 1836 | augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size); | 1852 | augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls); |
| 1837 | syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmented_args, augmented_args_size, trace, thread); | 1853 | syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmented_args, augmented_args_size, trace, thread); |
| 1838 | fprintf(trace->output, "%s", msg); | 1854 | fprintf(trace->output, "%s", msg); |
| 1839 | err = 0; | 1855 | err = 0; |
| @@ -3501,8 +3517,15 @@ int cmd_trace(int argc, const char **argv) | |||
| 3501 | evsel->handler = trace__sys_enter; | 3517 | evsel->handler = trace__sys_enter; |
| 3502 | 3518 | ||
| 3503 | evlist__for_each_entry(trace.evlist, evsel) { | 3519 | evlist__for_each_entry(trace.evlist, evsel) { |
| 3504 | if (strstarts(perf_evsel__name(evsel), "syscalls:sys_exit_") || | 3520 | bool raw_syscalls_sys_exit = strcmp(perf_evsel__name(evsel), "raw_syscalls:sys_exit") == 0; |
| 3505 | strcmp(perf_evsel__name(evsel), "raw_syscalls:sys_exit") == 0) { | 3521 | |
| 3522 | if (raw_syscalls_sys_exit) { | ||
| 3523 | trace.raw_augmented_syscalls = true; | ||
| 3524 | goto init_augmented_syscall_tp; | ||
| 3525 | } | ||
| 3526 | |||
| 3527 | if (strstarts(perf_evsel__name(evsel), "syscalls:sys_exit_")) { | ||
| 3528 | init_augmented_syscall_tp: | ||
| 3506 | perf_evsel__init_augmented_syscall_tp(evsel); | 3529 | perf_evsel__init_augmented_syscall_tp(evsel); |
| 3507 | perf_evsel__init_augmented_syscall_tp_ret(evsel); | 3530 | perf_evsel__init_augmented_syscall_tp_ret(evsel); |
| 3508 | evsel->handler = trace__sys_exit; | 3531 | evsel->handler = trace__sys_exit; |
