From: Jiri Olsa <olsajiri@gmail.com>
To: Ihor Solodrai <ihor.solodrai@linux.dev>
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
bpf@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v3 2/2] selftests/bpf: Update kfuncs using btf_struct_meta to new variants
Date: Thu, 19 Mar 2026 13:30:42 +0100 [thread overview]
Message-ID: <abvscsnSAiLLWBTZ@krava> (raw)
In-Reply-To: <20260318234210.1840295-2-ihor.solodrai@linux.dev>
On Wed, Mar 18, 2026 at 04:42:10PM -0700, Ihor Solodrai wrote:
> Update selftests to use the new non-_impl kfuncs marked with
> KF_IMPLICIT_ARGS by removing redundant declarations and macros from
> bpf_experimental.h (the new kfuncs are present in the vmlinux.h) and
> updating relevant callsites.
>
> Fix spin_lock verifier-log matching for lock_id_kptr_preserve by
> accepting variable instruction numbers. The calls to kfuncs with
> implicit arguments do not have register moves (e.g. r5 = 0)
> corresponding to dummy arguments anymore, so the order of instructions
> has shifted.
>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> ---
> .../testing/selftests/bpf/bpf_experimental.h | 156 +-----------------
> .../selftests/bpf/prog_tests/spin_lock.c | 5 +-
> .../selftests/bpf/progs/kptr_xchg_inline.c | 4 +-
> 3 files changed, 9 insertions(+), 156 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
> index 44466acf8083..2234bd6bc9d3 100644
> --- a/tools/testing/selftests/bpf/bpf_experimental.h
> +++ b/tools/testing/selftests/bpf/bpf_experimental.h
> @@ -8,156 +8,11 @@
>
> #define __contains(name, node) __attribute__((btf_decl_tag("contains:" #name ":" #node)))
>
> -/* Description
> - * Allocates an object of the type represented by 'local_type_id' in
> - * program BTF. User may use the bpf_core_type_id_local macro to pass the
> - * type ID of a struct in program BTF.
> - *
> - * The 'local_type_id' parameter must be a known constant.
> - * The 'meta' parameter is rewritten by the verifier, no need for BPF
> - * program to set it.
> - * Returns
> - * A pointer to an object of the type corresponding to the passed in
> - * 'local_type_id', or NULL on failure.
> - */
> -extern void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym;
> -
> -/* Convenience macro to wrap over bpf_obj_new_impl */
> -#define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL))
> -
> -/* Description
> - * Free an allocated object. All fields of the object that require
> - * destruction will be destructed before the storage is freed.
> - *
> - * The 'meta' parameter is rewritten by the verifier, no need for BPF
> - * program to set it.
> - * Returns
> - * Void.
> - */
> -extern void bpf_obj_drop_impl(void *kptr, void *meta) __ksym;
> -
> -/* Convenience macro to wrap over bpf_obj_drop_impl */
> -#define bpf_obj_drop(kptr) bpf_obj_drop_impl(kptr, NULL)
> -
> -/* Description
> - * Increment the refcount on a refcounted local kptr, turning the
> - * non-owning reference input into an owning reference in the process.
> - *
> - * The 'meta' parameter is rewritten by the verifier, no need for BPF
> - * program to set it.
> - * Returns
> - * An owning reference to the object pointed to by 'kptr'
> - */
> -extern void *bpf_refcount_acquire_impl(void *kptr, void *meta) __ksym;
> -
> -/* Convenience macro to wrap over bpf_refcount_acquire_impl */
> -#define bpf_refcount_acquire(kptr) bpf_refcount_acquire_impl(kptr, NULL)
> -
> -/* Description
> - * Add a new entry to the beginning of the BPF linked list.
> - *
> - * The 'meta' and 'off' parameters are rewritten by the verifier, no need
> - * for BPF programs to set them
> - * Returns
> - * 0 if the node was successfully added
> - * -EINVAL if the node wasn't added because it's already in a list
> - */
> -extern int bpf_list_push_front_impl(struct bpf_list_head *head,
> - struct bpf_list_node *node,
> - void *meta, __u64 off) __ksym;
> -
> -/* Convenience macro to wrap over bpf_list_push_front_impl */
> -#define bpf_list_push_front(head, node) bpf_list_push_front_impl(head, node, NULL, 0)
> -
> -/* Description
> - * Add a new entry to the end of the BPF linked list.
> - *
> - * The 'meta' and 'off' parameters are rewritten by the verifier, no need
> - * for BPF programs to set them
> - * Returns
> - * 0 if the node was successfully added
> - * -EINVAL if the node wasn't added because it's already in a list
> - */
> -extern int bpf_list_push_back_impl(struct bpf_list_head *head,
> - struct bpf_list_node *node,
> - void *meta, __u64 off) __ksym;
> -
> -/* Convenience macro to wrap over bpf_list_push_back_impl */
> -#define bpf_list_push_back(head, node) bpf_list_push_back_impl(head, node, NULL, 0)
> -
> -/* Description
> - * Remove the entry at the beginning of the BPF linked list.
> - * Returns
> - * Pointer to bpf_list_node of deleted entry, or NULL if list is empty.
> - */
> -extern struct bpf_list_node *bpf_list_pop_front(struct bpf_list_head *head) __ksym;
> -
> -/* Description
> - * Remove the entry at the end of the BPF linked list.
> - * Returns
> - * Pointer to bpf_list_node of deleted entry, or NULL if list is empty.
> - */
> -extern struct bpf_list_node *bpf_list_pop_back(struct bpf_list_head *head) __ksym;
> -
> -/* Description
> - * Remove 'node' from rbtree with root 'root'
> - * Returns
> - * Pointer to the removed node, or NULL if 'root' didn't contain 'node'
> - */
> -extern struct bpf_rb_node *bpf_rbtree_remove(struct bpf_rb_root *root,
> - struct bpf_rb_node *node) __ksym;
> -
> -/* Description
> - * Add 'node' to rbtree with root 'root' using comparator 'less'
> - *
> - * The 'meta' and 'off' parameters are rewritten by the verifier, no need
> - * for BPF programs to set them
> - * Returns
> - * 0 if the node was successfully added
> - * -EINVAL if the node wasn't added because it's already in a tree
> - */
> -extern int bpf_rbtree_add_impl(struct bpf_rb_root *root, struct bpf_rb_node *node,
> - bool (less)(struct bpf_rb_node *a, const struct bpf_rb_node *b),
> - void *meta, __u64 off) __ksym;
> -
> -/* Convenience macro to wrap over bpf_rbtree_add_impl */
> -#define bpf_rbtree_add(head, node, less) bpf_rbtree_add_impl(head, node, less, NULL, 0)
> +/* Convenience macro to wrap over bpf_obj_new */
> +#define bpf_obj_new(type) ((type *)bpf_obj_new(bpf_core_type_id_local(type)))
>
> -/* Description
> - * Return the first (leftmost) node in input tree
> - * Returns
> - * Pointer to the node, which is _not_ removed from the tree. If the tree
> - * contains no nodes, returns NULL.
> - */
> -extern struct bpf_rb_node *bpf_rbtree_first(struct bpf_rb_root *root) __ksym;
> -
> -/* Description
> - * Allocates a percpu object of the type represented by 'local_type_id' in
> - * program BTF. User may use the bpf_core_type_id_local macro to pass the
> - * type ID of a struct in program BTF.
> - *
> - * The 'local_type_id' parameter must be a known constant.
> - * The 'meta' parameter is rewritten by the verifier, no need for BPF
> - * program to set it.
> - * Returns
> - * A pointer to a percpu object of the type corresponding to the passed in
> - * 'local_type_id', or NULL on failure.
> - */
> -extern void *bpf_percpu_obj_new_impl(__u64 local_type_id, void *meta) __ksym;
> -
> -/* Convenience macro to wrap over bpf_percpu_obj_new_impl */
> -#define bpf_percpu_obj_new(type) ((type __percpu_kptr *)bpf_percpu_obj_new_impl(bpf_core_type_id_local(type), NULL))
> -
> -/* Description
> - * Free an allocated percpu object. All fields of the object that require
> - * destruction will be destructed before the storage is freed.
> - *
> - * The 'meta' parameter is rewritten by the verifier, no need for BPF
> - * program to set it.
> - * Returns
> - * Void.
> - */
> -extern void bpf_percpu_obj_drop_impl(void *kptr, void *meta) __ksym;
> +/* Convenience macro to wrap over bpf_percpu_obj_new */
> +#define bpf_percpu_obj_new(type) ((type __percpu_kptr *)bpf_percpu_obj_new(bpf_core_type_id_local(type)))
nit, seems like a shame to remove all the comments which are still
valid, maybe we could leave those externs with comments and just
drop the _impl suffix
jirka
next prev parent reply other threads:[~2026-03-19 12:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 23:42 [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS Ihor Solodrai
2026-03-18 23:42 ` [PATCH bpf-next v3 2/2] selftests/bpf: Update kfuncs using btf_struct_meta to new variants Ihor Solodrai
2026-03-19 12:30 ` Jiri Olsa [this message]
2026-03-19 20:43 ` Ihor Solodrai
2026-03-20 11:06 ` Jiri Olsa
2026-03-20 14:50 ` Mykyta Yatsenko
2026-03-19 12:25 ` [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS Jiri Olsa
2026-03-19 20:37 ` Ihor Solodrai
2026-03-20 15:49 ` Mykyta Yatsenko
2026-03-27 0:16 ` Ihor Solodrai
2026-03-27 19:19 ` Mykyta Yatsenko
2026-03-21 20:27 ` Alexei Starovoitov
2026-03-23 19:58 ` Ihor Solodrai
2026-03-24 17:22 ` Alexei Starovoitov
2026-03-26 19:13 ` Ihor Solodrai
2026-03-27 20:48 ` Alexei Starovoitov
2026-03-27 20:55 ` Ihor Solodrai
2026-03-27 21:00 ` Alexei Starovoitov
2026-03-27 21:08 ` Ihor Solodrai
2026-03-27 21:47 ` Alexei Starovoitov
2026-03-27 22:06 ` Ihor Solodrai
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=abvscsnSAiLLWBTZ@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.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