add lock-free stack support discovery
cover add lock-free stack support discovery
The lock-free stack implementation (RTE_STACK_F_LF) is supported only on a subset of platforms, namely x86_64 and arm64. Platforms supporting 128b atomics have to opt-in to a generic or C11 implementations. All other platforms use a stubbed implementation for push/pop operations which are basically NOPs. However rte_stack_create() will not fail and application can proceed assuming it has a working lock-free stack.
This means that among other things the stack_lf fast and perf tests will fail as if implementation is wrong (which one can argue is). Therefore this patchset tries to give user a way to check whether a lock_free is supported or not both at compile time (build flag) and at runtime (ENOTSUP errno in rte_stack_create).
I have added cc to [email protected] because check-git-log.sh suggested it. I'm not sure if adding a binary compatible change to API is worth [email protected].
Stanislaw Kardach (3):
stack: update lock-free supported archs
stack: add compile flag for lock-free support
test: run lock-free stack tests when supported
app/test/test_stack.c | 4 ++++ app/test/test_stack_perf.c | 4 ++++ doc/guides/rel_notes/release_21_05.rst | 4 ++++ lib/librte_stack/rte_stack.c | 4 +++- lib/librte_stack/rte_stack.h | 3 ++- lib/librte_stack/rte_stack_lf.h | 5 +++++ 6 files changed, 22 insertions(+), 2 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/3 stack: update lock-free supported archs
Since 7911ba047 lock-free stack is supported on arm64 but this description was missing from the doxygen for the flag.
--- lib/librte_stack/rte_stack.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_stack/rte_stack.h +1 -1
@@ -89,7 +89,7 @@ struct rte_stack {/** * The stack uses lock-free push and pop functions. This flag is only -* supported on x86_64 platforms, currently. +* supported on x86_64 or arm64 platforms, currently. */ #define RTE_STACK_F_LF 0x0001
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH 1/3] stack: update lock-free supported archs
Quoted 7 lines · Stanislaw Kardach
Since
7911ba047lock-free stack is supported on arm64 but this description was missing from the doxygen for the flag.Signed-off-by Stanislaw Kardach <[email protected]>Fixes 7911ba0473e0 ("stack: enable lock-free implementation for aarch64")
PATCH 2/3 stack: add lock-free support indication
In reply to Stanislaw KardachCurrently it is impossible to detect programatically whether lock-free implementation of rte_stack is supported. One could check whether the header guard for lock-free stubs is defined (_RTE_STACK_LF_STUBS_H_) but that's an unstable implementation detail. Because of that currently all lock-free ring creations silently succeed (as long as the stack header is 16B long) which later leads to push and pop operations being NOPs. The observable effect is that stack_lf_autotest fails on platforms not supporting the lock-free. Instead it should just skip the lock-free test altogether.
This commit adds a new errno value (ENOTSUP) that may be returned by rte_stack_create() to indicate that a given combination of flags is not supported on a current platform.
This is detected by checking a compile-time flag in the include logic in rte_stack_lf.h which may be used by applications to check the lock-free support at compile time.
--- doc/guides/rel_notes/release_21_05.rst | 4 ++++ lib/librte_stack/rte_stack.c | 4 +++- lib/librte_stack/rte_stack.h | 1 + lib/librte_stack/rte_stack_lf.h | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_21_05.rst +4 -0
@@ -166,6 +166,10 @@ API Changes * pci: The value ``PCI_ANY_ID`` is marked as deprecated and can be replaced with ``RTE_PCI_ANY_ID``. +* Lock-free ``rte_stack`` no longer silently ignores push and pop when it's not + supported on the current platform. Instead ``rte_stack_create()`` fails and + ``rte_errno`` is set to ``ENOTSUP``. + ABI Changes -----------
lib/librte_stack/rte_stack.c +3 -1
@@ -64,9 +64,11 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,#ifdef RTE_ARCH_64 RTE_BUILD_BUG_ON (sizeof (struct rte_stack_lf_head ) !=16 ); -#else +#endif +#if !defined(RTE_STACK_LF_SUPPORTED )if (flags &RTE_STACK_F_LF ) {STACK_LOG_ERR ("Lock-free stack is not supported on your platform\n" ); + rte_errno =ENOTSUP ;return NULL ; }#endif
lib/librte_stack/rte_stack.h +1 -0
@@ -205,6 +205,7 @@ rte_stack_free_count(struct rte_stack *s)* - EEXIST - a stack with the same name already exists * - ENOMEM - insufficient memory to create the stack * - ENAMETOOLONG - name size exceeds RTE_STACK_NAMESIZE +* - ENOTSUP - platform does not support given flags combination. */ struct rte_stack * rte_stack_create(const char *name, unsigned int count, int socket_id,
lib/librte_stack/rte_stack_lf.h +5 -0
@@ -13,6 +13,11 @@#else #include "rte_stack_lf_generic.h" #endif + +/** +* Indicates that RTE_STACK_F_LF is supported. +*/ +#define RTE_STACK_LF_SUPPORTED #endif /**
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH 2/3] stack: add lock-free support indication
Quoted 17 lines · Stanislaw Kardach
Currently it is impossible to detect programatically whether lock-free implementation of
rte_stackis supported. One could check whether the header guard for lock-free stubs is defined (_RTE_STACK_LF_STUBS_H_) but that's an unstable implementation detail. Because of that currently all lock-free ring creations silently succeed (as long as the stack header is 16B long) which later leads to push and pop operations being NOPs. The observable effect is thatstack_lf_autotestfails on platforms not supporting the lock-free. Instead it should just skip the lock-free test altogether.This commit adds a new errno value (ENOTSUP) that may be returned by
rte_stack_create()to indicate that a given combination of flags is not supported on a current platform.
This is detected by checking a compile-time flag in the include logic inrte_stack_lf.hwhich may be used by applications to check the lock-free support at compile time.
Quoted 4 lines
Signed-off-by Stanislaw Kardach <[email protected]>Fixes 7911ba0473e0 ("stack: enable lock-free implementation for aarch64")
PATCH 3/3 test: run lock-free stack tests when supported
In reply to Stanislaw KardachUse the recently added RTE_STACK_LF_SUPPORTED flag to disable the lock-free stack tests at the compile time.
Perf test doesn't fail because rte_ring_create() succeeds, however marking this test as skipped gives a better indication of what actually was tested.
--- app/test/test_stack.c | 4 ++++ app/test/test_stack_perf.c | 4 ++++ 2 files changed, 8 insertions(+)
app/test/test_stack.c +4 -0
@@ -373,7 +373,11 @@ test_stack(void)static int test_lf_stack (void ) { +#if defined(RTE_STACK_LF_SUPPORTED )return __test_stack (RTE_STACK_F_LF ); +#else +return TEST_SKIPPED ; +#endif }REGISTER_TEST_COMMAND (stack_autotest, test_stack);
app/test/test_stack_perf.c +4 -0
@@ -349,7 +349,11 @@ test_stack_perf(void)static int test_lf_stack_perf (void ) { +#if defined(RTE_STACK_LF_SUPPORTED )return __test_stack_perf (RTE_STACK_F_LF ); +#else +return TEST_SKIPPED ; +#endif }REGISTER_TEST_COMMAND (stack_perf_autotest, test_stack_perf);
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH 3/3] test: run lock-free stack tests when supported
Quoted 8 lines · Stanislaw Kardach
Use the recently added
RTE_STACK_LF_SUPPORTEDflag to disable the lock-free stack tests at the compile time.
Perf test doesn't fail becauserte_ring_create()succeeds, however marking this test as skipped gives a better indication of what actually was tested.Signed-off-by Stanislaw Kardach <[email protected]>
Quoted 7 lines · Stanislaw Kardach
The lock-free stack implementation (
RTE_STACK_F_LF) is supported only on a subset of platforms, namelyx86_64and arm64. Platforms supporting 128b atomics have to opt-in to a generic or C11 implementations. All other platforms use a stubbed implementation for push/pop operations which are basically NOPs. Howeverrte_stack_create()will not fail and application can proceed assuming it has a working lock-free stack.
Did you actually hit this issue or is this only theoretical? I can only think of ppc64 displaying such behavior.
Signature · 1 line
David Marchand
Quoted 9 lines · David Marchand
Quoted 7 lines · Stanislaw Kardach
The lock-free stack implementation (
RTE_STACK_F_LF) is supported only on a subset of platforms, namelyx86_64and arm64. Platforms supporting 128b atomics have to opt-in to a generic or C11 implementations. All other platforms use a stubbed implementation for push/pop operations which are basically NOPs. Howeverrte_stack_create()will not fail and application can proceed assuming it has a working lock-free stack.
Quoted 3 lines
Did you actually hit this issue or is this only theoretical? I can only think of ppc64 displaying such behavior.
I actually hit this issue while working on a RISC-V port.
My reasoning here is that sooner or later someone else will stumble upon this, either on ppc64 or while trying to port to some new platform. It is also a really nasty limitation do debug given the silent nature of the failure.
Quoted 4 lines
--
David Marchand
--
Best Regards,
Stanislaw Kardach
Quoted 13 lines · Stanislaw Kardach
The lock-free stack implementation (
RTE_STACK_F_LF) is supported only on a subset of platforms, namelyx86_64and arm64. Platforms supporting 128b atomics have to opt-in to a generic or C11 implementations. All other platforms use a stubbed implementation for push/pop operations which are basically NOPs. Howeverrte_stack_create()will not fail and application can proceed assuming it has a working lock-free stack.This means that among other things the
stack_lffast and perf tests will fail as if implementation is wrong (which one can argue is). Therefore this patchset tries to give user a way to check whether alock_freeis supported or not both at compile time (build flag) and at runtime (ENOTSUP errno inrte_stack_create).
Quoted 4 lines
I have added cc to [email protected] because
check-git-log.shsuggested it. I'm not sure if adding a binary compatible change to API is worth [email protected].
The issue was hit while porting to a new architecture. The feature is broken in existing stable releases and it won't get fixed by this change.
I'd rather not backport it.
Opinions?
Signature · 1 line
David Marchand
Quoted 19 lines · David Marchand
Quoted 13 lines · Stanislaw Kardach
The lock-free stack implementation (
RTE_STACK_F_LF) is supported only on a subset of platforms, namelyx86_64and arm64. Platforms supporting 128b atomics have to opt-in to a generic or C11 implementations. All other platforms use a stubbed implementation for push/pop operations which are basically NOPs. Howeverrte_stack_create()will not fail and application can proceed assuming it has a working lock-free stack.This means that among other things the
stack_lffast and perf tests will fail as if implementation is wrong (which one can argue is). Therefore this patchset tries to give user a way to check whether alock_freeis supported or not both at compile time (build flag) and at runtime (ENOTSUP errno inrte_stack_create).Quoted 4 lines
I have added cc to [email protected] because
check-git-log.shsuggested it. I'm not sure if adding a binary compatible change to API is worth [email protected].
Quoted 7 lines
The issue was hit while porting to a new architecture. The feature is broken in existing stable releases and it won't get fixed by this change.
I'd rather not backport it.
Opinions?
Agreed.
Quoted 36 lines · On Mon, 3 May 2021, 16:28 Olivier Matz, <[email protected]> wrote:
Quoted 1 line · David Marchand
On Mon, Apr 12, 2021 at 10:29 AM Stanislaw Kardach <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
The lock-free stack implementation (
RTE_STACK_F_LF) is supported onlyon a
Quoted 1 line
Quoted 1 line
subset of platforms, namely
x86_64and arm64. Platforms supporting128b atomics
Quoted 1 line
Quoted 1 line
have to opt-in to a generic or C11 implementations. All other
platforms use a
Quoted 1 line
Quoted 1 line
stubbed implementation for push/pop operations which are basically
NOPs.
Quoted 1 line
Quoted 1 line
However
rte_stack_create()will not fail and application can proceedassuming
Quoted 3 lines
Quoted 3 lines
it has a working lock-free stack.
This means that among other things the
stack_lffast and perf testswill fail
Quoted 1 line
Quoted 1 line
as if implementation is wrong (which one can argue is). Therefore this
patchset
Quoted 1 line
Quoted 1 line
tries to give user a way to check whether a
lock_freeis supported ornot both
Quoted 1 line
Quoted 1 line
at compile time (build flag) and at runtime (ENOTSUP errno in
rte_stack_create).Quoted 2 lines
Quoted 2 lines
I have added cc to [email protected] because
check-git-log.shsuggestedit. I'm
Quoted 1 line
Quoted 1 line
not sure if adding a binary compatible change to API is worth
Quoted 7 lines
Quoted 2 lines
The issue was hit while porting to a new architecture. The feature is broken in existing stable releases and it won't get fixed by this change.
Quoted 6 lines
Quoted 3 lines
I'd rather not backport it.
Opinions?
Agreed.
Agreed.
Quoted 1 line
Quoted 13 lines · Stanisław Kardach
Quoted 12 lines · On Mon, 3 May 2021, 16:28 Olivier Matz, <[email protected]> wrote:
Quoted 11 lines · David Marchand
Quoted 5 lines · Stanislaw Kardach
I have added cc to [email protected] because
check-git-log.shsuggested it. I'm not sure if adding a binary compatible change to API is worth [email protected].The issue was hit while porting to a new architecture. The feature is broken in existing stable releases and it won't get fixed by this change.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I'd rather not backport it.
Opinions?
Agreed.
Agreed.
Ok, thanks.
I'll take this series dropping Cc: stable.
Signature · 1 line
David Marchand
Quoted 8 lines · Stanislaw Kardach
The lock-free stack implementation (
RTE_STACK_F_LF) is supported only on a subset of platforms, namelyx86_64and arm64. Platforms supporting 128b atomics have to opt-in to a generic or C11 implementations. All other platforms use a stubbed implementation for push/pop operations which are basically NOPs. Howeverrte_stack_create()will not fail and application can proceed assuming it has a working lock-free stack.
Quoted 4 lines
This means that among other things the
stack_lffast and perf tests will fail as if implementation is wrong (which one can argue is). Therefore this patchset tries to give user a way to check whether alock_freeis supported or not both at compile time (build flag) and at runtime (ENOTSUP errno inrte_stack_create).
Series applied.
Thanks Stanislaw!
Signature · 1 line
David Marchand