bpf: Overwrite the htab element atomically
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 13 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | rculist: add hlist_nulls_replace_rcu() helperinclude/ | +42 | 0 replies | |
| 2/3 | bpf: Overwrite the element in hash map atomicallykernel/ | +8 | 13 replies | |
| 3/3 | selftests/bpf: Add test case for atomic htab updatetools/ tools/ | +143 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf-next 0/3] bpf: Overwrite the htab element atomically
Hi,
The motivation for the patch set comes from the question raised by Cody Haas [1]. He asked whether or not the update of htab of map is atomic in the perspective of lookup operation. Currently, the update is not atomic because the overwrite of existing element happens in a two-steps way, but the support of atomic update is feasible. Initiallly, I only plan to support atomic update for htab of map because array of map has already supported that. Afterwards, I think it may be reasonable to support atomic update for all kinds of hash map. However, for the BPF_F_LOCK case, although the update is protected by a spin-lock, the update is still not atomic in the perspective of the lookup operation.
Please see individual patches for details. Comments are always welcome.
---
[1] : https://lore.kernel.org/xdp-newbies/[email protected]/T/#m06fcd687c6cfdbd0f9b643b227e69b479fc8c2f6
Hou Tao (3):
rculist: add hlist_nulls_replace_rcu() helper
bpf: Overwrite the element in hash map atomically selftests/bpf: Add test case for atomic htab update
include/linux/rculist_nulls.h | 42 ++++++ kernel/bpf/hashtab.c | 14 +- .../selftests/bpf/prog_tests/htab_lookup.c | 130 ++++++++++++++++++ .../testing/selftests/bpf/progs/htab_lookup.c | 13 ++ 4 files changed, 193 insertions(+), 6 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/htab_lookup.c create mode 100644 tools/testing/selftests/bpf/progs/htab_lookup.c
Signature · 1 line
2.48.1