Re: bpf_map_delet_elem too slow

Yonghong Song

On Thu, Feb 7, 2019 at 8:31 AM Иван Иванов <iwan12iwan12@...> wrote:

I use simple prog to get stat from my map type BPF_MAP_TYPE_HASH.
An got too slow speed to delete elems from it, lookup elem 100-1000x faster.
My code is just

while(bpf_map_get_next_key(fd, &key,&nextkey)==0)
bpf_map_delete_elem(fd, &nextkey);
It is not recommended to do delete() during get_next_key() loop.
The delete() may change kernel internal hash table structure
and get_next_key() may not function as expected.

You can do one loop with get_next_key() to get all the keys
and another loop to do deletions.

whitout deleting code is very fast.

Join to automatically receive all group messages.