]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bpftool: Update btf_dump__new() and perf_buffer__new_raw() calls
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 11 Nov 2021 05:36:24 +0000 (21:36 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Nov 2021 00:54:06 +0000 (16:54 -0800)
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
tools/bpf/bpftool/btf.c
tools/bpf/bpftool/gen.c
tools/bpf/bpftool/map_perf_ring.c

index 015d2758f826473ac4988ca8727ded942cb77108..223ac76760274d39cf23db0012f38c9eef2cbb10 100644 (file)
@@ -418,7 +418,7 @@ static int dump_btf_c(const struct btf *btf,
        struct btf_dump *d;
        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))
                return PTR_ERR(d);
 
index 5c18351290f002c933c92e57a573c7e9aec8d9aa..89f0e828bbfaf22f4369ab7c19caab92fabcea62 100644 (file)
@@ -218,7 +218,7 @@ static int codegen_datasecs(struct bpf_object *obj, const char *obj_name)
        char sec_ident[256], map_ident[256];
        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))
                return PTR_ERR(d);
 
index b98ea702d2849aa13102f6f69cb1259153301fe9..6b0c410152defa3ef9e325e74dfa9102147c17bd 100644 (file)
@@ -124,7 +124,7 @@ int do_event_pipe(int argc, char **argv)
                .wakeup_events = 1,
        };
        struct bpf_map_info map_info = {};
-       struct perf_buffer_raw_opts opts = {};
+       LIBBPF_OPTS(perf_buffer_raw_opts, opts);
        struct event_pipe_ctx ctx = {
                .all_cpus = true,
                .cpu = -1,
@@ -190,14 +190,11 @@ int do_event_pipe(int argc, char **argv)
                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.cpus = &ctx.cpu;
        opts.map_keys = &ctx.idx;
-
-       pb = perf_buffer__new_raw(map_fd, MMAP_PAGE_CNT, &opts);
+       pb = perf_buffer__new_raw(map_fd, MMAP_PAGE_CNT, &perf_attr,
+                                 print_bpf_output, &ctx, &opts);
        err = libbpf_get_error(pb);
        if (err) {
                p_err("failed to create perf buffer: %s (%d)",