linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Dave Marchevsky <davemarchevsky@fb.com>
Cc: bpf <bpf@vger.kernel.org>,
	"linux-perf-use." <linux-perf-users@vger.kernel.org>,
	Song Liu <songliubraving@fb.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH v2 bpf-next 1/4] libbpf: migrate internal use of bpf_program__get_prog_info_linear
Date: Wed, 20 Oct 2021 10:36:35 -0700	[thread overview]
Message-ID: <CAEf4BzbRdUn4FG208egs+MuHy37W5=Tp=CHngMLQdNyZooWqiQ@mail.gmail.com> (raw)
In-Reply-To: <20211011082031.4148337-2-davemarchevsky@fb.com>

On Mon, Oct 11, 2021 at 1:20 AM Dave Marchevsky <davemarchevsky@fb.com> wrote:
>
> In preparation for bpf_program__get_prog_info_linear, move the single

for bpf_program__get_prog_info_linear *deprecation* ? fixed it up while applying

> use in libbpf to call bpf_obj_get_info_by_fd directly.
>
> Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
> ---

I've applied this patch for now, as it is pretty independent (and I've
already fixed it up already and didn't want to lose that :) I hope you
don't mind.

>  tools/lib/bpf/libbpf.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index ed313fd491bd..8b86c4831aa8 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -8459,26 +8459,24 @@ int libbpf_find_vmlinux_btf_id(const char *name,
>
>  static int libbpf_find_prog_btf_id(const char *name, __u32 attach_prog_fd)
>  {
> -       struct bpf_prog_info_linear *info_linear;
> -       struct bpf_prog_info *info;
> +       struct bpf_prog_info info = {};
> +       __u32 info_len = sizeof(info);
>         struct btf *btf;
>         int err;
>
> -       info_linear = bpf_program__get_prog_info_linear(attach_prog_fd, 0);
> -       err = libbpf_get_error(info_linear);
> +       err = bpf_obj_get_info_by_fd(attach_prog_fd, &info, &info_len);
>         if (err) {
> -               pr_warn("failed get_prog_info_linear for FD %d\n",
> +               pr_warn("failed bpf_obj_get_info_by_fd for FD %d\n",

I've also added err code into warn message here

>                         attach_prog_fd);
>                 return err;
>         }
>
>         err = -EINVAL;
> -       info = &info_linear->info;
> -       if (!info->btf_id) {
> +       if (!info.btf_id) {
>                 pr_warn("The target program doesn't have BTF\n");
>                 goto out;
>         }
> -       btf = btf__load_from_kernel_by_id(info->btf_id);
> +       btf = btf__load_from_kernel_by_id(info.btf_id);
>         if (libbpf_get_error(btf)) {
>                 pr_warn("Failed to get BTF of the program\n");

and here




>                 goto out;
> @@ -8490,7 +8488,6 @@ static int libbpf_find_prog_btf_id(const char *name, __u32 attach_prog_fd)
>                 goto out;
>         }
>  out:
> -       free(info_linear);
>         return err;
>  }
>
> --
> 2.30.2
>

  reply	other threads:[~2021-10-20 17:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11  8:20 [PATCH v2 bpf-next 0/4] libbpf: deprecate bpf_program__get_prog_info_linear Dave Marchevsky
2021-10-11  8:20 ` [PATCH v2 bpf-next 1/4] libbpf: migrate internal use of bpf_program__get_prog_info_linear Dave Marchevsky
2021-10-20 17:36   ` Andrii Nakryiko [this message]
2021-10-11  8:20 ` [PATCH v2 bpf-next 2/4] bpftool: use bpf_obj_get_info_by_fd directly Dave Marchevsky
2021-10-20 17:37   ` Andrii Nakryiko
2021-10-20 22:15     ` Quentin Monnet
2021-10-11  8:20 ` [PATCH v2 bpf-next 3/4] perf: pull in bpf_program__get_prog_info_linear Dave Marchevsky
2021-10-20 17:37   ` Andrii Nakryiko
     [not found]     ` <5080FF1F-8E7A-4AF7-AD7E-7349E58CFEDB@fb.com>
2021-10-31 17:13       ` Arnaldo Carvalho de Melo
2021-10-11  8:20 ` [PATCH v2 bpf-next 4/4] libbpf: deprecate bpf_program__get_prog_info_linear Dave Marchevsky
2021-10-20 17:37   ` Andrii Nakryiko
2021-10-20 21:01     ` Toke Høiland-Jørgensen
     [not found]       ` <d3de589a-21f3-7a0d-59de-126d3c70fba1@fb.com>
2021-10-22 19:26         ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4BzbRdUn4FG208egs+MuHy37W5=Tp=CHngMLQdNyZooWqiQ@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davemarchevsky@fb.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).