Hi Morten, On Fri, Oct 11, 2019 at 01:24:00PM +0200, Morten Brørup wrote: > The rte_mempool_get_bulk() documentation says: > > "If cache is enabled, objects will be retrieved first from cache, > subsequently from the common pool." > > But __mempool_generic_get() only uses the cache if the request is smaller > than the cache size. If not, objects will be retrieved from the common pool > only. > > Either the documentation should be corrected, or the implementation should > behave as described, i.e. retrieve the first of the objects from the cache > and the remaining objects from the common pool.
That's correct. I think the documentation could be updated. Maybe something like this: * If cache is enabled, objects will be retrieved first from cache, * subsequently from the common pool. If the number of requested objects * is higher than the cache size, the objects are directly retrieved * from the common pool. The put() suffers from the same problem, but the actual behavior is not easy to describe. We could add this: * The objects are added in the cache if it is enabled, and if * the number of objects is smaller than RTE_MEMPOOL_CACHE_MAX_SIZE. * After the operation, if the cache length is above 1.5 * size, * some objects are also returned to the common pool. But I feel the comment is just a duplication of the code, but in english... and there's a risk that they become unsynchronized in the future (especially because the comment is above rte_mempool_generic_put() and the code is in __rte_mempool_generic_put()). > PS: I stumbled into this while writing the unit test for mbuf bulk alloc/free. > > PPS: It seems unit tests for mempool bulk alloc/free are missing. :-) > > > Med venlig hilsen / kind regards > - Morten Brørup > >