On Thu, Jul 6, 2023 at 10:42 AM Anton Protopopov <aspsk@xxxxxxxxxxxxx> wrote: > > > > > Don't you want to do: > > val = bpf_map_lookup_elem(map, ...); > > cnt = bpf_map_sum_elem_count(map); > > > > and that's the main use case ? > > Not sure I understand what this ^ use case is... > > Our primary use case is to [periodically] get the number of elements from the > user space. We can do this using an iterator as you've suggested and what is > tested in the added selftest. Hmm. During the last office hours John explained that he needs to raise alarm to user space when the map is close to full capacity. Currently he's doing it with his own per-map counters implemented in a bpf prog. I'd expect the alarm to be done inline with updates to the counters. If you scan maps from user space every second or so there is a chance the spike in usage will be missed. If we're adding map counters they should be usable not only via iterators. John, did I describe your use case correctly?