bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] bpf: Overwrite the htab element atomically
@ 2025-02-04  8:28 Hou Tao
  2025-02-04  8:28 ` [PATCH bpf-next 1/3] rculist: add hlist_nulls_replace_rcu() helper Hou Tao
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Hou Tao @ 2025-02-04  8:28 UTC (permalink / raw)
  To: bpf, rcu
  Cc: linux-kernel, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Paul E . McKenney, houtao1, hotforest

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/07a365d8-2e66-2899-4298-b8b158a928fa@huaweicloud.com/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

-- 
2.48.1


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

end of thread, other threads:[~2025-03-06 10:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-04  8:28 [PATCH bpf-next 0/3] bpf: Overwrite the htab element atomically Hou Tao
2025-02-04  8:28 ` [PATCH bpf-next 1/3] rculist: add hlist_nulls_replace_rcu() helper Hou Tao
2025-02-04  8:28 ` [PATCH bpf-next 2/3] bpf: Overwrite the element in hash map atomically Hou Tao
2025-02-05  1:38   ` [RESEND] " Hou Tao
2025-02-06 15:05     ` Toke Høiland-Jørgensen
2025-02-08 10:16       ` Hou Tao
2025-02-26  3:24         ` Alexei Starovoitov
2025-02-26  4:05           ` Hou Tao
2025-02-26  5:42             ` Alexei Starovoitov
2025-02-26 23:17               ` Zvi Effron
2025-02-27  1:48                 ` Hou Tao
2025-02-27  1:59                   ` Alexei Starovoitov
2025-02-27  2:43                     ` Hou Tao
2025-02-27  3:17                       ` Alexei Starovoitov
2025-02-27  4:08                         ` Hou Tao
2025-03-06 10:22                         ` Nick Zavaritsky
2025-02-04  8:28 ` [PATCH bpf-next 3/3] selftests/bpf: Add test case for atomic htab update Hou Tao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).