Hi, +cc bpf list On 1/16/2025 4:51 AM, Cody Haas wrote: > Hey everyone, > > I've got a question. I've got an eBPF map that's a > BPF_MAP_TYPE_HASH_OF_MAPS where user space updates elements in the > map, user space will create a new inner map to do map-in-map swapping > in order to update the outer map's values. My XDP program will then > read the inner maps by using BPF_MAP_LOOKUP_ELEM on the outer map. > Does this create a potential race condition between > BPF_MAP_LOOKUP_ELEM and BPF_MAP_UPDATE_ELEM when one thread is trying > to lookup an existing element while another thread is trying to update > the same existing element? I'm expecting to see either the old value > or the new value, however I'm occasionally seeing the element does not > exist when looking up the element from the eBPF program. Is this > expected? For now, it is expected. The reason is that the update of hash map is not atomic and it is possible the lookup procedure may return ENOENT if there is concurrent update operation on the same key. However, it seems the atomic update for hash of maps is feasible (e.g., implement spin-lock support for hash of maps). I will check it later. > > Thanks, > > Cody Haas > > .