From: Tao Chen <chen.dylane@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, haoluo@google.com, jolsa@kernel.org,
qmo@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, chen.dylane@gmail.com,
Tao Chen <dylane.chen@didiglobal.com>
Subject: Re: [PATCH bpf-next v8 3/5] libbpf: Add libbpf_probe_bpf_kfunc API
Date: Tue, 25 Feb 2025 13:47:38 +0800 [thread overview]
Message-ID: <edec731d-3370-46b8-baad-b8bf181bcce3@linux.dev> (raw)
In-Reply-To: <CAEf4BzYr9WzYbmyq8=nVETDqYvmYmObhD6x+_TQYpSUWxxGLLg@mail.gmail.com>
在 2025/2/25 09:15, Andrii Nakryiko 写道:
> On Mon, Feb 24, 2025 at 9:02 AM Tao Chen <chen.dylane@linux.dev> wrote:
>>
>> Similarly to libbpf_probe_bpf_helper, the libbpf_probe_bpf_kfunc
>> used to test the availability of the different eBPF kfuncs on the
>> current system.
>>
>> Cc: Tao Chen <dylane.chen@didiglobal.com>
>> Reviewed-by: Jiri Olsa <jolsa@kernel.org>
>> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
>> Signed-off-by: Tao Chen <chen.dylane@linux.dev>
>> ---
>> tools/lib/bpf/libbpf.h | 19 ++++++++++++-
>> tools/lib/bpf/libbpf.map | 1 +
>> tools/lib/bpf/libbpf_probes.c | 51 +++++++++++++++++++++++++++++++++++
>> 3 files changed, 70 insertions(+), 1 deletion(-)
>>
>
> [...]
>
>> + buf[0] = '\0';
>> + ret = probe_prog_load(prog_type, insns, insn_cnt, btf_fd >= 0 ? fd_array : NULL,
>> + buf, sizeof(buf));
>> + if (ret < 0)
>> + return libbpf_err(ret);
>> +
>> + if (ret > 0)
>> + return 1; /* assume supported */
>> +
>> + /* If BPF verifier recognizes BPF kfunc but it's not supported for
>> + * given BPF program type, it will emit "calling kernel function
>> + * <name> is not allowed". If the kfunc id is invalid,
>> + * it will emit "kernel btf_id <id> is not a function". If BTF fd
>> + * invalid in module BTF, it will emit "invalid module BTF fd specified" or
>> + * "negative offset disallowed for kernel module function call". If
>> + * kfunc prog not dev buound, it will emit "metadata kfuncs require
>> + * device-bound program".
>> + */
>> + if (strstr(buf, "not allowed") || strstr(buf, "not a function") ||
>> + strstr(buf, "invalid module BTF fd") ||
>
> why is invalid module BTF FD not an error (negative return)?
>
>> + strstr(buf, "negative offset disallowed") ||
>> + strstr(buf, "device-bound program"))
>> + return 0;
>> +
>> + return 1;
>> +}
>> +
>> int libbpf_probe_bpf_helper(enum bpf_prog_type prog_type, enum bpf_func_id helper_id,
>> const void *opts)
>> {
>> --
>> 2.43.0
>>
In probe_prog_load, err will be checked and converted into either 0 or 1.
--
Best Regards
Tao Chen
next prev parent reply other threads:[~2025-02-25 5:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 16:59 [PATCH bpf-next v8 0/5] Add prog_kfunc feature probe Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 1/5] libbpf: Extract prog load type check from libbpf_probe_bpf_helper Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 2/5] libbpf: Init fd_array when prog probe load Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 3/5] libbpf: Add libbpf_probe_bpf_kfunc API Tao Chen
2025-02-25 1:15 ` Andrii Nakryiko
2025-02-25 5:47 ` Tao Chen [this message]
2025-02-25 17:01 ` Andrii Nakryiko
2025-02-24 16:59 ` [PATCH bpf-next v8 4/5] libbpf: Init kprobe prog expected_attach_type for kfunc probe Tao Chen
2025-02-25 1:15 ` Andrii Nakryiko
2025-02-25 5:44 ` Tao Chen
2025-02-25 17:04 ` Andrii Nakryiko
2025-02-26 11:12 ` Jiri Olsa
2025-02-26 16:10 ` Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 5/5] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests Tao Chen
2025-02-24 17:13 ` [PATCH bpf-next v8 0/5] Add prog_kfunc feature probe Tao Chen
2025-02-25 1:28 ` Eduard Zingerman
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=edec731d-3370-46b8-baad-b8bf181bcce3@linux.dev \
--to=chen.dylane@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chen.dylane@gmail.com \
--cc=daniel@iogearbox.net \
--cc=dylane.chen@didiglobal.com \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qmo@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.