* [dpdk-dev] [PATCH] mempool: fix sp sc mempool bug
@ 2016-09-08 3:52 Weiliang Luo
0 siblings, 0 replies; 4+ messages in thread
From: Weiliang Luo @ 2016-09-08 3:52 UTC (permalink / raw)
To: dev; +Cc: Weiliang Luo
Signed-off-by: Weiliang Luo <droidluo@gmail.com>
---
lib/librte_mempool/rte_mempool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 2e28e2e..350d77a 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -879,7 +879,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
* Since we have 4 combinations of the SP/SC/MP/MC examine the flags to
* set the correct index into the table of ops structs.
*/
- if (flags & (MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET))
+ if ((flags & MEMPOOL_F_SP_PUT) && (flags & MEMPOOL_F_SC_GET))
rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL);
else if (flags & MEMPOOL_F_SP_PUT)
rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL);
--
2.7.4 (Apple Git-66)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH] mempool: fix sp sc mempool bug
@ 2016-09-08 3:36 Weiliang Luo
2016-09-08 8:13 ` Olivier Matz
0 siblings, 1 reply; 4+ messages in thread
From: Weiliang Luo @ 2016-09-08 3:36 UTC (permalink / raw)
To: dev; +Cc: Weiliang Luo
Signed-off-by: Weiliang Luo <droidluo@gmail.com>
---
lib/librte_mempool/rte_mempool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 2e28e2e..350d77a 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -879,7 +879,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
* Since we have 4 combinations of the SP/SC/MP/MC examine the flags to
* set the correct index into the table of ops structs.
*/
- if (flags & (MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET))
+ if ((flags & MEMPOOL_F_SP_PUT) && (flags & MEMPOOL_F_SC_GET))
rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL);
else if (flags & MEMPOOL_F_SP_PUT)
rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL);
--
2.7.4 (Apple Git-66)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] mempool: fix sp sc mempool bug
2016-09-08 3:36 Weiliang Luo
@ 2016-09-08 8:13 ` Olivier Matz
2016-09-08 16:08 ` Weiliang Luo
0 siblings, 1 reply; 4+ messages in thread
From: Olivier Matz @ 2016-09-08 8:13 UTC (permalink / raw)
To: Weiliang Luo, dev
Hi Weiliang,
On 09/08/2016 05:36 AM, Weiliang Luo wrote:
> Signed-off-by: Weiliang Luo <droidluo@gmail.com>
> ---
> lib/librte_mempool/rte_mempool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
> index 2e28e2e..350d77a 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -879,7 +879,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
> * Since we have 4 combinations of the SP/SC/MP/MC examine the flags to
> * set the correct index into the table of ops structs.
> */
> - if (flags & (MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET))
> + if ((flags & MEMPOOL_F_SP_PUT) && (flags & MEMPOOL_F_SC_GET))
> rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL);
> else if (flags & MEMPOOL_F_SP_PUT)
> rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL);
>
I would just change the title and add some explanation in the commit
log. I suggest:
"""
mempool: fix corruption due to invalid handler
When using rte_mempool_create(), the mempool handler is selected
depending on the flags given by the user:
- multi-consumer / multi-producer
- multi-consumer / single-producer
- single-consumer / multi-producer
- single-consumer / single-producer
The flags were not properly tested, resulting in the selection of sc/sp
handler if sc/mp or mc/sp was asked. This can lead to corruption or
crashes because the get/put operations are not atomic.
Fixes: 449c49b93a6b ("mempool: support handler operations")
Signed-off-by: Weiliang Luo <droidluo@gmail.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
"""
Thanks!
Olivier
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] mempool: fix sp sc mempool bug
2016-09-08 8:13 ` Olivier Matz
@ 2016-09-08 16:08 ` Weiliang Luo
0 siblings, 0 replies; 4+ messages in thread
From: Weiliang Luo @ 2016-09-08 16:08 UTC (permalink / raw)
To: Olivier Matz; +Cc: dev
Thanks for your suggestion, I have submitted again with amended commit msg.
Thanks,
Weiliang
On Thu, Sep 8, 2016 at 3:13 AM, Olivier Matz <olivier.matz@6wind.com> wrote:
> Hi Weiliang,
>
> On 09/08/2016 05:36 AM, Weiliang Luo wrote:
> > Signed-off-by: Weiliang Luo <droidluo@gmail.com>
> > ---
> > lib/librte_mempool/rte_mempool.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_
> mempool.c
> > index 2e28e2e..350d77a 100644
> > --- a/lib/librte_mempool/rte_mempool.c
> > +++ b/lib/librte_mempool/rte_mempool.c
> > @@ -879,7 +879,7 @@ rte_mempool_create(const char *name, unsigned n,
> unsigned elt_size,
> > * Since we have 4 combinations of the SP/SC/MP/MC examine the
> flags to
> > * set the correct index into the table of ops structs.
> > */
> > - if (flags & (MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET))
> > + if ((flags & MEMPOOL_F_SP_PUT) && (flags & MEMPOOL_F_SC_GET))
> > rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL);
> > else if (flags & MEMPOOL_F_SP_PUT)
> > rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL);
> >
>
>
> I would just change the title and add some explanation in the commit
> log. I suggest:
>
> """
> mempool: fix corruption due to invalid handler
>
> When using rte_mempool_create(), the mempool handler is selected
> depending on the flags given by the user:
> - multi-consumer / multi-producer
> - multi-consumer / single-producer
> - single-consumer / multi-producer
> - single-consumer / single-producer
>
> The flags were not properly tested, resulting in the selection of sc/sp
> handler if sc/mp or mc/sp was asked. This can lead to corruption or
> crashes because the get/put operations are not atomic.
>
> Fixes: 449c49b93a6b ("mempool: support handler operations")
>
> Signed-off-by: Weiliang Luo <droidluo@gmail.com>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> """
>
>
> Thanks!
> Olivier
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-08 16:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 3:52 [dpdk-dev] [PATCH] mempool: fix sp sc mempool bug Weiliang Luo
-- strict thread matches above, loose matches on Subject: below --
2016-09-08 3:36 Weiliang Luo
2016-09-08 8:13 ` Olivier Matz
2016-09-08 16:08 ` Weiliang Luo
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).