public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 bpf 0/2] bpf: skip non exist keys in generic_map_lookup_batch
@ 2025-02-10  7:22 Yan Zhai
  2025-02-10  7:22 ` [PATCH v3 bpf 1/2] " Yan Zhai
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yan Zhai @ 2025-02-10  7:22 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Mykola Lysenko, Shuah Khan, Yan Zhai, Brian Vazquez, linux-kernel,
	linux-kselftest, kernel-team, Hou Tao

The generic_map_lookup_batch currently returns EINTR if it fails with
ENOENT and retries several times on bpf_map_copy_value. The next batch
would start from the same location, presuming it's a transient issue.
This is incorrect if a map can actually have "holes", i.e.
"get_next_key" can return a key that does not point to a valid value. At
least the array of maps type may contain such holes legitly. Right now
these holes show up, generic batch lookup cannot proceed any more. It
will always fail with EINTR errors.

This patch fixes this behavior by skipping the non-existing key, and
does not return EINTR any more.

V2->V3: deleted a unused macro
V1->V2: split the fix and selftests; fixed a few selftests issues.

V2: https://lore.kernel.org/bpf/cover.1738905497.git.yan@cloudflare.com/
V1: https://lore.kernel.org/bpf/Z6OYbS4WqQnmzi2z@debian.debian/

Yan Zhai (2):
  bpf: skip non exist keys in generic_map_lookup_batch
  selftests: bpf: test batch lookup on array of maps with holes

 kernel/bpf/syscall.c                          | 18 ++----
 .../bpf/map_tests/map_in_map_batch_ops.c      | 62 +++++++++++++------
 2 files changed, 49 insertions(+), 31 deletions(-)

-- 
2.39.5



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-02-19  1:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-10  7:22 [PATCH v3 bpf 0/2] bpf: skip non exist keys in generic_map_lookup_batch Yan Zhai
2025-02-10  7:22 ` [PATCH v3 bpf 1/2] " Yan Zhai
2025-02-10  9:19   ` Jiri Olsa
2025-02-10 14:47     ` Brian Vazquez
2025-02-10 16:21       ` Yan Zhai
2025-02-12 17:04         ` Jiri Olsa
2025-02-10  7:22 ` [PATCH v3 bpf 2/2] selftests: bpf: test batch lookup on array of maps with holes Yan Zhai
2025-02-19  1:40 ` [PATCH v3 bpf 0/2] bpf: skip non exist keys in generic_map_lookup_batch patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox