Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, "Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Song Liu" <song@kernel.org>, Eduard <eddyz87@gmail.com>,
	"Daniel Xu" <dxu@dxuuu.xyz>, "Daniel Müller" <deso@posteo.net>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Hao Luo" <haoluo@google.com>, "Shuah Khan" <shuah@kernel.org>,
	"Jason Xing" <kerneljasonxing@gmail.com>,
	"Tao Chen" <chen.dylane@linux.dev>,
	"Willem de Bruijn" <willemb@google.com>,
	"Paul Chaignon" <paul.chaignon@gmail.com>,
	"Anton Protopopov" <a.s.protopopov@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Mykyta Yatsenko" <yatsenko@meta.com>,
	"Tobias Klauser" <tklauser@distanz.ch>,
	kernel-patches-bot@fb.com, LKML <linux-kernel@vger.kernel.org>,
	"open list:KERNEL SELFTEST FRAMEWORK"
	<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH bpf-next v10 8/8] selftests/bpf: Add cases to test BPF_F_CPU and BPF_F_ALL_CPUS flags
Date: Mon, 24 Nov 2025 22:23:53 +0800	[thread overview]
Message-ID: <5a633862-ae0e-43ba-8da6-0f03efd01bde@linux.dev> (raw)
In-Reply-To: <CAADnVQLARr69Qv9EfwWkpudXLZNb21zYd86aPux_Fv3UAsrLGw@mail.gmail.com>



On 2025/11/22 10:34, Alexei Starovoitov wrote:
> On Mon, Nov 17, 2025 at 8:22 AM Leon Hwang <leon.hwang@linux.dev> wrote:
>>

[...]

>> +
>> +                       /* lookup then check value on CPUs */
>> +                       for (j = 0; j < nr_cpus; j++) {
>> +                               flags = (u64)j << 32 | BPF_F_CPU;
>> +                               err = bpf_map__lookup_elem(map, keys + i * key_sz, key_sz, values,
>> +                                                          value_sz, flags);
>> +                               if (!ASSERT_OK(err, "bpf_map__lookup_elem specified cpu"))
>> +                                       goto out;
>> +                               if (!ASSERT_EQ(values[0], j != cpu ? 0 : value,
>> +                                              "bpf_map__lookup_elem value on specified cpu"))
>> +                                       goto out;
> 
> I was about to apply it, but noticed that the test is unstable.
> It fails 1 out of 10 for me in the above line.
> test_percpu_map_op_cpu_flag:PASS:bpf_map_lookup_batch value on
> specified cpu 0 nsec
> test_percpu_map_op_cpu_flag:FAIL:bpf_map_lookup_batch value on
> specified cpu unexpected bpf_map_lookup_batch value on specified cpu:
> actual 0 != expected 3735929054
> #261/15  percpu_alloc/cpu_flag_lru_percpu_hash:FAIL
> #261     percpu_alloc:FAIL
> 
> Please investigate what is going on.
> 

I was able to reproduce the failure on a 16-core VM.

It appears to be caused by LRU eviction. When I increased max_entries of
the lru_percpu_hash map to libbpf_num_possible_cpus(), the issue no
longer reproduced.

I'll need to spend more time investigating the exact eviction behavior
and why it shows up intermittently in this test.

Thanks,
Leon

      reply	other threads:[~2025-11-24 14:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 16:20 [PATCH bpf-next v10 0/8] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags for percpu maps Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 1/8] bpf: Introduce internal bpf_map_check_op_flags helper function Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 2/8] bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 3/8] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_array maps Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 4/8] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_hash and lru_percpu_hash maps Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 5/8] bpf: Copy map value using copy_map_value_long for percpu_cgroup_storage maps Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 6/8] bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support " Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 7/8] libbpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu maps Leon Hwang
2025-11-17 16:20 ` [PATCH bpf-next v10 8/8] selftests/bpf: Add cases to test BPF_F_CPU and BPF_F_ALL_CPUS flags Leon Hwang
2025-11-22  2:34   ` Alexei Starovoitov
2025-11-24 14:23     ` Leon Hwang [this message]

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=5a633862-ae0e-43ba-8da6-0f03efd01bde@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=a.s.protopopov@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chen.dylane@linux.dev \
    --cc=daniel@iogearbox.net \
    --cc=deso@posteo.net \
    --cc=dxu@dxuuu.xyz \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-patches-bot@fb.com \
    --cc=kerneljasonxing@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=paul.chaignon@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=tklauser@distanz.ch \
    --cc=willemb@google.com \
    --cc=yatsenko@meta.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox