mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
bpftool: Update btf_dump__new() and perf_buffer__new_raw() calls
Use v1.0-compatible variants of btf_dump and perf_buffer "constructors". This is also a demonstration of reusing struct perf_buffer_raw_opts as OPTS-style option struct for new perf_buffer__new_raw() API. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211111053624.190580-10-andrii@kernel.org
This commit is contained in:
parent
eda8bfa5b7
commit
164b04f27f
3 changed files with 5 additions and 8 deletions
|
@ -418,7 +418,7 @@ static int dump_btf_c(const struct btf *btf,
|
||||||
struct btf_dump *d;
|
struct btf_dump *d;
|
||||||
int err = 0, i;
|
int err = 0, i;
|
||||||
|
|
||||||
d = btf_dump__new(btf, NULL, NULL, btf_dump_printf);
|
d = btf_dump__new(btf, btf_dump_printf, NULL, NULL);
|
||||||
if (IS_ERR(d))
|
if (IS_ERR(d))
|
||||||
return PTR_ERR(d);
|
return PTR_ERR(d);
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,7 @@ static int codegen_datasecs(struct bpf_object *obj, const char *obj_name)
|
||||||
char sec_ident[256], map_ident[256];
|
char sec_ident[256], map_ident[256];
|
||||||
int i, err = 0;
|
int i, err = 0;
|
||||||
|
|
||||||
d = btf_dump__new(btf, NULL, NULL, codegen_btf_dump_printf);
|
d = btf_dump__new(btf, codegen_btf_dump_printf, NULL, NULL);
|
||||||
if (IS_ERR(d))
|
if (IS_ERR(d))
|
||||||
return PTR_ERR(d);
|
return PTR_ERR(d);
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ int do_event_pipe(int argc, char **argv)
|
||||||
.wakeup_events = 1,
|
.wakeup_events = 1,
|
||||||
};
|
};
|
||||||
struct bpf_map_info map_info = {};
|
struct bpf_map_info map_info = {};
|
||||||
struct perf_buffer_raw_opts opts = {};
|
LIBBPF_OPTS(perf_buffer_raw_opts, opts);
|
||||||
struct event_pipe_ctx ctx = {
|
struct event_pipe_ctx ctx = {
|
||||||
.all_cpus = true,
|
.all_cpus = true,
|
||||||
.cpu = -1,
|
.cpu = -1,
|
||||||
|
@ -190,14 +190,11 @@ int do_event_pipe(int argc, char **argv)
|
||||||
ctx.idx = 0;
|
ctx.idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.attr = &perf_attr;
|
|
||||||
opts.event_cb = print_bpf_output;
|
|
||||||
opts.ctx = &ctx;
|
|
||||||
opts.cpu_cnt = ctx.all_cpus ? 0 : 1;
|
opts.cpu_cnt = ctx.all_cpus ? 0 : 1;
|
||||||
opts.cpus = &ctx.cpu;
|
opts.cpus = &ctx.cpu;
|
||||||
opts.map_keys = &ctx.idx;
|
opts.map_keys = &ctx.idx;
|
||||||
|
pb = perf_buffer__new_raw(map_fd, MMAP_PAGE_CNT, &perf_attr,
|
||||||
pb = perf_buffer__new_raw(map_fd, MMAP_PAGE_CNT, &opts);
|
print_bpf_output, &ctx, &opts);
|
||||||
err = libbpf_get_error(pb);
|
err = libbpf_get_error(pb);
|
||||||
if (err) {
|
if (err) {
|
||||||
p_err("failed to create perf buffer: %s (%d)",
|
p_err("failed to create perf buffer: %s (%d)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue