On Thu, Jun 1, 2023 at 11:17 AM Anton Protopopov <aspsk@xxxxxxxxxxxxx> wrote: > > > > LRU logic doesn't kick in until the map is full. > > In fact, it can: a reproducable example is in the self-test from this patch > series. In the test N threads try to insert random values for keys 1..3000 > simultaneously. As the result, the map may contain any number of elements, > typically 100 to 1000 (never full 3000, which is also less than the map size). > So a user can't really even closely estimate the number of elements in the LRU > map based on the number of updates (with unique keys). A per-cpu counter > inc/dec'ed from the kernel side would solve this. That's odd and unexpected. Definitely something to investigate and fix in the LRU map. Pls cc Martin in the future. > > If your LRU map is not full you shouldn't be using LRU in the first place. > > This makes sense, yes, especially that LRU evictions may happen randomly, > without a map being full. I will step back with this patch until we investigate > if we can replace LRUs with hashes. > > Thanks for the comments!