XDP/eBPF map thread safety in kernel (e.g. lookup/delete)

Vadim Goncharov <[email protected]> Wed, 23 Oct 2024 14:54:26 +0300
Newsgroups org.kernel.vger.xdp-newbies
Message-ID <[email protected]>
Hello,

Where to find exact documentation about what happens in kernel BPF
helpers calls with respect to locking? For example, I have
`bpf_map_lookup_elem()` in one thread, then work on pointer, and at this
time, another thread does `bpf_map_delete_elem()` for exactly same key.
What happens to memory the first thread still continue to work on? Is
it now dangling pointer to nowhere?

In my particular case it's a bpf_timer callback who does
`bpf_map_delete_elem()`. I'd prefer for it to not delete entry if
another thread did `lookup` and works already, is it possible to do so
(in a performant way)?

-- 
WBR, @nuclight