From: Eduard Zingerman <eddyz87@gmail.com>
To: Tao Chen <chen.dylane@linux.dev>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
haoluo@google.com, jolsa@kernel.org, qmo@kernel.org
Cc: 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 4/4] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests
Date: Fri, 21 Feb 2025 10:19:53 -0800 [thread overview]
Message-ID: <d3dacc81d79d67f1c4372adc2517176bed57fadd.camel@gmail.com> (raw)
In-Reply-To: <20250221163335.262143-5-chen.dylane@linux.dev>
On Sat, 2025-02-22 at 00:33 +0800, Tao Chen wrote:
[...]
> +static const struct {
> + const char *name;
> + int code;
> +} program_types[] = {
> +#define _T(n) { #n, BPF_PROG_TYPE_##n }
> + _T(KPROBE),
> + _T(XDP),
> + _T(SYSCALL),
> + _T(SCHED_CLS),
> + _T(SCHED_ACT),
> + _T(SK_SKB),
> + _T(SOCKET_FILTER),
> + _T(CGROUP_SKB),
> + _T(LWT_OUT),
> + _T(LWT_IN),
> + _T(LWT_XMIT),
> + _T(LWT_SEG6LOCAL),
> + _T(NETFILTER),
> + _T(CGROUP_SOCK_ADDR),
> + _T(SCHED_ACT)
> +#undef _T
> +};
> +
> +void test_libbpf_probe_kfuncs_many(void)
> +{
Hi Tao,
Sorry, probably some miscommunication from my side.
I did not mean this test for inclusion, it was meant as a one time
manual inspection of libbpf_probe_bpf_kfunc results.
Just as a sanity check before series is merged.
As an automated test it does not provide much meaningful signal.
> + int i, kfunc_id, ret, id;
> + const struct btf_type *t;
> + struct btf *btf = NULL;
> + const char *kfunc;
> + const char *tag;
> +
> + btf = btf__parse("/sys/kernel/btf/vmlinux", NULL);
> + if (!ASSERT_OK_PTR(btf, "btf_parse"))
> + return;
> + for (id = 0; id < btf__type_cnt(btf); ++id) {
> + t = btf__type_by_id(btf, id);
> + if (!t)
> + continue;
> + if (!btf_is_decl_tag(t))
> + continue;
> + tag = btf__name_by_offset(btf, t->name_off);
> + if (strcmp(tag, "bpf_kfunc") != 0)
> + continue;
> + kfunc_id = t->type;
> + t = btf__type_by_id(btf, kfunc_id);
> + if (!btf_is_func(t))
> + continue;
> + kfunc = btf__name_by_offset(btf, t->name_off);
> + for (i = 0; i < ARRAY_SIZE(program_types); ++i) {
> + ret = libbpf_probe_bpf_kfunc(program_types[i].code,
> + kfunc_id, -1, NULL);
> + if (ret < 0) {
> + ASSERT_FAIL("kfunc:%s use prog type:%d",
> + kfunc, program_types[i].code);
> + goto cleanup;
> + }
> + }
> + }
> +cleanup:
> + btf__free(btf);
> +}
next prev parent reply other threads:[~2025-02-21 18:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 16:33 [PATCH bpf-next v8 0/4] Add prog_kfunc feature probe Tao Chen
2025-02-21 16:33 ` [PATCH bpf-next v8 1/4] libbpf: Extract prog load type check from libbpf_probe_bpf_helper Tao Chen
2025-02-21 16:33 ` [PATCH bpf-next v8 2/4] libbpf: Init fd_array when prog probe load Tao Chen
2025-02-21 16:33 ` [PATCH bpf-next v8 3/4] libbpf: Add libbpf_probe_bpf_kfunc API Tao Chen
2025-02-21 16:33 ` [PATCH bpf-next v8 4/4] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests Tao Chen
2025-02-21 18:19 ` Eduard Zingerman [this message]
2025-02-22 3:00 ` 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=d3dacc81d79d67f1c4372adc2517176bed57fadd.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chen.dylane@gmail.com \
--cc=chen.dylane@linux.dev \
--cc=daniel@iogearbox.net \
--cc=dylane.chen@didiglobal.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®