[PATCH] lib/mempool : rte_mempool_avail_count, fixing return bigger than mempool size
David Marchand
david.marchand at redhat.com
Wed May 17 13:53:25 CEST 2023
On Wed, May 17, 2023 at 11:05 AM Morten Brørup <mb at smartsharesystems.com> wrote:
> > On Tue, 16 May 2023 13:41:46 +0000
> > Yasin CANER <yasinncaner at gmail.com> wrote:
> >
> > > From: Yasin CANER <yasin.caner at ulakhaberlesme.com.tr>
> > >
> > > after a while working rte_mempool_avail_count function returns bigger
> > > than mempool size that cause miscalculation rte_mempool_in_use_count.
> > >
> > > it helps to avoid miscalculation rte_mempool_in_use_count.
Is this issue reproduced with an application of the reporter, or a
DPDK in-tree application?
> > >
> > > Bugzilla ID: 1229
> > >
> > > Signed-off-by: Yasin CANER <yasin.caner at ulakhaberlesme.com.tr>
> >
> > An alternative that avoids some code duplication.
> >
> > diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
> > index cf5dea2304a7..2406b112e7b0 100644
> > --- a/lib/mempool/rte_mempool.c
> > +++ b/lib/mempool/rte_mempool.c
> > @@ -1010,7 +1010,7 @@ rte_mempool_avail_count(const struct rte_mempool
> > *mp)
> > count = rte_mempool_ops_get_count(mp);
> >
> > if (mp->cache_size == 0)
> > - return count;
> > + goto exit;
>
> This bug can only occur here (i.e. with cache_size==0) if rte_mempool_ops_get_count() returns an incorrect value. The bug should be fixed there instead.
>
>
>
> MB (continued): The bug must be in the underlying mempool driver. I took a look at the ring and stack drivers, and they seem fine.
Or it could indicate a double free (or equivalent) issue from the
application (either through direct call to mempool API, or indirectly
like sending/freeing an already sent/freed packet for example).
--
David Marchand
More information about the dev
mailing list