From: Jiri Olsa <olsajiri@gmail.com>
To: Tao Chen <chen.dylane@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, haoluo@google.com, qmo@kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 4/4] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests
Date: Mon, 10 Feb 2025 14:47:08 +0100 [thread overview]
Message-ID: <Z6oDXNpqmwHo6lKh@krava> (raw)
In-Reply-To: <20250210055945.27192-5-chen.dylane@gmail.com>
On Mon, Feb 10, 2025 at 01:59:45PM +0800, Tao Chen wrote:
> Add selftests for prog_kfunc feature probing.
>
> ./test_progs -t libbpf_probe_kfuncs
> #153 libbpf_probe_kfuncs:OK
> Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
>
> Signed-off-by: Tao Chen <chen.dylane@gmail.com>
> ---
> .../selftests/bpf/prog_tests/libbpf_probes.c | 118 ++++++++++++++++++
> 1 file changed, 118 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/libbpf_probes.c b/tools/testing/selftests/bpf/prog_tests/libbpf_probes.c
> index 4ed46ed58a7b..fc4c9dc2cbed 100644
> --- a/tools/testing/selftests/bpf/prog_tests/libbpf_probes.c
> +++ b/tools/testing/selftests/bpf/prog_tests/libbpf_probes.c
> @@ -126,3 +126,121 @@ void test_libbpf_probe_helpers(void)
> ASSERT_EQ(res, d->supported, buf);
> }
> }
> +
> +static int module_btf_fd(char *module)
> +{
> + int fd, err;
> + __u32 id = 0, len;
> + struct bpf_btf_info info;
> + char name[64];
> +
> + while (true) {
> + err = bpf_btf_get_next_id(id, &id);
> + if (err && (errno == ENOENT || errno == EPERM))
> + return 0;
> + if (err) {
> + err = -errno;
> + return err;
> + }
> + fd = bpf_btf_get_fd_by_id(id);
> + if (fd < 0) {
> + if (errno == ENOENT)
> + continue;
> + err = -errno;
> + return err;
nit, return -errno ?
jirka
> + }
> + len = sizeof(info);
> + memset(&info, 0, sizeof(info));
> + info.name = ptr_to_u64(name);
> + info.name_len = sizeof(name);
> + err = bpf_btf_get_info_by_fd(fd, &info, &len);
> + if (err) {
> + err = -errno;
> + goto err_out;
> + }
> + /* find target module btf */
> + if (!strcmp(name, module))
> + break;
> +
> + close(fd);
> + }
> +
> + return fd;
> +err_out:
> + close(fd);
> + return err;
> +}
SNIP
next prev parent reply other threads:[~2025-02-10 13:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 5:59 [PATCH bpf-next v5 0/4] Add prog_kfunc feature probe Tao Chen
2025-02-10 5:59 ` [PATCH bpf-next v5 1/4] libbpf: Extract prog load type check from libbpf_probe_bpf_helper Tao Chen
2025-02-10 5:59 ` [PATCH bpf-next v5 2/4] libbpf: Init fd_array when prog probe load Tao Chen
2025-02-10 5:59 ` [PATCH bpf-next v5 3/4] libbpf: Add libbpf_probe_bpf_kfunc API Tao Chen
2025-02-10 13:47 ` Jiri Olsa
2025-02-10 15:19 ` Tao Chen
2025-02-10 5:59 ` [PATCH bpf-next v5 4/4] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests Tao Chen
2025-02-10 13:47 ` Jiri Olsa [this message]
2025-02-10 15:11 ` Tao Chen
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=Z6oDXNpqmwHo6lKh@krava \
--to=olsajiri@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=eddyz87@gmail.com \
--cc=haoluo@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox