Skip to content

bpf: skip non exist keys in generic_map_lookup_batch

Yan Zhai bpf linux-kselftest lkml 2 versions – Applied

Status from this message: This series was applied to bpf/bpf.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 4 repliesApplied 2/2
  2. v22 patches 3 repliesSuperseded

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: skip non exist keys in generic_map_lookup_batchkernel/bpf/syscall.c+5 -134 repliesApplied
2/2selftests: bpf: test batch lookup on array of maps with holestools/testing/selftests/bpf/map_tests/map_in_map_batch_ops.c+44 -180 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchHou Tao
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 bpf 0/2] bpf: skip non exist keys in generic_map_lookup_batch

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/[email protected]/
V1: https://lore.kernel.org/bpf/[email protected]/

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(-)
Signature · 1 line
2.39.5