On Thu, Jan 6, 2022 at 12:03 PM Christy Lee <christylee@xxxxxx> wrote: > > bpf_prog_load() API is deprecated, remove perf's usage of the deprecated > function. > > Signed-off-by: Christy Lee <christylee@xxxxxx> > Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > --- > tools/perf/tests/bpf.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c > index 573490530194..57b9591f7cbb 100644 > --- a/tools/perf/tests/bpf.c > +++ b/tools/perf/tests/bpf.c > @@ -281,8 +281,8 @@ static int __test__bpf(int idx) > > static int check_env(void) > { > + LIBBPF_OPTS(bpf_prog_load_opts, opts); > int err; > - unsigned int kver_int; > char license[] = "GPL"; > > struct bpf_insn insns[] = { > @@ -290,19 +290,13 @@ static int check_env(void) > BPF_EXIT_INSN(), > }; > > - err = fetch_kernel_version(&kver_int, NULL, 0); > + err = fetch_kernel_version(&opts.kern_version, NULL, 0); > if (err) { > pr_debug("Unable to get kernel version\n"); > return err; > } > - > -/* temporarily disable libbpf deprecation warnings */ > -#pragma GCC diagnostic push > -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" > - err = bpf_load_program(BPF_PROG_TYPE_KPROBE, insns, > - ARRAY_SIZE(insns), > - license, kver_int, NULL, 0); > -#pragma GCC diagnostic pop > + err = bpf_prog_load(BPF_PROG_TYPE_KPROBE, NULL, license, insns, > + ARRAY_SIZE(insns), &opts); Christy, you should probably define __weak bpf_prog_load implementation that will re-route to bpf_load_program? See how it was done for other APIs (e.g., btf__load_from_kernel_by_id). Arnaldo, more generally, what would be the plan for libbpf 1.0 at which point those deprecated APIs (e.g., bpf_load_program) are going to be removed completely? Do you have some control over the minimal libbpf version for cases when you'd like to use libbpf as a shared library? > if (err < 0) { > pr_err("Missing basic BPF support, skip this test: %s\n", > strerror(errno)); > -- > 2.30.2 >