[v2] stack: fix reload head when pop fails

Message ID 20210921161724.20860-1-julien.meunier@nokia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] stack: fix reload head when pop fails |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance fail Performance Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Functional fail Functional Testing issues
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Julien Meunier Sept. 21, 2021, 4:17 p.m. UTC
  The previous commit 18effad9cfa7 ("stack: reload head when pop fails")
only changed C11 implementation, not generic implementation.

List head must be loaded right before continue (when failed to find the
new head). Without this, one thread might keep trying and failing to pop
items without ever loading the new correct head.

Fixes: 3340202f5954 ("stack: add lock-free implementation")
Cc: stable@dpdk.org

Signed-off-by: Julien Meunier <julien.meunier@nokia.com>
---
v2:
* rebase
* update commit log + remove invalid CC email address

lib/stack/rte_stack_lf_generic.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--
2.17.1
  

Comments

Olivier Matz Sept. 24, 2021, 8:57 a.m. UTC | #1
Hello,

On Tue, Sep 21, 2021 at 06:17:24PM +0200, Julien Meunier wrote:
> The previous commit 18effad9cfa7 ("stack: reload head when pop fails")
> only changed C11 implementation, not generic implementation.
> 
> List head must be loaded right before continue (when failed to find the
> new head). Without this, one thread might keep trying and failing to pop
> items without ever loading the new correct head.
> 
> Fixes: 3340202f5954 ("stack: add lock-free implementation")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Julien Meunier <julien.meunier@nokia.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Thanks Julien!
  
Thomas Monjalon Sept. 27, 2021, 3:47 p.m. UTC | #2
24/09/2021 10:57, Olivier Matz:
> Hello,
> 
> On Tue, Sep 21, 2021 at 06:17:24PM +0200, Julien Meunier wrote:
> > The previous commit 18effad9cfa7 ("stack: reload head when pop fails")
> > only changed C11 implementation, not generic implementation.
> > 
> > List head must be loaded right before continue (when failed to find the
> > new head). Without this, one thread might keep trying and failing to pop
> > items without ever loading the new correct head.
> > 
> > Fixes: 3340202f5954 ("stack: add lock-free implementation")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Julien Meunier <julien.meunier@nokia.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks.
  

Patch

diff --git a/lib/stack/rte_stack_lf_generic.h b/lib/stack/rte_stack_lf_generic.h
index 4850a05ee7..7fa29cedb2 100644
--- a/lib/stack/rte_stack_lf_generic.h
+++ b/lib/stack/rte_stack_lf_generic.h
@@ -128,8 +128,10 @@  __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list,
 		/* If NULL was encountered, the list was modified while
 		 * traversing it. Retry.
 		 */
-		if (i != num)
+		if (i != num) {
+			old_head = list->head;
 			continue;
+		}

 		new_head.top = tmp;
 		new_head.cnt = old_head.cnt + 1;