From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 08B57A0A02 for ; Mon, 17 May 2021 18:16:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0050F410F7; Mon, 17 May 2021 18:16:12 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 2646640041 for ; Mon, 17 May 2021 18:16:12 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lifud-0008J7-Az; Mon, 17 May 2021 16:16:11 +0000 From: Christian Ehrhardt To: Stanislaw Kardach Cc: Olivier Matz , dpdk stable Date: Mon, 17 May 2021 18:09:31 +0200 Message-Id: <20210517161039.3132619-142-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> References: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'stack: allow lock-free only on relevant architectures' has been queued to stable release 19.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/19/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/ee781f5c21d6012846ccdcb09a72f97c3153e220 Thanks. Christian Ehrhardt --- >From ee781f5c21d6012846ccdcb09a72f97c3153e220 Mon Sep 17 00:00:00 2001 From: Stanislaw Kardach Date: Mon, 12 Apr 2021 10:28:59 +0200 Subject: [PATCH] stack: allow lock-free only on relevant architectures [ upstream commit 1abb185d6cd41f83cd91eb6b1816c31e4bce887a ] Since commit 7911ba0473e0 ("stack: enable lock-free implementation for aarch64"), lock-free stack is supported on arm64 but this description was missing from the doxygen for the flag. Currently it is impossible to detect programmatically 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. Use the 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. Fixes: 7911ba0473e0 ("stack: enable lock-free implementation for aarch64") Signed-off-by: Stanislaw Kardach Acked-by: Olivier Matz --- app/test/test_stack.c | 4 ++++ app/test/test_stack_perf.c | 4 ++++ lib/librte_stack/rte_stack.c | 4 +++- lib/librte_stack/rte_stack.h | 3 ++- lib/librte_stack/rte_stack_lf.h | 5 +++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/test/test_stack.c b/app/test/test_stack.c index c8dac1f55c..fe6f1aab9c 100644 --- a/app/test/test_stack.c +++ b/app/test/test_stack.c @@ -419,7 +419,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); diff --git a/app/test/test_stack_perf.c b/app/test/test_stack_perf.c index 3ab7267b1b..a0c7d4d9dd 100644 --- a/app/test/test_stack_perf.c +++ b/app/test/test_stack_perf.c @@ -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); diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c index d19824f004..112f2f99ce 100644 --- a/lib/librte_stack/rte_stack.c +++ b/lib/librte_stack/rte_stack.c @@ -61,9 +61,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 abf6420766..ee94a758b3 100644 --- a/lib/librte_stack/rte_stack.h +++ b/lib/librte_stack/rte_stack.h @@ -93,7 +93,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 @@ -228,6 +228,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. */ __rte_experimental struct rte_stack * diff --git a/lib/librte_stack/rte_stack_lf.h b/lib/librte_stack/rte_stack_lf.h index e67630c277..3d3bd0f798 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.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:34.970774979 +0200 +++ 0142-stack-allow-lock-free-only-on-relevant-architectures.patch 2021-05-17 17:40:29.419811429 +0200 @@ -1 +1 @@ -From 1abb185d6cd41f83cd91eb6b1816c31e4bce887a Mon Sep 17 00:00:00 2001 +From ee781f5c21d6012846ccdcb09a72f97c3153e220 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1abb185d6cd41f83cd91eb6b1816c31e4bce887a ] + @@ -38,7 +40,6 @@ - app/test/test_stack.c | 4 ++++ - app/test/test_stack_perf.c | 4 ++++ - doc/guides/rel_notes/release_21_05.rst | 4 ++++ - lib/stack/rte_stack.c | 4 +++- - lib/stack/rte_stack.h | 3 ++- - lib/stack/rte_stack_lf.h | 5 +++++ - 6 files changed, 22 insertions(+), 2 deletions(-) + app/test/test_stack.c | 4 ++++ + app/test/test_stack_perf.c | 4 ++++ + lib/librte_stack/rte_stack.c | 4 +++- + lib/librte_stack/rte_stack.h | 3 ++- + lib/librte_stack/rte_stack_lf.h | 5 +++++ + 5 files changed, 18 insertions(+), 2 deletions(-) @@ -47 +48 @@ -index 02422a32d6..00efb38e2a 100644 +index c8dac1f55c..fe6f1aab9c 100644 @@ -50 +51 @@ -@@ -373,7 +373,11 @@ test_stack(void) +@@ -419,7 +419,11 @@ test_stack(void) @@ -63 +64 @@ -index 3590625c49..4ee40d5d19 100644 +index 3ab7267b1b..a0c7d4d9dd 100644 @@ -78,20 +79,5 @@ -diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst -index b3224dc332..cd33898c55 100644 ---- a/doc/guides/rel_notes/release_21_05.rst -+++ b/doc/guides/rel_notes/release_21_05.rst -@@ -329,6 +329,10 @@ API Changes - ``policer_action_recolor_supported`` and ``policer_action_drop_supported`` - have been removed. - -+* stack: 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/stack/rte_stack.c b/lib/stack/rte_stack.c -index 8a51fba17f..10d3b2eeb3 100644 ---- a/lib/stack/rte_stack.c -+++ b/lib/stack/rte_stack.c -@@ -64,9 +64,11 @@ rte_stack_create(const char *name, unsigned int count, int socket_id, +diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c +index d19824f004..112f2f99ce 100644 +--- a/lib/librte_stack/rte_stack.c ++++ b/lib/librte_stack/rte_stack.c +@@ -61,9 +61,11 @@ rte_stack_create(const char *name, unsigned int count, int socket_id, @@ -110,5 +96,5 @@ -diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h -index 395b9ef835..27640f87b2 100644 ---- a/lib/stack/rte_stack.h -+++ b/lib/stack/rte_stack.h -@@ -89,7 +89,7 @@ struct rte_stack { +diff --git a/lib/librte_stack/rte_stack.h b/lib/librte_stack/rte_stack.h +index abf6420766..ee94a758b3 100644 +--- a/lib/librte_stack/rte_stack.h ++++ b/lib/librte_stack/rte_stack.h +@@ -93,7 +93,7 @@ struct rte_stack { @@ -123 +109 @@ -@@ -205,6 +205,7 @@ rte_stack_free_count(struct rte_stack *s) +@@ -228,6 +228,7 @@ rte_stack_free_count(struct rte_stack *s) @@ -128,0 +115 @@ + __rte_experimental @@ -130,5 +117,4 @@ - rte_stack_create(const char *name, unsigned int count, int socket_id, -diff --git a/lib/stack/rte_stack_lf.h b/lib/stack/rte_stack_lf.h -index eb106e64e6..f2b012cd0e 100644 ---- a/lib/stack/rte_stack_lf.h -+++ b/lib/stack/rte_stack_lf.h +diff --git a/lib/librte_stack/rte_stack_lf.h b/lib/librte_stack/rte_stack_lf.h +index e67630c277..3d3bd0f798 100644 +--- a/lib/librte_stack/rte_stack_lf.h ++++ b/lib/librte_stack/rte_stack_lf.h