From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, 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,
leon.hwang@linux.dev, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, donggeunyoo.kernel@gmail.com
Subject: [PATCH bpf v3 0/2] bpf: fix per-cpu initialization of a BPF_F_CPU created hash element
Date: Thu, 24 Sep 2026 19:23:19 +0900 [thread overview]
Message-ID: <20260924102321.2120434-1-donggeunyoo.kernel@gmail.com> (raw)
A BPF_F_CPU update that creates a [lru_]percpu_hash element writes the
named CPU's slot and leaves the others holding the recycled element's
values, so a lookup of the new key returns a deleted key's per-cpu
values.
Patch 1 zero-fills the other CPUs. Patch 2 adds the selftest: the
existing cpu_flag subtests always prime a key with BPF_F_ALL_CPUS
first, so the create path is not covered today.
v1: https://lore.kernel.org/bpf/20260920093153.439743-1-donggeunyoo.kernel@gmail.com/
v2: https://lore.kernel.org/bpf/20260923000801.1764758-1-donggeunyoo.kernel@gmail.com/
Changes in v3:
- patch 1: key init_cpu on BPF_F_CPU rather than on onallcpus (Leon
Hwang)
- patch 1: re-flow the paragraph naming pcpu_copy_value() (BPF CI AI
review)
- patch 2: pin the thread across the delete and the create, and name a
CPU other than the pinned one, so the BPF_F_NO_PREALLOC arm does not
depend on staying put (BPF CI AI review)
Changes in v2:
- patch 1: cover the BPF_F_CPU entry condition in the block comment
above pcpu_init_value() (BPF CI AI review, Alexei Starovoitov)
- patch 2: skip the new subtests instead of failing them on a
uniprocessor machine (Sashiko AI review)
test_progs -t percpu_alloc and fourteen neighboring map tests, x86_64
under QEMU/KVM, 4 vCPUs:
without patch 1 31/112 PASSED, 1/3 FAILED
with patch 1 32/115 PASSED, 0/0 FAILED
Donggeun Yoo (2):
bpf: Zero-fill other CPUs when BPF_F_CPU creates a per-cpu hash
element
selftests/bpf: Test per-cpu initialization of a BPF_F_CPU created
element
kernel/bpf/hashtab.c | 11 +-
.../selftests/bpf/prog_tests/percpu_alloc.c | 105 ++++++++++++++++++
2 files changed, 112 insertions(+), 4 deletions(-)
--
2.53.0
next reply other threads:[~2026-09-24 10:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 10:23 Donggeun Yoo [this message]
2026-09-24 10:23 ` [PATCH bpf v3 1/2] bpf: Zero-fill other CPUs when BPF_F_CPU creates a per-cpu " Donggeun Yoo
2026-09-24 10:23 ` [PATCH bpf v3 2/2] selftests/bpf: Test per-cpu initialization of a BPF_F_CPU created element Donggeun Yoo
2026-09-24 14:30 ` [PATCH bpf v3 0/2] bpf: fix per-cpu initialization of a BPF_F_CPU created hash element 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=20260924102321.2120434-1-donggeunyoo.kernel@gmail.com \
--to=donggeunyoo.kernel@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.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®