Re: [PATCH v6 2/5] bpf/verifier: allow using bpf_kptr_xchg even if the NON_OWN_REF flag is set
From: Alexei Starovoitov
Date: Wed Feb 11 2026 - 20:50:59 EST
On Sat, Feb 7, 2026 at 6:49 PM Chengkaitao <pilgrimtao@xxxxxxxxx> wrote:
>
> From: Kaitao Cheng <chengkaitao@xxxxxxxxxx>
>
> When traversing an rbtree using bpf_rbtree_left/right, if bpf_kptr_xchg
> is used to access the __kptr pointer contained in a node, it currently
> requires first removing the node with bpf_rbtree_remove and clearing the
> NON_OWN_REF flag, then re-adding the node to the original rbtree with
> bpf_rbtree_add after usage. This process significantly degrades rbtree
> traversal performance. The patch enables accessing __kptr pointers with
> the NON_OWN_REF flag set while holding the lock, eliminating the need
> for this remove-read-add sequence.
>
> Signed-off-by: Kaitao Cheng <chengkaitao@xxxxxxxxxx>
> Signed-off-by: Feng Yang <yangfeng@xxxxxxxxxx>
> ---
> kernel/bpf/verifier.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 05a6a6606b6c..bb3ff4bbb3a2 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -9260,7 +9260,8 @@ static const struct bpf_reg_types timer_types = { .types = { PTR_TO_MAP_VALUE }
> static const struct bpf_reg_types kptr_xchg_dest_types = {
> .types = {
> PTR_TO_MAP_VALUE,
> - PTR_TO_BTF_ID | MEM_ALLOC
> + PTR_TO_BTF_ID | MEM_ALLOC,
> + PTR_TO_BTF_ID | MEM_ALLOC | NON_OWN_REF
add a comma, so the next patch doesn't need to add it and
has less churn.
PTR_TO_BTF_ID | MEM_ALLOC | NON_OWN_REF | MEM_RCU , <-- comma too
Also don't invent new prefixes.
Either "bpf: ..." or "selftests/bpf: ...".
pw-bot: cr