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 06624A0C44 for ; Mon, 12 Apr 2021 10:29:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F966140FBC; Mon, 12 Apr 2021 10:29:33 +0200 (CEST) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by mails.dpdk.org (Postfix) with ESMTP id ACE1D4068E for ; Mon, 12 Apr 2021 10:29:30 +0200 (CEST) Received: by mail-lf1-f49.google.com with SMTP id w8so11498334lfr.0 for ; Mon, 12 Apr 2021 01:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tU24hPsZkZ7o3h6ovCZ80IvRq1RBxTdPMb3w7zVoAkc=; b=BpLIOCmzsCmBL5p54jA06Bd43maHRwhb6CEdIuwTQCe0KtExXD+pxJlnTsrhv+WpW8 1l9CrLWtA6u8YJFmns/tqG7aQKfVbjN7eY4iAD/vEjUqnufFtxNKGAE9vzhay0vdMmN1 iAM9tQv8JHHRxdnHxq4n61anLdmlsGfH32BzxbFlR9Zt0DfvD/XSczf4LxJCImCJsj6U 57t5RxGz50GdGFyE7m2k+bjKPLGLQGf8jzCq3taJ/gqzYrq9WYGu/PUdje6DqC/GfmFV Q67pRiz7ZuHmiW7K3pXf0gZ+i3t9VZqWFwLWOLbvse0jqvoZvz5DcHoUNsfhlYbt/4k+ YeBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tU24hPsZkZ7o3h6ovCZ80IvRq1RBxTdPMb3w7zVoAkc=; b=BbAJJo7j62N390kWSFug6N4Cn5bMtEDNtZpJTGAe26uIpaSFXmA3jorp7sDjVVSn8Q NyX9g7cWNQVw6Aq9PXjCqaRkB6jewTUzX5d752/Ik8Psk8C4zmSAVwba0FnehTgpNZJx Lqfjcw0i3TpYl0ugWPm6HMdmruIjkus+1qJ1HmlWZdU6lq9W8yZcNI8/DsgOFcc5x2UF F0/tln8jtcE4QL0coRvpxbg00sVl+m+YPfcFolJyMGz7XeqtRHUZcwRlb9BsItP98Cu6 QO3i8Q91UyV1OISqFA5Cpd3yN2bsKqdn0PnaZuoz3BkKeyhSPUd6MLjihdAWR640MosP bVcA== X-Gm-Message-State: AOAM533VUsUqI5SzCnyi7IP3BsIGWkMUJDbDae3VVuOIeazLpWPETBtd WFiNZamkHD2R/0I2N4nX0vB/Iw== X-Google-Smtp-Source: ABdhPJxSs01v2e3I1MmYolWILMTd5PUkcLnLddkRGMfrvwU3P6W7mwRQMwlmv36ZobWklcIFy3A2cA== X-Received: by 2002:ac2:5a4e:: with SMTP id r14mr10030220lfn.78.1618216170281; Mon, 12 Apr 2021 01:29:30 -0700 (PDT) Received: from toster.semihalf.com (host-193.106.246.139.static.3s.pl. [193.106.246.139]) by smtp.gmail.com with ESMTPSA id x4sm2691118ljd.112.2021.04.12.01.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 01:29:30 -0700 (PDT) From: Stanislaw Kardach To: Olivier Matz Cc: dev@dpdk.org, Stanislaw Kardach , phil.yang@arm.com, stable@dpdk.org Date: Mon, 12 Apr 2021 10:29:00 +0200 Message-Id: <20210412082901.652736-3-kda@semihalf.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210412082901.652736-1-kda@semihalf.com> References: <20210412082901.652736-1-kda@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 2/3] stack: add lock-free support indication 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" 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 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