On 12/9/24 17:15, Mina Almasry wrote:
On Wed, Dec 4, 2024 at 9:22 AM David Wei <dw@xxxxxxxxxxx> wrote:
...
+/*
+ * page_pool_mp_return_in_cache() - return a netmem to the allocation cache.
+ * @pool: pool from which pages were allocated
+ * @netmem: netmem to return
+ *
+ * Return already allocated and accounted netmem to the page pool's allocation
+ * cache. The function doesn't provide synchronisation and must only be called
+ * from the napi context.
+ */
+void page_pool_mp_return_in_cache(struct page_pool *pool, netmem_ref netmem)
+{
+ if (WARN_ON_ONCE(pool->alloc.count >= PP_ALLOC_CACHE_REFILL))
+ return;
+
Really the caller needs to check this, and if the caller is checking
it then this additional check is unnecessarily defensive I would say.
But not really a big deal. I think I gave this feedback on the
previous iteration.
I think I already killed it. Nevertheless, that's true, the caller
has to check it, which is why it's a warning.
Reviewed-by: Mina Almasry <almasrymina@xxxxxxxxxx>
--
Pavel Begunkov