From: Stephen Hemminger <stephen@networkplumber.org>
To: Fengnan Chang <changfengnan@bytedance.com>
Cc: Olivier Matz <olivier.matz@6wind.com>,
david.marchand@redhat.com, mb@smartsharesystems.com,
dev@dpdk.org
Subject: Re: [External] Re: [PATCH v2] mempool: fix rte_mempool_avail_count may segment fault when used in multiprocess
Date: Mon, 17 Jul 2023 09:43:05 -0700 [thread overview]
Message-ID: <20230717094305.6035eca1@hermes.local> (raw)
In-Reply-To: <CAPFOzZu9QfCmWFrQd1ByA-oHA6btsYxbfDAGnp-+Jfz+hood9Q@mail.gmail.com>
On Tue, 29 Nov 2022 17:57:05 +0800
Fengnan Chang <changfengnan@bytedance.com> wrote:
> Olivier Matz <olivier.matz@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 <changfengnan@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)
prev parent reply other threads:[~2023-07-17 16:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 12:35 Fengnan Chang
2022-11-22 15:24 ` Olivier Matz
2022-11-29 9:57 ` [External] " Fengnan Chang
2023-07-17 16:43 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230717094305.6035eca1@hermes.local \
--to=stephen@networkplumber.org \
--cc=changfengnan@bytedance.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=olivier.matz@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).