All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
	andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
	martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
	jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
	qmo@kernel.org, shuah@kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, martin.lau@kernel.org,
	clm@meta.com
Subject: Re: [PATCH bpf-next 4/5] selftests/bpf: Avoid flaky resize value test for percpu data
Date: Mon, 17 Aug 2026 14:28:19 +0800	[thread overview]
Message-ID: <9de86d80-59f9-45cb-a684-42ec7d2831b9@linux.dev> (raw)
In-Reply-To: <49f1c39a9af6f07357e66657ca1020e57684036626ef1f180a803f148f8eefe4@mail.kernel.org>

On 15/8/26 02:24, bot+bpf-ci@kernel.org wrote:
>> diff --git a/tools/testing/selftests/bpf/prog_tests/global_data_init.c b/tools/testing/selftests/bpf/prog_tests/global_data_init.c
>> index 7d6bda909295..2f0dbeb88934 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/global_data_init.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> 
> [ ... ]
> 
>> @@ -126,11 +123,11 @@ static void test_percpu_data_on_cpus(struct bpf_map *map, int map_fd, int prog_f
>>  static void test_global_percpu_data_init(void)
>>  {
>>  	struct test_global_percpu_data__percpu init_value = {};
>> +	const __u32 desired_sz = sysconf(_SC_PAGE_SIZE) * 2;
>>  	struct test_global_percpu_data__percpu *init_data;
>> -	const __u32 desired_sz = sysconf(_SC_PAGE_SIZE);
> 
> Does multiplying by 2 here break the test on 64K page systems?
> 
> Per-CPU array value sizes are capped by the kernel:
> 
>   /* percpu map value size is bound by PCPU_MIN_UNIT_SIZE */
>   if (percpu && round_up(attr->value_size, 8) > PCPU_MIN_UNIT_SIZE)
>           return -E2BIG;
> 
> in kernel/bpf/arraymap.c:array_map_alloc_check(), where PCPU_MIN_UNIT_SIZE
> is defined as:
> 
>   #define PCPU_MIN_UNIT_SIZE  PFN_ALIGN(32 << 10)
> 
> which equals max(32768, PAGE_SIZE).
> 
> The old code was safe by construction: desired_sz == PAGE_SIZE <=
> PFN_ALIGN(32768) == PCPU_MIN_UNIT_SIZE. Doubling it breaks that:
> 
>   PAGE_SIZE  4096 -> limit 32768, request   8192  OK
>   PAGE_SIZE 16384 -> limit 32768, request  32768  OK (exactly at limit)
>   PAGE_SIZE 65536 -> limit 65536, request 131072  -E2BIG
> 
> On kernels built with 64K pages (arm64 CONFIG_ARM64_64K_PAGES, ppc64)
> bpf_map__set_value_size() still succeeds (it is purely userspace
> bookkeeping), all four assertions that follow it pass, and then map
> creation fails inside test_global_percpu_data__load():
> 
>>  	err = test_global_percpu_data__load(skel);
>>  	if (!ASSERT_OK(err, "test_global_percpu_data__load"))
>>  		goto out;
> 
> The "global_percpu_data/init" subtest fails, and test_percpu_data_on_cpus()
> is never reached. That is a new failure introduced by this patch (with
> desired_sz == PAGE_SIZE the same configuration created a 65536-byte per-CPU
> value, which is exactly at the limit and accepted).
> 
> Note that the neighbouring resize test in global_map_resize.c deliberately
> does not scale a per-CPU map by page size for this reason. At line 46 it
> uses:
> 
>   new_sz = sizeof(skel->data_percpu_arr->percpu_arr[0]) *
>            libbpf_num_possible_cpus();
> 
> A size that is independent of PAGE_SIZE would still force the mmap region
> to move, which is what the new skel->percpu_arr reassignment and the
> arr[0] == -1 check are there to exercise, without hitting the per-CPU
> allocator bound.
> 

To avoid breaking the test on 64K page systems, run the resize subtest
only on 4K page systems.

From maintenance view, I think it's better to add a dedicated subtest to
test bpf_map__set_value_size() for percpu data. Then, it will be able to
skip the subtest when sysconf(_SC_PAGE_SIZE) != 4K.

Thanks,
Leon


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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 17:32 [PATCH bpf-next 0/5] bpf: Followups for global percpu data series Leon Hwang
2026-08-14 17:32 ` [PATCH bpf-next 1/5] bpf: Drop duplicate blank line in verifier Leon Hwang
2026-08-14 20:32   ` Andrii Nakryiko
2026-08-14 17:32 ` [PATCH bpf-next 2/5] libbpf: Avoid unnecessary mmap resize for percpu data maps Leon Hwang
2026-08-14 17:32 ` [PATCH bpf-next 3/5] bpftool: Update comments about skel " Leon Hwang
2026-08-14 20:32   ` Andrii Nakryiko
2026-08-14 17:32 ` [PATCH bpf-next 4/5] selftests/bpf: Avoid flaky resize value test for percpu data Leon Hwang
2026-08-14 18:24   ` bot+bpf-ci
2026-08-17  6:28     ` Leon Hwang [this message]
2026-08-14 17:32 ` [PATCH bpf-next 5/5] selftests/bpf: Improve readability in iter " Leon Hwang
2026-08-14 20:37 ` [PATCH bpf-next 0/5] bpf: Followups for global percpu data series Andrii Nakryiko
2026-08-14 20:40 ` patchwork-bot+netdevbpf

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=9de86d80-59f9-45cb-a684-42ec7d2831b9@linux.dev \
    --to=leon.hwang@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=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=qmo@kernel.org \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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.