From: Tao Chen <chen.dylane@gmail.com>
To: Jiri Olsa <olsajiri@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 v3 3/3] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests
Date: Sat, 25 Jan 2025 22:56:30 +0800 [thread overview]
Message-ID: <63f24d23-2efd-4fb2-a637-68765b1f7df9@gmail.com> (raw)
In-Reply-To: <Z5O_bNToXdn01f4B@krava>
在 2025/1/25 00:27, Jiri Olsa 写道:
> On Fri, Jan 24, 2025 at 10:44:11PM +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 | 35 +++++++++++++++++++
>> 1 file changed, 35 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..d9d69941f694 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/libbpf_probes.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/libbpf_probes.c
>> @@ -126,3 +126,38 @@ void test_libbpf_probe_helpers(void)
>> ASSERT_EQ(res, d->supported, buf);
>> }
>> }
>> +
>> +void test_libbpf_probe_kfuncs(void)
>> +{
>> + int ret, kfunc_id;
>> + char *kfunc = "bpf_cpumask_create";
>> + struct btf *btf;
>> +
>> + btf = btf__parse("/sys/kernel/btf/vmlinux", NULL);
>> + if (!ASSERT_OK_PTR(btf, "btf_parse"))
>> + return;
>> +
>> + kfunc_id = btf__find_by_name_kind(btf, kfunc, BTF_KIND_FUNC);
>> + if (!ASSERT_GT(kfunc_id, 0, kfunc))
>> + goto cleanup;
>> +
>> + /* prog BPF_PROG_TYPE_SYSCALL supports kfunc bpf_cpumask_create */
>> + ret = libbpf_probe_bpf_kfunc(BPF_PROG_TYPE_SYSCALL, kfunc_id, 0, NULL);
>> + ASSERT_EQ(ret, 1, kfunc);
>> +
>> + /* prog BPF_PROG_TYPE_KPROBE does not support kfunc bpf_cpumask_create */
>> + ret = libbpf_probe_bpf_kfunc(BPF_PROG_TYPE_KPROBE, kfunc_id, 0, NULL);
>> + ASSERT_EQ(ret, 0, kfunc);
>> +
>> + /* invalid kfunc id */
>> + ret = libbpf_probe_bpf_kfunc(BPF_PROG_TYPE_KPROBE, -1, 0, NULL);
>> + ASSERT_EQ(ret, 0, "invalid kfunc id:-1");
>> +
>> + /* invalid prog type */
>> + ret = libbpf_probe_bpf_kfunc(100000, kfunc_id, 0, NULL);
>> + if (!ASSERT_LE(ret, 0, "invalid prog type:100000"))
>> + goto cleanup;
>
> nit no need for the goto
>
> jirka
>
Ack. Will fix.
>> +
>> +cleanup:
>> + btf__free(btf);
>> +}
>> --
>> 2.43.0
>>
--
Best Regards
Dylane Chen
next prev parent reply other threads:[~2025-01-25 14:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 14:44 [PATCH bpf-next v3 0/3] Add prog_kfunc feature probe Tao Chen
2025-01-24 14:44 ` [PATCH bpf-next v3 1/3] libbpf: Refactor libbpf_probe_bpf_helper Tao Chen
2025-01-24 16:26 ` Jiri Olsa
2025-01-25 14:52 ` Tao Chen
2025-01-24 18:44 ` Andrii Nakryiko
2025-01-25 15:05 ` Tao Chen
2025-01-24 14:44 ` [PATCH bpf-next v3 2/3] libbpf: Add libbpf_probe_bpf_kfunc API Tao Chen
2025-01-24 16:27 ` Jiri Olsa
2025-01-25 14:54 ` Tao Chen
2025-01-24 18:46 ` Andrii Nakryiko
2025-01-24 14:44 ` [PATCH bpf-next v3 3/3] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests Tao Chen
2025-01-24 16:27 ` Jiri Olsa
2025-01-25 14:56 ` Tao Chen [this message]
2025-01-24 18:48 ` Andrii Nakryiko
2025-01-25 15:07 ` 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=63f24d23-2efd-4fb2-a637-68765b1f7df9@gmail.com \
--to=chen.dylane@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olsajiri@gmail.com \
--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