[dpdk-dev] [RFC v2 11/17] mempool: ensure the mempool is initialized before populating
Olivier Matz
olivier.matz at 6wind.com
Wed Jan 31 17:45:39 CET 2018
On Tue, Jan 23, 2018 at 01:16:06PM +0000, Andrew Rybchenko wrote:
> From: "Artem V. Andreev" <Artem.Andreev at oktetlabs.ru>
>
> Callback to calculate required memory area size may require mempool
> driver data to be already allocated and initialized.
>
> Signed-off-by: Artem V. Andreev <Artem.Andreev at oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
> ---
> lib/librte_mempool/rte_mempool.c | 29 ++++++++++++++++++++++-------
> 1 file changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
> index fc9c95a..cbb4dd5 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -370,6 +370,21 @@ rte_mempool_free_memchunks(struct rte_mempool *mp)
> }
> }
>
> +static int
> +mempool_maybe_initialize(struct rte_mempool *mp)
> +{
> + int ret;
> +
> + /* create the internal ring if not already done */
> + if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) {
> + ret = rte_mempool_ops_alloc(mp);
> + if (ret != 0)
> + return ret;
> + mp->flags |= MEMPOOL_F_POOL_CREATED;
> + }
> + return 0;
> +}
mempool_ops_alloc_once() ?
More information about the dev
mailing list