[2/3] stack: add lock-free support indication
Checks
Commit Message
Currently 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.
Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Fixes: 7911ba0473e0 ("stack: enable lock-free implementation for aarch64")
Cc: phil.yang@arm.com
Cc: stable@dpdk.org
---
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(-)
Comments
On Mon, Apr 12, 2021 at 10:29:00AM +0200, Stanislaw Kardach wrote:
> Currently 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.
>
> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
> Fixes: 7911ba0473e0 ("stack: enable lock-free implementation for aarch64")
> Cc: phil.yang@arm.com
> Cc: stable@dpdk.org
Acked-by: Olivier Matz <olivier.matz@6wind.com>
@@ -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
-----------
@@ -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
@@ -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,
@@ -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
/**