|
18 | 18 | #include <api/fs/tracing_path.h> |
19 | 19 | #ifdef HAVE_LIBBPF_SUPPORT |
20 | 20 | #include <bpf/bpf.h> |
| 21 | +#include <bpf/libbpf.h> |
21 | 22 | #endif |
22 | 23 | #include "util/bpf_map.h" |
23 | 24 | #include "util/rlimit.h" |
|
53 | 54 | #include "trace/beauty/beauty.h" |
54 | 55 | #include "trace-event.h" |
55 | 56 | #include "util/parse-events.h" |
56 | | -#include "util/bpf-loader.h" |
57 | 57 | #include "util/tracepoint.h" |
58 | 58 | #include "callchain.h" |
59 | 59 | #include "print_binary.h" |
@@ -3287,17 +3287,6 @@ static struct bpf_map *trace__find_bpf_map_by_name(struct trace *trace, const ch |
3287 | 3287 | return bpf_object__find_map_by_name(trace->bpf_obj, name); |
3288 | 3288 | } |
3289 | 3289 |
|
3290 | | -static void trace__set_bpf_map_filtered_pids(struct trace *trace) |
3291 | | -{ |
3292 | | - trace->filter_pids.map = trace__find_bpf_map_by_name(trace, "pids_filtered"); |
3293 | | -} |
3294 | | - |
3295 | | -static void trace__set_bpf_map_syscalls(struct trace *trace) |
3296 | | -{ |
3297 | | - trace->syscalls.prog_array.sys_enter = trace__find_bpf_map_by_name(trace, "syscalls_sys_enter"); |
3298 | | - trace->syscalls.prog_array.sys_exit = trace__find_bpf_map_by_name(trace, "syscalls_sys_exit"); |
3299 | | -} |
3300 | | - |
3301 | 3290 | static struct bpf_program *trace__find_bpf_program_by_title(struct trace *trace, const char *name) |
3302 | 3291 | { |
3303 | 3292 | struct bpf_program *pos, *prog = NULL; |
@@ -3553,71 +3542,19 @@ static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace) |
3553 | 3542 | return err; |
3554 | 3543 | } |
3555 | 3544 |
|
3556 | | -static void trace__delete_augmented_syscalls(struct trace *trace) |
3557 | | -{ |
3558 | | - struct evsel *evsel, *tmp; |
3559 | | - |
3560 | | - evlist__remove(trace->evlist, trace->syscalls.events.augmented); |
3561 | | - evsel__delete(trace->syscalls.events.augmented); |
3562 | | - trace->syscalls.events.augmented = NULL; |
3563 | | - |
3564 | | - evlist__for_each_entry_safe(trace->evlist, tmp, evsel) { |
3565 | | - if (evsel->bpf_obj == trace->bpf_obj) { |
3566 | | - evlist__remove(trace->evlist, evsel); |
3567 | | - evsel__delete(evsel); |
3568 | | - } |
3569 | | - |
3570 | | - } |
3571 | | - |
3572 | | - bpf_object__close(trace->bpf_obj); |
3573 | | - trace->bpf_obj = NULL; |
3574 | | -} |
3575 | 3545 | #else // HAVE_LIBBPF_SUPPORT |
3576 | 3546 | static struct bpf_map *trace__find_bpf_map_by_name(struct trace *trace __maybe_unused, |
3577 | 3547 | const char *name __maybe_unused) |
3578 | 3548 | { |
3579 | 3549 | return NULL; |
3580 | 3550 | } |
3581 | 3551 |
|
3582 | | -static void trace__set_bpf_map_filtered_pids(struct trace *trace __maybe_unused) |
3583 | | -{ |
3584 | | -} |
3585 | | - |
3586 | | -static void trace__set_bpf_map_syscalls(struct trace *trace __maybe_unused) |
3587 | | -{ |
3588 | | -} |
3589 | | - |
3590 | | -static struct bpf_program *trace__find_bpf_program_by_title(struct trace *trace __maybe_unused, |
3591 | | - const char *name __maybe_unused) |
3592 | | -{ |
3593 | | - return NULL; |
3594 | | -} |
3595 | | - |
3596 | 3552 | static int trace__init_syscalls_bpf_prog_array_maps(struct trace *trace __maybe_unused) |
3597 | 3553 | { |
3598 | 3554 | return 0; |
3599 | 3555 | } |
3600 | | - |
3601 | | -static void trace__delete_augmented_syscalls(struct trace *trace __maybe_unused) |
3602 | | -{ |
3603 | | -} |
3604 | 3556 | #endif // HAVE_LIBBPF_SUPPORT |
3605 | 3557 |
|
3606 | | -static bool trace__only_augmented_syscalls_evsels(struct trace *trace) |
3607 | | -{ |
3608 | | - struct evsel *evsel; |
3609 | | - |
3610 | | - evlist__for_each_entry(trace->evlist, evsel) { |
3611 | | - if (evsel == trace->syscalls.events.augmented || |
3612 | | - evsel->bpf_obj == trace->bpf_obj) |
3613 | | - continue; |
3614 | | - |
3615 | | - return false; |
3616 | | - } |
3617 | | - |
3618 | | - return true; |
3619 | | -} |
3620 | | - |
3621 | 3558 | static int trace__set_ev_qualifier_filter(struct trace *trace) |
3622 | 3559 | { |
3623 | 3560 | if (trace->syscalls.events.sys_enter) |
@@ -3981,16 +3918,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv) |
3981 | 3918 | if (err < 0) |
3982 | 3919 | goto out_error_open; |
3983 | 3920 |
|
3984 | | - err = bpf__apply_obj_config(); |
3985 | | - if (err) { |
3986 | | - char errbuf[BUFSIZ]; |
3987 | | - |
3988 | | - bpf__strerror_apply_obj_config(err, errbuf, sizeof(errbuf)); |
3989 | | - pr_err("ERROR: Apply config to BPF failed: %s\n", |
3990 | | - errbuf); |
3991 | | - goto out_error_open; |
3992 | | - } |
3993 | | - |
3994 | 3921 | err = trace__set_filter_pids(trace); |
3995 | 3922 | if (err < 0) |
3996 | 3923 | goto out_error_mem; |
@@ -4922,77 +4849,6 @@ int cmd_trace(int argc, const char **argv) |
4922 | 4849 | "cgroup monitoring only available in system-wide mode"); |
4923 | 4850 | } |
4924 | 4851 |
|
4925 | | - evsel = bpf__setup_output_event(trace.evlist, "__augmented_syscalls__"); |
4926 | | - if (IS_ERR(evsel)) { |
4927 | | - bpf__strerror_setup_output_event(trace.evlist, PTR_ERR(evsel), bf, sizeof(bf)); |
4928 | | - pr_err("ERROR: Setup trace syscalls enter failed: %s\n", bf); |
4929 | | - goto out; |
4930 | | - } |
4931 | | - |
4932 | | - if (evsel) { |
4933 | | - trace.syscalls.events.augmented = evsel; |
4934 | | - |
4935 | | - evsel = evlist__find_tracepoint_by_name(trace.evlist, "raw_syscalls:sys_enter"); |
4936 | | - if (evsel == NULL) { |
4937 | | - pr_err("ERROR: raw_syscalls:sys_enter not found in the augmented BPF object\n"); |
4938 | | - goto out; |
4939 | | - } |
4940 | | - |
4941 | | - if (evsel->bpf_obj == NULL) { |
4942 | | - pr_err("ERROR: raw_syscalls:sys_enter not associated to a BPF object\n"); |
4943 | | - goto out; |
4944 | | - } |
4945 | | - |
4946 | | - trace.bpf_obj = evsel->bpf_obj; |
4947 | | - |
4948 | | - /* |
4949 | | - * If we have _just_ the augmenter event but don't have a |
4950 | | - * explicit --syscalls, then assume we want all strace-like |
4951 | | - * syscalls: |
4952 | | - */ |
4953 | | - if (!trace.trace_syscalls && trace__only_augmented_syscalls_evsels(&trace)) |
4954 | | - trace.trace_syscalls = true; |
4955 | | - /* |
4956 | | - * So, if we have a syscall augmenter, but trace_syscalls, aka |
4957 | | - * strace-like syscall tracing is not set, then we need to trow |
4958 | | - * away the augmenter, i.e. all the events that were created |
4959 | | - * from that BPF object file. |
4960 | | - * |
4961 | | - * This is more to fix the current .perfconfig trace.add_events |
4962 | | - * style of setting up the strace-like eBPF based syscall point |
4963 | | - * payload augmenter. |
4964 | | - * |
4965 | | - * All this complexity will be avoided by adding an alternative |
4966 | | - * to trace.add_events in the form of |
4967 | | - * trace.bpf_augmented_syscalls, that will be only parsed if we |
4968 | | - * need it. |
4969 | | - * |
4970 | | - * .perfconfig trace.add_events is still useful if we want, for |
4971 | | - * instance, have msr_write.msr in some .perfconfig profile based |
4972 | | - * 'perf trace --config determinism.profile' mode, where for some |
4973 | | - * particular goal/workload type we want a set of events and |
4974 | | - * output mode (with timings, etc) instead of having to add |
4975 | | - * all via the command line. |
4976 | | - * |
4977 | | - * Also --config to specify an alternate .perfconfig file needs |
4978 | | - * to be implemented. |
4979 | | - */ |
4980 | | - if (!trace.trace_syscalls) { |
4981 | | - trace__delete_augmented_syscalls(&trace); |
4982 | | - } else { |
4983 | | - trace__set_bpf_map_filtered_pids(&trace); |
4984 | | - trace__set_bpf_map_syscalls(&trace); |
4985 | | - trace.syscalls.unaugmented_prog = trace__find_bpf_program_by_title(&trace, "!raw_syscalls:unaugmented"); |
4986 | | - } |
4987 | | - } |
4988 | | - |
4989 | | - err = bpf__setup_stdout(trace.evlist); |
4990 | | - if (err) { |
4991 | | - bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); |
4992 | | - pr_err("ERROR: Setup BPF stdout failed: %s\n", bf); |
4993 | | - goto out; |
4994 | | - } |
4995 | | - |
4996 | 4852 | err = -1; |
4997 | 4853 |
|
4998 | 4854 | if (map_dump_str) { |
|
0 commit comments