On Tue, 29 Nov 2022 17:57:05 +0800 Fengnan Chang <changfeng...@bytedance.com> wrote:
> Olivier Matz <olivier.m...@6wind.com> 于2022年11月22日周二 23:25写道: > > > > Hi, > > > > On Tue, Nov 15, 2022 at 08:35:02PM +0800, Fengnan Chang wrote: > > > rte_mempool_create put tailq entry into rte_mempool_tailq list before > > > populate, and pool_data set when populate. So in multi process, if > > > process A create mempool, and process B can get mempool through > > > rte_mempool_lookup before pool_data set, if B call > > > rte_mempool_avail_count, > > > it will cause segment fault. > > > > > > Fix this by put tailq entry into rte_mempool_tailq after populate. > > > > > > Signed-off-by: Fengnan Chang <changfeng...@bytedance.com> Why not just handle this in rte_mempool_avail_count? It would be much simpler there. diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 4d337fca8dcd..14855e21801f 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -1006,6 +1006,10 @@ rte_mempool_avail_count(const struct rte_mempool *mp) unsigned count; unsigned lcore_id; + /* Handle race where pool created but ops not allocated yet */ + if (!(mp->flags & RTE_MEMPOOL_F_POOL_CREATED)) + return 0; + count = rte_mempool_ops_get_count(mp); if (mp->cache_size == 0)