All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Kardach <kda@semihalf.com>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org, Stanislaw Kardach <kda@semihalf.com>,
	phil.yang@arm.com, stable@dpdk.org
Subject: [dpdk-dev] [PATCH 2/3] stack: add lock-free support indication
Date: Mon, 12 Apr 2021 10:29:00 +0200	[thread overview]
Message-ID: <20210412082901.652736-3-kda@semihalf.com> (raw)
In-Reply-To: <20210412082901.652736-1-kda@semihalf.com>

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(-)

diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 6f5858c8f..42ed60da8 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -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
 -----------
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index 8a51fba17..10d3b2eeb 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -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
diff --git a/lib/librte_stack/rte_stack.h b/lib/librte_stack/rte_stack.h
index b82c74e72..27640f87b 100644
--- a/lib/librte_stack/rte_stack.h
+++ b/lib/librte_stack/rte_stack.h
@@ -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,
diff --git a/lib/librte_stack/rte_stack_lf.h b/lib/librte_stack/rte_stack_lf.h
index eb106e64e..f2b012cd0 100644
--- a/lib/librte_stack/rte_stack_lf.h
+++ b/lib/librte_stack/rte_stack_lf.h
@@ -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
 
 /**
-- 
2.27.0


  parent reply	other threads:[~2021-04-12  8:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  8:28 [dpdk-dev] [PATCH 0/3] add lock-free stack support discovery Stanislaw Kardach
2021-04-12  8:28 ` [dpdk-dev] [PATCH 1/3] stack: update lock-free supported archs Stanislaw Kardach
2021-04-27 13:54   ` Olivier Matz
2021-04-12  8:29 ` Stanislaw Kardach [this message]
2021-04-27 13:54   ` [dpdk-dev] [PATCH 2/3] stack: add lock-free support indication Olivier Matz
2021-04-12  8:29 ` [dpdk-dev] [PATCH 3/3] test: run lock-free stack tests when supported Stanislaw Kardach
2021-04-27 13:55   ` Olivier Matz
2021-04-16  6:34 ` [dpdk-dev] [PATCH 0/3] add lock-free stack support discovery David Marchand
2021-04-19 14:44   ` Stanisław Kardach
2021-05-03 14:21 ` David Marchand
2021-05-03 14:28   ` Olivier Matz
2021-05-03 18:34     ` Stanisław Kardach
2021-05-04  6:44       ` David Marchand
2021-05-04  6:44 ` David Marchand

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=20210412082901.652736-3-kda@semihalf.com \
    --to=kda@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=phil.yang@arm.com \
    --cc=stable@dpdk.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.