All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
	eddyz87@gmail.com, kernel-team@fb.com, martin.lau@kernel.org,
	clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v3 10/11] selftests/bpf: Test kfuncs returning arena pointers by value
Date: Fri, 28 Aug 2026 11:28:42 -0700	[thread overview]
Message-ID: <42faf6da-b782-44f1-ab0b-767c703dd523@linux.dev> (raw)
In-Reply-To: <465f8ac0b4ab71a0d3939e6bded8e52a1a1e54e7c6d57ef7447b1dad571ce9ae@mail.kernel.org>



On 8/27/26 12:17 AM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/tools/testing/selftests/bpf/progs/aggregate_ret_kfunc_arena.c b/tools/testing/selftests/bpf/progs/aggregate_ret_kfunc_arena.c
>> new file mode 100644
>> index 0000000000000..94c35e1b547cd
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/progs/aggregate_ret_kfunc_arena.c
>> @@ -0,0 +1,129 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
>> +#include <vmlinux.h>
>> +#include <bpf/bpf_helpers.h>
>> +#include <bpf_arena_common.h>
>> +#include "bpf_misc.h"
>> +#include "../test_kmods/bpf_testmod_kfunc.h"
>> +
>> +#if defined(__clang_major__) && __clang_major__ >= 23
>> +
>> +struct {
>> +	__uint(type, BPF_MAP_TYPE_ARENA);
>> +	__uint(map_flags, BPF_F_MMAPABLE);
>> +	__uint(max_entries, 2);
>> +} arena SEC(".maps");
>> +
>> +/*
>> + * A returned member carries the arena type tag but not the address space
>> + * qualifier, so the program casts it into the arena address space itself
>> + * rather than the compiler doing it.
>> + */
>> +#define arena_ptr(p) ((u32 volatile __arena *)(p))
> This isn't a bug, but could the cast be spelled out at each use site, or
> the macro named after the type it produces (e.g. arena_u32p())? The name
> arena_ptr() reads as a generic address-space cast, but it hardcodes 'u32
> volatile', which matters for the load/store widths the test checks. Other
> arena selftest programs write the cast inline with the type visible at the
> use site (for example '(char __arena *)ptr' in progs/arena_mem_usage.c).

Okay, let us inline arena_ptr(p) directly in the code.

>
>> +
>> +SEC("syscall")
>> +__arch_x86_64 __arch_arm64
>> +__load_if_JITed()
>> +__success __retval(0)
>> +int aggregate_ret_kfunc_arena(void *ctx)
>> +{
>> +	u32 volatile __arena *page = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
>> +	u32 volatile __arena *a, *b;
>> +	struct prog_test_ret_arena r;
>> +
>> +	if (!page)
>> +		return 1;
>> +
>> +	/* Both halves come back in R0:R2, pointing at page and page + 4. */
>> +	r = bpf_kfunc_call_test_ret_arena((u64)page);
>> +	if (!r.a || !r.b)
>> +		return 2;
>> +
>> +	a = arena_ptr(r.a);
>> +	b = arena_ptr(r.b);
>> +	*a = 1;
>> +	*b = 2;
>> +	if (*a != 1)
>> +		return 3;
>> +	if (*b != 2)
>> +		return 4;
>> +
>> +	/* The halves are the first two slots of the page the program allocated. */
>> +	page[0] = 7;
>> +	if (*a != 7)
>> +		return 5;
>> +	page[1] = 9;
>> +	if (*b != 9)
>> +		return 6;
>> +
>> +	return 0;
>> +}
> [ ... ]
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/33045482525


  reply	other threads:[~2026-08-28 18:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27  6:11 [PATCH bpf-next v3 00/11] bpf: Allow arena pointers in by-value returns Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 01/11] bpf: Record each half of a paired return value in verifier diagnostics Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 02/11] bpf: Drop the recursion depth argument of btf_type_is_scalar_struct() Yonghong Song
2026-08-27  7:04   ` bot+bpf-ci
2026-08-28 17:39     ` Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 03/11] bpf: Add btf_type_is_arena_ptr() Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 04/11] bpf: Let the by-value struct walk take the kinds of member it accepts Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 05/11] bpf: Report which member makes a kfunc return type unsupported Yonghong Song
2026-08-27  7:04   ` bot+bpf-ci
2026-08-28 17:45     ` Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 06/11] bpf: Allow a global function to return arena pointers by value Yonghong Song
2026-08-27  6:33   ` sashiko-bot
2026-08-28 18:00     ` Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 07/11] bpf: Allow arena pointers in a by-value kfunc return Yonghong Song
2026-08-27  6:55   ` sashiko-bot
2026-08-28 18:10     ` Yonghong Song
2026-08-27  6:11 ` [PATCH bpf-next v3 08/11] selftests/bpf: Check the member named for an unsupported kfunc return type Yonghong Song
2026-08-27  7:04   ` bot+bpf-ci
2026-08-28 18:20     ` Yonghong Song
2026-08-27  6:12 ` [PATCH bpf-next v3 09/11] selftests/bpf: Test global functions returning arena pointers by value Yonghong Song
2026-08-27  7:04   ` bot+bpf-ci
2026-08-28 18:26     ` Yonghong Song
2026-08-27  6:12 ` [PATCH bpf-next v3 10/11] selftests/bpf: Test kfuncs " Yonghong Song
2026-08-27  7:17   ` bot+bpf-ci
2026-08-28 18:28     ` Yonghong Song [this message]
2026-08-27  6:12 ` [PATCH bpf-next v3 11/11] docs/bpf: Document arena pointers in a by-value return Yonghong Song

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=42faf6da-b782-44f1-ab0b-767c703dd523@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.