From: bot+bpf-ci@kernel.org
To: leon.hwang@linux.dev,bpf@vger.kernel.org
Cc: ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,martin.lau@linux.dev,eddyz87@gmail.com,song@kernel.org,yonghong.song@linux.dev,john.fastabend@gmail.com,kpsingh@kernel.org,sdf@fomichev.me,haoluo@google.com,jolsa@kernel.org,shuah@kernel.org,leon.hwang@linux.dev,skb99@linux.ibm.com,davem@davemloft.net,linux-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,kernel-patches-bot@fb.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next 3/3] selftests/bpf: Add tests to verify no unintended eviction when updating lru hash maps
Date: Tue, 2 Dec 2025 15:56:21 +0000 (UTC) [thread overview]
Message-ID: <09491a8e930081007a29db98e86fae762e662ff371db8267bdd94f8ba45aae39@mail.kernel.org> (raw)
In-Reply-To: <20251202153032.10118-4-leon.hwang@linux.dev>
[-- Attachment #1: Type: text/plain, Size: 2419 bytes --]
> diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> index d0b405eb2..bd29a915b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
> +++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
[ ... ]
> +static void test_lru_hash_map_update_elem(enum bpf_map_type map_type)
> +{
> + int err, map_fd, i, key, nr_cpus, max_entries = 128;
> + u64 *values, value = 0xDEADC0DE;
> +
> + nr_cpus = libbpf_num_possible_cpus();
> + if (!ASSERT_GT(nr_cpus, 0, "libbpf_num_possible_cpus"))
> + return;
> +
> + values = calloc(nr_cpus, sizeof(u64));
[ ... ]
> + err = bpf_map_lookup_elem(map_fd, &key, values);
> + if (!ASSERT_OK(err, "bpf_map_lookup_elem"))
> + goto out;
> + if (!ASSERT_EQ(*values, 0, "bpf_map_lookup_elem value"))
> + goto out;
> +
> + for (key = 1; key < max_entries; key++) {
> + err = bpf_map_lookup_elem(map_fd, &key, values);
> + if (!ASSERT_OK(err, "bpf_map_lookup_elem"))
> + goto out;
> + if (!ASSERT_EQ(*values, value, "bpf_map_lookup_elem value"))
> + goto out;
> + }
When test_lru_hash_map_update_elem() is called with
BPF_MAP_TYPE_LRU_PERCPU_HASH via test_update_lru_percpu_hash_map(),
should all CPU values be checked rather than just *values?
For percpu maps, bpf_map_lookup_elem() returns an array with one value
per CPU. The test allocates space for nr_cpus values but only verifies
the first element. This means values for CPUs 1 through nr_cpus-1 are
not validated.
Looking at tools/testing/selftests/bpf/prog_tests/lookup_and_delete.c,
the pattern for percpu maps is to loop through all CPUs:
for (i = 0; i < nr_cpus; i++) {
val = value[i];
/* check val */
}
For BPF_MAP_TYPE_LRU_HASH this is correct, but for
BPF_MAP_TYPE_LRU_PERCPU_HASH the test may pass even if non-primary
CPUs have incorrect values.
> +
> +out:
> + close(map_fd);
> + free(values);
> +}
> +
> +static void test_update_lru_hash_map(void)
> +{
> + test_lru_hash_map_update_elem(BPF_MAP_TYPE_LRU_HASH);
> +}
> +
> +static void test_update_lru_percpu_hash_map(void)
> +{
> + test_lru_hash_map_update_elem(BPF_MAP_TYPE_LRU_PERCPU_HASH);
> +}
[ ... ]
---
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/19864460617
next prev parent reply other threads:[~2025-12-02 15:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 15:30 [PATCH bpf-next 0/3] bpf: Fix " Leon Hwang
2025-12-02 15:30 ` [PATCH bpf-next 1/3] bpf: Avoid unintended eviction when updating lru_hash maps Leon Hwang
2025-12-02 18:10 ` Alexei Starovoitov
2025-12-03 15:14 ` Leon Hwang
2025-12-02 15:30 ` [PATCH bpf-next 2/3] bpf: Avoid unintended eviction when updating lru_percpu_hash maps Leon Hwang
2025-12-02 15:30 ` [PATCH bpf-next 3/3] selftests/bpf: Add tests to verify no unintended eviction when updating lru hash maps Leon Hwang
2025-12-02 15:56 ` bot+bpf-ci [this message]
2025-12-02 20:44 ` [syzbot ci] Re: bpf: Fix " syzbot ci
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=09491a8e930081007a29db98e86fae762e662ff371db8267bdd94f8ba45aae39@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-patches-bot@fb.com \
--cc=kpsingh@kernel.org \
--cc=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=skb99@linux.ibm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®