Good progress, Robert.
One more change requested, see comments inline below.
> +/*
> + * Check whether the mempool driver has allocated its store. Mempools
> are on
> + * the mempool list before that, so rte_mempool_dump() and
> rte_mempool_walk()
> + * callbacks can find them while another thread populates them.
> + * Acquire: pairs with the release in mempool_ops_alloc_once().
> + */
> +static bool
> +mempool_is_created(const struct rte_mempool *mp)
> +{
> + return (rte_atomic_load_explicit(
> + (const RTE_ATOMIC(unsigned int) *)&mp->flags,
> + rte_memory_order_acquire) &
> + RTE_MEMPOOL_F_POOL_CREATED) != 0;
> +}
mempool_is_created() should be public as rte_mempool_is_created().
Then the rte_mempool_walk() description can refer to it instead of referring to
the RTE_MEMPOOL_F_POOL_CREATED flag.
The "Acquire:" comment is an implementation detail; when you make the function
public, move that comment away from the function description and into the
implementation instead.
About the function name:
When the empty mempool is created, it is assigned the "ring" driver as default.
Until the pool has been populated, it may be assigned a different mempool
driver, e.g. the "stack" driver.
I suppose this is why the flag is named CREATED and not POPULATED.
And thus, the name rte_mempool_is_created() remains correct, rather than using
a different name.
You may consider this information, if you choose to update the function
description.
Notes:
Although the function is short and simple, it is not fast path, so it should
remain non-inline.
You already made it non-inline, so I'm just making sure you keep it that way.
:-)
It is used by mempool dump, so I don't think it can be marked experimental.
[...]
> * The mempool list is locked while the iterator function runs, so the
> * iterator function must not create or free a mempool.
> *
> + * The iterator function is also called for mempools that are not
> + * populated yet, which do not have RTE_MEMPOOL_F_POOL_CREATED set in
> + * their flags. Such a mempool has no store yet, so the iterator
> function
> + * must check this flag before calling functions that query the
Remember referring to the new rte_mempool_is_created() function in this
description.
> mempool
> + * driver, such as rte_mempool_avail_count().
> + *
> * @param func
> * Iterator function
> * @param arg
With the suggested change,
Acked-by: Morten Brørup <[email protected]>