From patchwork Wed Sep 13 10:34:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131376 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D369C42588; Wed, 13 Sep 2023 12:36:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 473D3402EE; Wed, 13 Sep 2023 12:36:17 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 9BB30402EE for ; Wed, 13 Sep 2023 12:36:16 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 610BC320091C; Wed, 13 Sep 2023 06:36:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 06:36:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601374; x=1694687774; bh=9KmtH2xdcVmEydycKsOW5EgSK9TiWdCDs/c RCnJvKQE=; b=S3zvQ56ovK+dqRnF3GrwR5VdTibe0gYAU6LovIfTj7QD1mdNUJl 1iTziNvSlKZsMmMFYtj7Qbn/9T+IvcaXcBwP+MyP/pMMx/0oZBoHr/nvr15yF+zv 4QtwFl192HbhYOiuHZ27L+MGmDvoIxoA6zIZN+v36Ez7vwoc8FzgCKlep/PeobG+ rOI4O8yXjSIueccT8722h9JCiZ7VaBercYlLmtdLuNKi8SCOmOdexR8tcZa4ee2N 10rTf249uws7P9m4z/R/seufNeTXdW0PZ4onMDUTuPRZ7Uub2L/H7/zrs9rk0zTy FzUeGtl/sKiNKpIAjuD1xlrfSeyuvC7Rurg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601374; x=1694687774; bh=9KmtH2xdcVmEydycKsOW5EgSK9TiWdCDs/c RCnJvKQE=; b=WXAAWiwtTz/SqipnVpR5svGwhF3GHH3n6kntbqNd2/zFKAikCX4 I0sBDNHlKUuQVI2eqFPHUOMVpA0yxU/WHCdpxQaoFSH00qCOCP55IDpOVR2wrftL 2LxmTEFs2NCXQehwGrTMQheXRmf923kWzXItK8SXGbvoynG77VEuN54+p3Z0o4Kr 9p+tld6+G1cUIhQ48gnrG+FzsRRsdI4jSum9tw3YTyHB2rKYRxn5Wa1V720LsNfF hG30HF5OFT99zKY6YgAK3Zdn2RWlYg4Xct01FBZT3wDAR567TuNF7qHZ7Qi0kqZa RAxTWT/ICTSRp7SR62E4RD3qQ0CgJd0fgDg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:36:12 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH v2 01/11] devtools: warn when adding some pthread calls Date: Wed, 13 Sep 2023 12:34:20 +0200 Message-ID: <20230913103600.1935292-2-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org All pthread functions below have an equivalent in rte_thread API: - pthread_create - pthread_join - pthread_detach - pthread_setname_np - pthread_set_name_np - pthread_setaffinity_np - pthread_attr_setinheritsched - pthread_attr_setschedpolicy Usage of these functions will be raised to encourage rte_thread adoption. The pthread functions for locks and cancel are still allowed. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- v2: replace (|_) with _? --- devtools/checkpatches.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index 55fabc5458..ec9d232393 100755 --- a/devtools/checkpatches.sh +++ b/devtools/checkpatches.sh @@ -119,6 +119,14 @@ check_forbidden_additions() { # -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ "$1" || res=1 + # refrain from using some pthread functions + awk -v FOLDERS="lib drivers app examples" \ + -v EXPRESSIONS="pthread_(create|join|detach|set(_?name_np|affinity_np)|attr_set(inheritsched|schedpolicy))\\\(" \ + -v RET_ON_FAIL=1 \ + -v MESSAGE='Using pthread functions, prefer rte_thread' \ + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ + "$1" || res=1 + # forbid use of __reserved which is a reserved keyword in Windows system headers awk -v FOLDERS="lib drivers app examples" \ -v EXPRESSIONS='\\<__reserved\\>' \ From patchwork Wed Sep 13 10:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131377 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9B7BF42588; Wed, 13 Sep 2023 12:36:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8AE264064A; Wed, 13 Sep 2023 12:36:28 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 6DBC040649 for ; Wed, 13 Sep 2023 12:36:27 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 7414A3200914; Wed, 13 Sep 2023 06:36:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 06:36:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601384; x=1694687784; bh=Qu2x7Ja/yh9Qi3mISmOdF72ldQCkUZbKAQQ /xmlwgv0=; b=wsY+/1e3r+1rIOKEiAcfEPZjZQ/Gcu+NU14VvbdTpxStjb59Eg7 tGkyrl9hLH/j6FaTFHbPSZ3PNXPyDKK8JgHL5HvEbV0/Agetnkzq/CYQZo2GnI7I OnLd7eDzZ2tIk2GwVtKjaIRyUIn/KVplHM2hgThKd3ttvhSXDcZ2BPgweRZfZeFC O026AHVM7irnugRVi/B1iP8jLSdmgEi5Az4/YACePLsmimBhdDF9t+e3gVjybolI Fb6i2rcGHrP3S0xgVznuXe06RCyAlEohfQaBy3koyt9VrS65zkSueC7IF7mGOqMC Jb8bUkIYYylDqy9s3mVPc5QK86didP3/OYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601384; x=1694687784; bh=Qu2x7Ja/yh9Qi3mISmOdF72ldQCkUZbKAQQ /xmlwgv0=; b=riOW1jK4Gm9SUMbDQs028t64MW15erg7UQTBPf3en0oiYXDIbzv 9ksDBVt9MdYtG0Havip/YRxJdiqV+QX7/wcHYHkXtwYF8aBCKoNzgeDPsIK7SS6W nkUJwlXHV36n6cVf0NXttm+BZACZA+4X6q1RBuR29rWtyVpLq4tAhfESnHqugRte M7eoh+13v3pq48vjtvIflVkEaEW+MiRh4ejci9YVIsAzf60tGAFs2eczaT9Ul7Fy YQKmyyo+tUNj8tsudUlhsUe7ao3a1jHoS6jniSgYcMpGmsUY7AyL7eyF+e+kHyTx llAtwqcbIyEKWbImQnPQEG8MrTcbqN08Qvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:36:22 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v2 02/11] eal: rename thread name length definition Date: Wed, 13 Sep 2023 12:34:21 +0200 Message-ID: <20230913103600.1935292-3-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org RTE_MAX_THREAD_NAME_LEN is including the NUL character, so it should be named "size" instead of "length". A new constant RTE_THREAD_NAME_SIZE is introduced for naming accuracy. For API compatibility, the old name is kept. At the same time, the original definition is moved from rte_eal.h to rte_thread.h. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- lib/eal/freebsd/eal.c | 2 +- lib/eal/freebsd/eal_thread.c | 2 +- lib/eal/include/rte_eal.h | 3 --- lib/eal/include/rte_thread.h | 9 +++++++-- lib/eal/linux/eal.c | 2 +- lib/eal/linux/eal_thread.c | 2 +- lib/eal/windows/eal.c | 2 +- lib/eal/windows/rte_thread.c | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 9e1e267955..39a2868523 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -583,7 +583,7 @@ rte_eal_init(int argc, char **argv) static uint32_t run_once; uint32_t has_run = 0; char cpuset[RTE_CPU_AFFINITY_STR_LEN]; - char thread_name[RTE_MAX_THREAD_NAME_LEN]; + char thread_name[RTE_THREAD_NAME_SIZE]; const struct rte_config *config = rte_eal_get_configuration(); struct internal_config *internal_conf = eal_get_internal_configuration(); diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c index 3227d9b8a2..ba9b25c2c0 100644 --- a/lib/eal/freebsd/eal_thread.c +++ b/lib/eal/freebsd/eal_thread.c @@ -34,7 +34,7 @@ int rte_sys_gettid(void) void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name) { - char truncated[RTE_MAX_THREAD_NAME_LEN]; + char truncated[RTE_THREAD_NAME_SIZE]; const size_t truncatedsz = sizeof(truncated); if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz) diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h index 53c4a5519e..cd318ee141 100644 --- a/lib/eal/include/rte_eal.h +++ b/lib/eal/include/rte_eal.h @@ -27,9 +27,6 @@ extern "C" { #define RTE_MAGIC 19820526 /**< Magic number written by the main partition when ready. */ -/* Maximum thread_name length. */ -#define RTE_MAX_THREAD_NAME_LEN 16 - /** * The type of process in a linux, multi-process setup */ diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 369e2375f6..6233142322 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -23,6 +23,11 @@ extern "C" { #endif +/** Maximum thread name length (including '\0'). */ +#define RTE_THREAD_NAME_SIZE 16 +/* Old definition, aliased for compatibility. */ +#define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE + /** * Thread id descriptor. */ @@ -110,7 +115,7 @@ int rte_thread_create(rte_thread_t *thread_id, * Filled with the thread id of the new created thread. * @param name * The name of the control thread - * (max RTE_MAX_THREAD_NAME_LEN characters including '\0'). + * (max RTE_THREAD_NAME_SIZE characters including '\0'). * @param thread_attr * Attributes for the new thread. * @param thread_func @@ -188,7 +193,7 @@ rte_thread_t rte_thread_self(void); * The id of the thread to set name. * * @param thread_name - * The name to set. Truncated to RTE_MAX_THREAD_NAME_LEN, + * The name to set. Truncated to RTE_THREAD_NAME_SIZE, * including terminating NUL if necessary. */ __rte_experimental diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index a26822f667..5f4b2fb005 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -970,7 +970,7 @@ rte_eal_init(int argc, char **argv) static uint32_t run_once; uint32_t has_run = 0; char cpuset[RTE_CPU_AFFINITY_STR_LEN]; - char thread_name[RTE_MAX_THREAD_NAME_LEN]; + char thread_name[RTE_THREAD_NAME_SIZE]; bool phys_addrs; const struct rte_config *config = rte_eal_get_configuration(); struct internal_config *internal_conf = diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c index c07ad9d8a4..b9a126f3a8 100644 --- a/lib/eal/linux/eal_thread.c +++ b/lib/eal/linux/eal_thread.c @@ -24,7 +24,7 @@ void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name) int ret = ENOSYS; #if defined(__GLIBC__) && defined(__GLIBC_PREREQ) #if __GLIBC_PREREQ(2, 12) - char truncated[RTE_MAX_THREAD_NAME_LEN]; + char truncated[RTE_THREAD_NAME_SIZE]; const size_t truncatedsz = sizeof(truncated); if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz) diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 16c1ba1596..7ec2152211 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -283,7 +283,7 @@ rte_eal_init(int argc, char **argv) enum rte_iova_mode iova_mode; int ret; char cpuset[RTE_CPU_AFFINITY_STR_LEN]; - char thread_name[RTE_MAX_THREAD_NAME_LEN]; + char thread_name[RTE_THREAD_NAME_SIZE]; eal_log_init(NULL, 0); diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c index e528ac9991..acf648456c 100644 --- a/lib/eal/windows/rte_thread.c +++ b/lib/eal/windows/rte_thread.c @@ -324,7 +324,7 @@ void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name) { int ret = 0; - wchar_t wname[RTE_MAX_THREAD_NAME_LEN]; + wchar_t wname[RTE_THREAD_NAME_SIZE]; mbstate_t state = {0}; size_t rv; HANDLE thread_handle; From patchwork Wed Sep 13 10:34:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131378 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3A6D742588; Wed, 13 Sep 2023 12:36:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 228F640689; Wed, 13 Sep 2023 12:36:42 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id B8A5240685 for ; Wed, 13 Sep 2023 12:36:40 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 371E23200034; Wed, 13 Sep 2023 06:36:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 06:36:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601397; x=1694687797; bh=EUKNyUWMwzAdPPKZvr+lgcbvVSZusN28/YR l3AeLfus=; b=kxlAtWn9BDidL+nMLTPdi0HW1nZoCj1hVpo4DU2aYUSMy8BLL2c SzQaLuwvMFWHHaJv91Fe/TUB5JoWb0GMzo5MArKnB6EGT5CfVrpsqmrbM7Hh+hUH 6UetsTjYKkkCOJpJ0nf79tijHx2GZl7eW3bGGIJwwJrQ3zmtuzol3ljz6Z9qhwQQ D8qJi9lWXGcmWurilEMRENg5x+ykAhCzmzzetMwpcYFEY4aI6SZ6B6rAXEv2XLXo BvMNv+6HNAxUBHcQg4Q0Wxl+LI55Z3t/fTjYgrlZg8w6pD4gICv9sHAfDRwue64i BoTnwHRUi5miVLbVl8nDHY9aUyVq/pfcQFw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601397; x=1694687797; bh=EUKNyUWMwzAdPPKZvr+lgcbvVSZusN28/YR l3AeLfus=; b=KBsbQslg8aq5IQHuhKgyyqFlUusAr9id9rtWNdd8V4ujbS8URag UdxNNqiOXJXQ0wxudIiu85FgcQo991izPTBSU0Q9ELfX9+sZU1f+tWE+v1y1d3qm 8XL0J4990p2sm3KW4UoOUBV+KGuKdRJkXbgM3YIsiQsns8JTM+3ruPhI5KzfdGy0 6mcErv+mizahdTtPxX148fpQCGtvTQvUqSl1YUz1I2YqPGAWyfNrk9xWQSrBtPfW FqQGAwNgjNjcmOJOk+1Ru6IVtHmyY6SZei5C58LB2nxEQvihbcemNdN9UCsiW6H1 tOi0tqt0Wq/v2qeq75jQ8aXr9e1u5hvv44g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:36:32 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Chengwen Feng , Kevin Laatz , Bruce Richardson , Jingjing Wu , Beilei Xing , Qiming Yang , Qi Zhang , Wenjun Wu , Jiawen Wu , Jian Wang , Harman Kalra , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v2 03/11] eal: remove attributes from control thread creation Date: Wed, 13 Sep 2023 12:34:22 +0200 Message-ID: <20230913103600.1935292-4-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The experimental function rte_thread_create_control() is supposed to wrap actions needed to create a control thread in DPDK. This function should be easy to port on any OS. As such, the thread attributes should not be customizable in this API. The thread priority should be normal, and the affinity is on "free cores". That's why the custom attributes parameter thread_attr is dropped. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- app/test/test_threads.c | 2 +- doc/guides/rel_notes/release_23_11.rst | 3 +++ drivers/dma/skeleton/skeleton_dmadev.c | 3 +-- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/ice_dcf_parent.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 1 - drivers/net/txgbe/txgbe_ethdev.c | 2 +- lib/eal/common/eal_common_thread.c | 5 ++--- lib/eal/include/rte_thread.h | 5 +---- lib/eal/windows/eal_interrupts.c | 2 +- 10 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/test/test_threads.c b/app/test/test_threads.c index 8c27e2bae1..4ac3f2671a 100644 --- a/app/test/test_threads.c +++ b/app/test/test_threads.c @@ -240,7 +240,7 @@ test_thread_control_create_join(void) thread_id_ready = 0; RTE_TEST_ASSERT(rte_thread_create_control(&thread_id, "dpdk-test-thcc", - NULL, thread_main, &thread_main_id) == 0, + thread_main, &thread_main_id) == 0, "Failed to create thread."); while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 333e1d95a2..d3d500f294 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -113,6 +113,9 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* eal: The thread API has changed. + The function ``rte_thread_create_control()`` does not take attributes anymore. + ABI Changes ----------- diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index 493224542f..4fc2319668 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -128,8 +128,7 @@ skeldma_start(struct rte_dma_dev *dev) rte_mb(); snprintf(name, sizeof(name), "dpdk-dma-skel%d", dev->data->dev_id); - ret = rte_thread_create_control(&hw->thread, name, NULL, - cpucopy_thread, dev); + ret = rte_thread_create_control(&hw->thread, name, cpucopy_thread, dev); if (ret) { SKELDMA_LOG(ERR, "Start cpucopy thread fail!"); return -EINVAL; diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index c31a6d5c98..6baa6d5955 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -136,7 +136,7 @@ iavf_dev_event_handler_init(void) pthread_mutex_init(&handler->lock, NULL); if (rte_thread_create_control(&handler->tid, "dpdk-iavf-event", - NULL, iavf_dev_event_handle, NULL)) { + iavf_dev_event_handle, NULL)) { __atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED); return -1; } diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index ad98a531de..d3bb65874f 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -182,7 +182,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id) param->vf_id = vf_id; snprintf(name, sizeof(name), "dpdk-ice-rst%u", vf_id); - ret = rte_thread_create_control(&thread, name, NULL, + ret = rte_thread_create_control(&thread, name, ice_dcf_vsi_update_service_handler, param); if (ret != 0) { PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling"); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 7eac05ee60..64e7e5d7d6 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4330,7 +4330,6 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; if (rte_thread_create_control(&ad->link_thread_tid, "dpdk-ixgbe-link", - NULL, ixgbe_dev_setup_link_thread_handler, dev) < 0) { PMD_DRV_LOG(ERR, diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 6f2f5a1841..198fac8318 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -2897,7 +2897,7 @@ txgbe_dev_link_update_share(struct rte_eth_dev *dev, */ intr->flags |= TXGBE_FLAG_NEED_LINK_CONFIG; if (rte_thread_create_control(&ad->link_thread_tid, - "dpdk-txgbe-link", NULL, + "dpdk-txgbe-link", txgbe_dev_setup_link_thread_handler, dev) < 0) { PMD_DRV_LOG(ERR, "Create link thread failed!"); __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c index 6605bd017e..07ac721da1 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -349,8 +349,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, int rte_thread_create_control(rte_thread_t *thread, const char *name, - const rte_thread_attr_t *attr, rte_thread_func start_routine, - void *arg) + rte_thread_func start_routine, void *arg) { struct rte_thread_ctrl_params *params; enum __rte_ctrl_thread_status ctrl_thread_status; @@ -365,7 +364,7 @@ rte_thread_create_control(rte_thread_t *thread, const char *name, params->ret = 0; params->ctrl_thread_status = CTRL_THREAD_LAUNCHING; - ret = rte_thread_create(thread, attr, control_thread_start, params); + ret = rte_thread_create(thread, NULL, control_thread_start, params); if (ret != 0) { free(params); return -ret; diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 6233142322..28cc5220a4 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -116,8 +116,6 @@ int rte_thread_create(rte_thread_t *thread_id, * @param name * The name of the control thread * (max RTE_THREAD_NAME_SIZE characters including '\0'). - * @param thread_attr - * Attributes for the new thread. * @param thread_func * Function to be executed by the new thread. * @param arg @@ -129,8 +127,7 @@ int rte_thread_create(rte_thread_t *thread_id, __rte_experimental int rte_thread_create_control(rte_thread_t *thread, const char *name, - const rte_thread_attr_t *thread_attr, rte_thread_func thread_func, - void *arg); + rte_thread_func thread_func, void *arg); /** * @warning diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c index b1b1228c2b..66a49c844a 100644 --- a/lib/eal/windows/eal_interrupts.c +++ b/lib/eal/windows/eal_interrupts.c @@ -98,7 +98,7 @@ rte_eal_intr_init(void) return -1; } - ret = rte_thread_create_control(&intr_thread, "dpdk-intr", NULL, + ret = rte_thread_create_control(&intr_thread, "dpdk-intr", eal_intr_thread_main, NULL); if (ret != 0) { rte_errno = -ret; From patchwork Wed Sep 13 10:34:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131379 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E7C3042588; Wed, 13 Sep 2023 12:37:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3EE04067C; Wed, 13 Sep 2023 12:37:03 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id CB76D402E2 for ; Wed, 13 Sep 2023 12:37:01 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 89510320085B; Wed, 13 Sep 2023 06:37:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 13 Sep 2023 06:37:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601420; x=1694687820; bh=hlyDNq+UviAf6NbnW8IY9uFsNlBNIABWbp3 kCjdFB0g=; b=nwdU12Ly1lLtNE/rBTqKopGguTU3VhpjaB2O0pbEUX5jo2YY8RX fomdzta5arSp5j3H7A5/n+wldVCRjV2CjlNBDq0mRF1aeGlPMu3GRkxy8oGEGXxZ fXOa8p09jmegmZcRy7FPUb80N1xCVQkKQsagcpmK9DEK3P5OemHpQ9vI3cyce9/Y PutpF2B899Z5BjPE05fj2kcIwvOjI8EjyU+1dx2ddfjpWHEAsMT8stgcRDclwFs/ YcTi0CQdzRdf/NjitUd7BlqxytgBQYfQm0GDZ/o/+pi5Vf0N7IPQ2UqXLNSrau4l wIieom8jALca5IxuFM4SU1g3OKn66mg5jfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601420; x=1694687820; bh=hlyDNq+UviAf6NbnW8IY9uFsNlBNIABWbp3 kCjdFB0g=; b=XeJJlcf8vOGumXVolPG/O1JDdtHYr5t0zMLD2eR9Qj6ZvhOfylO Ci0VIwiyakwo/3So4Qn5WTeBklZuuVe5MoiPP9t0SLqfiLI7B3np6Zw//WjrWYMW nsbuquUNwJzWRavlG08bVI/PAsmFNF2BV6qAW4kEXfbpZ8+P4Ecvgo9hOrHrDv+p psn8tgwwxYPEsoTqWKyq9AmmeSqtfTU5Aisj93eQ81B6jhXlRx7o9amzVg1QtRqf WxMmu/muegBWQzaS+a2nR1CFrsrNnFVouCkqBEJmKFF3ggAEzKIjLDq5CXjR9LdC dhjZ/AIG94NEPLLvNA7tJR+6xsMv1AtYU3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:36:58 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH v2 04/11] eal: promote thread API as stable Date: Wed, 13 Sep 2023 12:34:23 +0200 Message-ID: <20230913103600.1935292-5-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The rte_thread API must be used to ease OS porting. One step of this process is to mark the necessary API as stable. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- doc/guides/rel_notes/release_23_11.rst | 1 + lib/eal/include/rte_thread.h | 64 -------------------------- lib/eal/version.map | 40 ++++++++-------- 3 files changed, 20 insertions(+), 85 deletions(-) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index d3d500f294..d7562fd646 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -115,6 +115,7 @@ API Changes * eal: The thread API has changed. The function ``rte_thread_create_control()`` does not take attributes anymore. + The whole thread API was promoted to stable level. ABI Changes diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 28cc5220a4..dd1f62523f 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -73,9 +73,6 @@ typedef struct { typedef struct eal_tls_key *rte_thread_key; /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Create a new thread that will invoke the 'thread_func' routine. * * @param thread_id @@ -94,15 +91,11 @@ typedef struct eal_tls_key *rte_thread_key; * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_create(rte_thread_t *thread_id, const rte_thread_attr_t *thread_attr, rte_thread_func thread_func, void *arg); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Create a control thread. * * Creates a control thread with the given name and attributes. The @@ -124,15 +117,11 @@ int rte_thread_create(rte_thread_t *thread_id, * On success, returns 0; on error, it returns a negative value * corresponding to the error number. */ -__rte_experimental int rte_thread_create_control(rte_thread_t *thread, const char *name, rte_thread_func thread_func, void *arg); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Waits for the thread identified by 'thread_id' to terminate * * @param thread_id @@ -145,13 +134,9 @@ rte_thread_create_control(rte_thread_t *thread, const char *name, * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Indicate that the return value of the thread is not needed and * all thread resources should be release when the thread terminates. * @@ -162,25 +147,17 @@ int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr); * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_detach(rte_thread_t thread_id); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Get the id of the calling thread. * * @return * Return the thread id of the calling thread. */ -__rte_experimental rte_thread_t rte_thread_self(void); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Set the name of the thread. * This API is a noop if the underlying platform does not * support setting the thread name or the platform-specific @@ -193,14 +170,10 @@ rte_thread_t rte_thread_self(void); * The name to set. Truncated to RTE_THREAD_NAME_SIZE, * including terminating NUL if necessary. */ -__rte_experimental void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Check if 2 thread ids are equal. * * @param t1 @@ -213,13 +186,9 @@ rte_thread_set_name(rte_thread_t thread_id, const char *thread_name); * If the ids are equal, return nonzero. * Otherwise, return 0. */ -__rte_experimental int rte_thread_equal(rte_thread_t t1, rte_thread_t t2); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Initialize the attributes of a thread. * These attributes can be passed to the rte_thread_create() function * that will create a new thread and set its attributes according to attr. @@ -231,13 +200,9 @@ int rte_thread_equal(rte_thread_t t1, rte_thread_t t2); * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_attr_init(rte_thread_attr_t *attr); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Set the thread priority value in the thread attributes pointed to * by 'thread_attr'. * @@ -251,16 +216,12 @@ int rte_thread_attr_init(rte_thread_attr_t *attr); * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, enum rte_thread_priority priority); #ifdef RTE_HAS_CPUSET /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Set the CPU affinity value in the thread attributes pointed to * by 'thread_attr'. * @@ -274,14 +235,10 @@ int rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, rte_cpuset_t *cpuset); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Get the value of CPU affinity that is set in the thread attributes pointed * to by 'thread_attr'. * @@ -295,14 +252,10 @@ int rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, rte_cpuset_t *cpuset); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Set the affinity of thread 'thread_id' to the cpu set * specified by 'cpuset'. * @@ -316,14 +269,10 @@ int rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_set_affinity_by_id(rte_thread_t thread_id, const rte_cpuset_t *cpuset); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Get the affinity of thread 'thread_id' and store it * in 'cpuset'. * @@ -337,7 +286,6 @@ int rte_thread_set_affinity_by_id(rte_thread_t thread_id, * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_get_affinity_by_id(rte_thread_t thread_id, rte_cpuset_t *cpuset); @@ -364,9 +312,6 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); #endif /* RTE_HAS_CPUSET */ /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Get the priority of a thread. * * @param thread_id @@ -379,14 +324,10 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_get_priority(rte_thread_t thread_id, enum rte_thread_priority *priority); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice. - * * Set the priority of a thread. * * @param thread_id @@ -399,7 +340,6 @@ int rte_thread_get_priority(rte_thread_t thread_id, * On success, return 0. * On failure, return a positive errno-style error number. */ -__rte_experimental int rte_thread_set_priority(rte_thread_t thread_id, enum rte_thread_priority priority); @@ -421,7 +361,6 @@ int rte_thread_set_priority(rte_thread_t thread_id, * ENOEXEC - Specific OS error. */ -__rte_experimental int rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *)); @@ -437,7 +376,6 @@ int rte_thread_key_create(rte_thread_key *key, * rte_errno can be: EINVAL - Invalid parameter passed. * ENOEXEC - Specific OS error. */ -__rte_experimental int rte_thread_key_delete(rte_thread_key key); /** @@ -454,7 +392,6 @@ int rte_thread_key_delete(rte_thread_key key); * rte_errno can be: EINVAL - Invalid parameter passed. * ENOEXEC - Specific OS error. */ -__rte_experimental int rte_thread_value_set(rte_thread_key key, const void *value); /** @@ -469,7 +406,6 @@ int rte_thread_value_set(rte_thread_key key, const void *value); * rte_errno can be: EINVAL - Invalid parameter passed. * ENOEXEC - Specific OS error. */ -__rte_experimental void *rte_thread_value_get(rte_thread_key key); #ifdef __cplusplus diff --git a/lib/eal/version.map b/lib/eal/version.map index 7940431e5a..33b853d7be 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -257,12 +257,31 @@ DPDK_24 { rte_strscpy; rte_strsplit; rte_sys_gettid; + rte_thread_attr_get_affinity; + rte_thread_attr_init; + rte_thread_attr_set_affinity; + rte_thread_attr_set_priority; + rte_thread_create; + rte_thread_create_control; + rte_thread_detach; + rte_thread_equal; rte_thread_get_affinity; + rte_thread_get_affinity_by_id; + rte_thread_get_priority; rte_thread_is_intr; + rte_thread_join; + rte_thread_key_create; + rte_thread_key_delete; rte_thread_register; + rte_thread_self; rte_thread_set_affinity; + rte_thread_set_affinity_by_id; + rte_thread_set_name; + rte_thread_set_priority; rte_thread_setname; rte_thread_unregister; + rte_thread_value_get; + rte_thread_value_set; rte_uuid_compare; rte_uuid_is_null; rte_uuid_parse; @@ -368,10 +387,6 @@ EXPERIMENTAL { # added in 21.05 rte_devargs_reset; rte_intr_callback_unregister_sync; - rte_thread_key_create; - rte_thread_key_delete; - rte_thread_value_get; - rte_thread_value_set; rte_version_minor; rte_version_month; rte_version_prefix; @@ -392,26 +407,9 @@ EXPERIMENTAL { # added in 22.07 rte_drand; - rte_thread_get_affinity_by_id; - rte_thread_get_priority; - rte_thread_self; - rte_thread_set_affinity_by_id; - rte_thread_set_priority; - - # added in 22.11 - rte_thread_attr_get_affinity; - rte_thread_attr_init; - rte_thread_attr_set_affinity; - rte_thread_attr_set_priority; - rte_thread_create; - rte_thread_detach; - rte_thread_equal; - rte_thread_join; # added in 23.03 rte_lcore_register_usage_cb; - rte_thread_create_control; - rte_thread_set_name; __rte_eal_trace_generic_blob; # added in 23.07 From patchwork Wed Sep 13 10:34:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131380 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91F9842588; Wed, 13 Sep 2023 12:37:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28BCA4064A; Wed, 13 Sep 2023 12:37:09 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 6461940698 for ; Wed, 13 Sep 2023 12:37:07 +0200 (CEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 29DB03200034; Wed, 13 Sep 2023 06:37:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 13 Sep 2023 06:37:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601425; x=1694687825; bh=lzZrcDoZqS8nGj9M1y0hbtQRNekkmoZFyrn dO3XUe7Y=; b=oM46EFr+jtSCI8Cu2KxZLEQyasftRuJ8LwzJgnGaweJ+D7hMud8 bcr5xE5b9+mqiKjmeNAmHwYqKxsBUNBXtfNrjLn/Go/kQJDgTngJVrvLxI8Mtv8i ghZX/epY70Yqa4/O18PyGlM9GSPByNDkdH3KUg4xMa8p41/zLXNypnNr4dkSUYNy BCuqU5EzHSytXQA5xeR9X8FBLf8q/qru0jXDIULxJD04hkj+cfk8aw2PWehgZV0l 7jp1ufhZpvCo96ZGP66DDJPqKN/TnqQM5lXgelcXlV5uPzx85hoAa/U2JxzwbYOh K1RdSxWtf4gw2HbcLg3QBQNA0YPrEg3CXKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601425; x=1694687825; bh=lzZrcDoZqS8nGj9M1y0hbtQRNekkmoZFyrn dO3XUe7Y=; b=WO4rwwblbh6ky7opihaMTevBTsXVZrBcCbdVBtr8rPSIGHgyNR0 rJXjE+U9DLvwNbK3+ZT8y+lVOVy2Ps6/tK+Cpjg2AybmFeiUjmqkY3H5q5jSRlSm nN1wX1AMifEvKFNdlXwwNjnkBUiKUz1RrLS2fBS3zbHPrbMGsxHjzMSsy/ozgDSe IcOxOdnGHcWnaWxo9zpHQWcgff0FggwR1bYOOiOIzW3crAuh9aSNwX3f4OSyaqvA cfcJWyFODX8gelTkmbJrAE+otJ5mOogYGjVSbM9LVWk1Ihel8wBVYAECCDJed3p4 1k5myfaOXq2+EBgvWgOCW6QMUwTSXp1O+3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:37:04 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH v2 05/11] eal: force prefix for internal threads Date: Wed, 13 Sep 2023 12:34:24 +0200 Message-ID: <20230913103600.1935292-6-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org In order to make sure all threads created in DPDK drivers and libraries have the same prefix in their name, some wrapper functions are added for internal use when creating a control thread or setting a thread name: - rte_thread_create_internal_control - rte_thread_set_prefixed_name The equivalent public functions are then forbidden for internal use: - rte_thread_create_control - rte_thread_set_name Note: the libraries and drivers conversion is done in next patches, while doing other thread-related changes. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- v2: simplify size doc + build time check of internal name size --- devtools/checkpatches.sh | 8 ++++ lib/eal/common/eal_common_thread.c | 29 +++++++++++++++ lib/eal/include/rte_thread.h | 59 +++++++++++++++++++++++++++++- lib/eal/version.map | 2 + 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index ec9d232393..e97811192a 100755 --- a/devtools/checkpatches.sh +++ b/devtools/checkpatches.sh @@ -159,6 +159,14 @@ check_forbidden_additions() { # -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ "$1" || res=1 + # forbid non-internal thread in drivers and libs + awk -v FOLDERS='lib drivers' \ + -v EXPRESSIONS="rte_thread_(set_name|create_control)\\\(" \ + -v RET_ON_FAIL=1 \ + -v MESSAGE='Prefer rte_thread_(set_prefixed_name|create_internal_control) in lib & drivers' \ + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ + "$1" || res=1 + # forbid inclusion of driver specific headers in apps and examples awk -v FOLDERS='app examples' \ -v EXPRESSIONS='include.*_driver\\.h include.*_pmd\\.h' \ diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c index 07ac721da1..cd6e00fe8a 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -392,6 +392,35 @@ rte_thread_create_control(rte_thread_t *thread, const char *name, return ret; } +static void +add_internal_prefix(char *prefixed_name, const char *name, size_t size) +{ + size_t prefixlen; + + prefixlen = strlen(RTE_THREAD_INTERNAL_PREFIX); + strlcpy(prefixed_name, RTE_THREAD_INTERNAL_PREFIX, size); + strlcpy(prefixed_name + prefixlen, name, size - prefixlen); +} + +int +rte_thread_create_internal_control(rte_thread_t *id, const char *name, + rte_thread_func func, void *arg) +{ + char prefixed_name[RTE_THREAD_NAME_SIZE]; + + add_internal_prefix(prefixed_name, name, sizeof(prefixed_name)); + return rte_thread_create_control(id, prefixed_name, func, arg); +} + +void +rte_thread_set_prefixed_name(rte_thread_t id, const char *name) +{ + char prefixed_name[RTE_THREAD_NAME_SIZE]; + + add_internal_prefix(prefixed_name, name, sizeof(prefixed_name)); + rte_thread_set_name(id, prefixed_name); +} + int rte_thread_register(void) { diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index dd1f62523f..afede97bed 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -28,6 +28,13 @@ extern "C" { /* Old definition, aliased for compatibility. */ #define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE +/** Thread name prefix automatically added to all internal threads. */ +#define RTE_THREAD_INTERNAL_PREFIX "dpdk-" +/** Maximum internal thread name length (including '\0'). */ +#define RTE_THREAD_INTERNAL_NAME_SIZE 11 +RTE_BUILD_BUG_ON(RTE_THREAD_INTERNAL_NAME_SIZE != + RTE_THREAD_NAME_SIZE - sizeof(RTE_THREAD_INTERNAL_PREFIX) + 1) + /** * Thread id descriptor. */ @@ -112,7 +119,7 @@ int rte_thread_create(rte_thread_t *thread_id, * @param thread_func * Function to be executed by the new thread. * @param arg - * Argument passed to start_routine. + * Argument passed to thread_func. * @return * On success, returns 0; on error, it returns a negative value * corresponding to the error number. @@ -121,6 +128,35 @@ int rte_thread_create_control(rte_thread_t *thread, const char *name, rte_thread_func thread_func, void *arg); +/** + * Create an internal control thread. + * + * Creates a control thread with the given name prefixed. + * If setting the name of the thread fails, the error is ignored and logged. + * + * The affinity of the new thread is based on the CPU affinity retrieved + * at the time rte_eal_init() was called, the EAL threads are then excluded. + * + * @param id + * Filled with the thread ID of the new created thread. + * @param name + * The name of the control thread. + * See RTE_THREAD_INTERNAL_NAME_SIZE for maximum length. + * The name of the driver or library should be first, + * then followed by a hyphen and more details. + * It will be prefixed with RTE_THREAD_INTERNAL_PREFIX by this function. + * @param func + * Function to be executed by the new thread. + * @param arg + * Argument passed to func. + * @return + * On success, returns 0; a negative value otherwise. + */ +__rte_internal +int +rte_thread_create_internal_control(rte_thread_t *id, const char *name, + rte_thread_func func, void *arg); + /** * Waits for the thread identified by 'thread_id' to terminate * @@ -159,6 +195,7 @@ rte_thread_t rte_thread_self(void); /** * Set the name of the thread. + * * This API is a noop if the underlying platform does not * support setting the thread name or the platform-specific * API used to set the thread name fails. @@ -173,6 +210,26 @@ rte_thread_t rte_thread_self(void); void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name); +/** + * Set the name of an internal thread with the common prefix. + * + * This API is a noop if the underlying platform does not support + * setting the thread name, or if it fails. + * + * @param id + * The ID of the thread to set name. + * + * @param name + * The name to set after being prefixed. + * See RTE_THREAD_INTERNAL_NAME_SIZE for maximum length. + * The name of the driver or library should be first, + * then followed by a hyphen and more details. + * It will be prefixed with RTE_THREAD_INTERNAL_PREFIX by this function. + */ +__rte_internal +void +rte_thread_set_prefixed_name(rte_thread_t id, const char *name); + /** * Check if 2 thread ids are equal. * diff --git a/lib/eal/version.map b/lib/eal/version.map index 33b853d7be..6d32c19286 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -462,4 +462,6 @@ INTERNAL { rte_mem_map; rte_mem_page_size; rte_mem_unmap; + rte_thread_create_internal_control; + rte_thread_set_prefixed_name; }; From patchwork Wed Sep 13 10:34:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131381 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9752942588; Wed, 13 Sep 2023 12:37:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82E04406A2; Wed, 13 Sep 2023 12:37:33 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 5F800402E2 for ; Wed, 13 Sep 2023 12:37:31 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 20CC33200034; Wed, 13 Sep 2023 06:37:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 06:37:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601448; x=1694687848; bh=ecpQRRc/6W/1/MdPdGqxXxKE5PvQ6KULBf6 JwkOr8Rg=; b=nVYnZmJp8RMc8xc0KnhFmv1SCfizYsjGRO9o9NS9dGaA3UK1V9A 6XE0RFCPH3ZuOgZk8ZwYcq6wojNcj9xJhpxBADN4zBGauQDGqvWAu1N6hqBzc9wP dI6njXRqvKaZ2J9nWeV4tzG1QqSIK7F813lbwepN9uuwbGijzRGWePilE3SKW7qM ur+CRfY2oR7b9zFoRe/MmREH1pbAJ6WX/FNUDGzNkNE/1LN8IcfNZoERrCj0sc7v LvRwJMG4AovXkstPWmyQ10PaRbWjEBmFsC1aBFpgL2V18Hjv25s4JiyDm8a9sHy3 ZpKR+QDDlwOvJ/9NSjkf+rETFlG/MDiuLsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601448; x=1694687848; bh=ecpQRRc/6W/1/MdPdGqxXxKE5PvQ6KULBf6 JwkOr8Rg=; b=nw+j32/frWivmW/q8A93aptlp2DcQk0AZH8PCo2Ks4DE4SGOe1b 1OS5OudPv9QiRX5DMmPxUT7T1jz2pCqedSIK/MPRYeki2zmoxHRFW5PwWtQjhSuy hm5686vpXBjQUQPE6otvP9jkfdjDOFT9aMPBSZnA+ri/ZlnGH9GmM4bg9qcGMTqd 8xy7+uiRCIgJ45zkGZn/y3kyPi411U+QoTBmsri3qhTQhaqT5HMsXUypF0q0PPHB UuAE9AgSuYpwON8r5n5PS6LUXXsvxwlxi2XBSoOMZ6XeplubxiLYfEkgY74XkbV+ ebisyszHmDnoEfKjByz7OGoERR4pQI55H4w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:37:26 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Anatoly Burakov , Harman Kalra , Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Naga Harish K S V , Jerin Jacob , Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 06/11] lib: convert to internal control threads Date: Wed, 13 Sep 2023 12:34:25 +0200 Message-ID: <20230913103600.1935292-7-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Calls to rte_ctrl_thread_create() are replaced with rte_thread_create_internal_control(). Other pthread-related functions are replaced with the rte_thread API. Only pthread_cancel() has no replacement. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- lib/eal/common/eal_common_proc.c | 15 ++++++++------- lib/eal/freebsd/eal_interrupts.c | 10 +++++----- lib/eal/linux/eal_interrupts.c | 10 +++++----- lib/eal/linux/eal_timer.c | 11 ++++++----- lib/eal/unix/rte_thread.c | 2 +- lib/eal/windows/eal_interrupts.c | 2 +- lib/eventdev/rte_event_eth_rx_adapter.c | 23 ++++++++++++----------- lib/vhost/fd_man.c | 6 +++--- lib/vhost/fd_man.h | 2 +- lib/vhost/socket.c | 23 +++++++++++------------ lib/vhost/vduse.c | 5 +++-- 11 files changed, 56 insertions(+), 53 deletions(-) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index 26e6b78f8f..f20a348ede 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "eal_memcfg.h" #include "eal_private.h" @@ -33,7 +34,7 @@ #include "eal_internal_cfg.h" static int mp_fd = -1; -static pthread_t mp_handle_tid; +static rte_thread_t mp_handle_tid; static char mp_filter[PATH_MAX]; /* Filter for secondary process sockets */ static char mp_dir_path[PATH_MAX]; /* The directory path for all mp sockets */ static pthread_mutex_t mp_mutex_action = PTHREAD_MUTEX_INITIALIZER; @@ -396,7 +397,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) } } -static void * +static uint32_t mp_handle(void *arg __rte_unused) { struct mp_msg_internal msg; @@ -413,7 +414,7 @@ mp_handle(void *arg __rte_unused) process_msg(&msg, &sa); } - return NULL; + return 0; } static int @@ -646,8 +647,8 @@ rte_mp_channel_init(void) return -1; } - if (rte_ctrl_thread_create(&mp_handle_tid, "dpdk-mp-msg", - NULL, mp_handle, NULL) < 0) { + if (rte_thread_create_internal_control(&mp_handle_tid, "mp-msg", + mp_handle, NULL) < 0) { RTE_LOG(ERR, EAL, "failed to create mp thread: %s\n", strerror(errno)); close(dir_fd); @@ -671,8 +672,8 @@ rte_mp_channel_cleanup(void) if (fd < 0) return; - pthread_cancel(mp_handle_tid); - pthread_join(mp_handle_tid, NULL); + pthread_cancel((pthread_t)mp_handle_tid.opaque_id); + rte_thread_join(mp_handle_tid, NULL); close_socket_fd(fd); } diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c index 68cdb9deb3..2b31dfb099 100644 --- a/lib/eal/freebsd/eal_interrupts.c +++ b/lib/eal/freebsd/eal_interrupts.c @@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER; static struct rte_intr_source_list intr_sources; /* interrupt handling thread */ -static pthread_t intr_thread; +static rte_thread_t intr_thread; static volatile int kq = -1; @@ -591,7 +591,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds) } } -static void * +static uint32_t eal_intr_thread_main(void *arg __rte_unused) { struct kevent events[MAX_INTR_EVENTS]; @@ -619,7 +619,7 @@ eal_intr_thread_main(void *arg __rte_unused) } close(kq); kq = -1; - return NULL; + return 0; } int @@ -637,7 +637,7 @@ rte_eal_intr_init(void) } /* create the host thread to wait/handle the interrupt */ - ret = rte_ctrl_thread_create(&intr_thread, "dpdk-intr", NULL, + ret = rte_thread_create_internal_control(&intr_thread, "intr", eal_intr_thread_main, NULL); if (ret != 0) { rte_errno = -ret; @@ -746,5 +746,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) int rte_thread_is_intr(void) { - return pthread_equal(intr_thread, pthread_self()); + return rte_thread_equal(intr_thread, rte_thread_self()); } diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index 19b36787b8..24fff3d3c2 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -89,7 +89,7 @@ static union intr_pipefds intr_pipe; static struct rte_intr_source_list intr_sources; /* interrupt handling thread */ -static pthread_t intr_thread; +static rte_thread_t intr_thread; /* VFIO interrupts */ #ifdef VFIO_PRESENT @@ -1103,7 +1103,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds) * @return * never return; */ -static __rte_noreturn void * +static __rte_noreturn uint32_t eal_intr_thread_main(__rte_unused void *arg) { /* host thread, never break out */ @@ -1188,7 +1188,7 @@ rte_eal_intr_init(void) } /* create the host thread to wait/handle the interrupt */ - ret = rte_ctrl_thread_create(&intr_thread, "dpdk-intr", NULL, + ret = rte_thread_create_internal_control(&intr_thread, "intr", eal_intr_thread_main, NULL); if (ret != 0) { rte_errno = -ret; @@ -1601,5 +1601,5 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle) int rte_thread_is_intr(void) { - return pthread_equal(intr_thread, pthread_self()); + return rte_thread_equal(intr_thread, rte_thread_self()); } diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c index 1898709700..3a30284e3a 100644 --- a/lib/eal/linux/eal_timer.c +++ b/lib/eal/linux/eal_timer.c @@ -14,6 +14,7 @@ #include #include +#include #include "eal_private.h" @@ -71,14 +72,14 @@ static uint64_t eal_hpet_resolution_hz = 0; /* Incremented 4 times during one 32bits hpet full count */ static uint32_t eal_hpet_msb; -static pthread_t msb_inc_thread_id; +static rte_thread_t msb_inc_thread_id; /* * This function runs on a specific thread to update a global variable * containing used to process MSB of the HPET (unfortunately, we need * this because hpet is 32 bits by default under linux). */ -static void * +static uint32_t hpet_msb_inc(__rte_unused void *arg) { uint32_t t; @@ -89,7 +90,7 @@ hpet_msb_inc(__rte_unused void *arg) eal_hpet_msb ++; sleep(10); } - return NULL; + return 0; } uint64_t @@ -176,8 +177,8 @@ rte_eal_hpet_init(int make_default) /* create a thread that will increment a global variable for * msb (hpet is 32 bits by default under linux) */ - ret = rte_ctrl_thread_create(&msb_inc_thread_id, "dpdk-hpet-msb", NULL, - hpet_msb_inc, NULL); + ret = rte_thread_create_internal_control(&msb_inc_thread_id, "hpet-msb", + hpet_msb_inc, NULL); if (ret != 0) { RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n"); internal_conf->no_hpet = 1; diff --git a/lib/eal/unix/rte_thread.c b/lib/eal/unix/rte_thread.c index f4076122a4..36a21ab2f9 100644 --- a/lib/eal/unix/rte_thread.c +++ b/lib/eal/unix/rte_thread.c @@ -190,7 +190,7 @@ rte_thread_create(rte_thread_t *thread_id, pthread_mutex_unlock(&ctx.wrapper_mutex); if (ret != 0) - pthread_join((pthread_t)thread_id->opaque_id, NULL); + rte_thread_join(*thread_id, NULL); cleanup: if (attrp != NULL) diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c index 66a49c844a..49efdc098c 100644 --- a/lib/eal/windows/eal_interrupts.c +++ b/lib/eal/windows/eal_interrupts.c @@ -98,7 +98,7 @@ rte_eal_intr_init(void) return -1; } - ret = rte_thread_create_control(&intr_thread, "dpdk-intr", + ret = rte_thread_create_internal_control(&intr_thread, "intr", eal_intr_thread_main, NULL); if (ret != 0) { rte_errno = -ret; diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c index 3ebfa5366d..c166ef69a8 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.c +++ b/lib/eventdev/rte_event_eth_rx_adapter.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -165,7 +166,7 @@ struct event_eth_rx_adapter { /* Count of interrupt vectors in use */ uint32_t num_intr_vec; /* Thread blocked on Rx interrupts */ - pthread_t rx_intr_thread; + rte_thread_t rx_intr_thread; /* Configuration callback for rte_service configuration */ rte_event_eth_rx_adapter_conf_cb conf_cb; /* Configuration callback argument */ @@ -1154,13 +1155,13 @@ rxa_intr_ring_del_entries(struct event_eth_rx_adapter *rx_adapter, rte_spinlock_unlock(&rx_adapter->intr_ring_lock); } -/* pthread callback handling interrupt mode receive queues +/* thread callback handling interrupt mode receive queues * After receiving an Rx interrupt, it enqueues the port id and queue id of the * interrupting queue to the adapter's ring buffer for interrupt events. * These events are picked up by rxa_intr_ring_dequeue() which is invoked from * the adapter service function. */ -static void * +static uint32_t rxa_intr_thread(void *arg) { struct event_eth_rx_adapter *rx_adapter = arg; @@ -1179,7 +1180,7 @@ rxa_intr_thread(void *arg) } } - return NULL; + return 0; } /* Dequeue from interrupt ring and enqueue received @@ -1595,7 +1596,7 @@ static int rxa_create_intr_thread(struct event_eth_rx_adapter *rx_adapter) { int err; - char thread_name[RTE_MAX_THREAD_NAME_LEN]; + char thread_name[RTE_THREAD_INTERNAL_NAME_SIZE]; if (rx_adapter->intr_ring) return 0; @@ -1618,11 +1619,11 @@ rxa_create_intr_thread(struct event_eth_rx_adapter *rx_adapter) rte_spinlock_init(&rx_adapter->intr_ring_lock); - snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, - "dpdk-evt-rx%d", rx_adapter->id); + snprintf(thread_name, sizeof(thread_name), + "evt-rx%d", rx_adapter->id); - err = rte_ctrl_thread_create(&rx_adapter->rx_intr_thread, thread_name, - NULL, rxa_intr_thread, rx_adapter); + err = rte_thread_create_internal_control(&rx_adapter->rx_intr_thread, + thread_name, rxa_intr_thread, rx_adapter); if (!err) return 0; @@ -1640,12 +1641,12 @@ rxa_destroy_intr_thread(struct event_eth_rx_adapter *rx_adapter) { int err; - err = pthread_cancel(rx_adapter->rx_intr_thread); + err = pthread_cancel((pthread_t)rx_adapter->rx_intr_thread.opaque_id); if (err) RTE_EDEV_LOG_ERR("Can't cancel interrupt thread err = %d\n", err); - err = pthread_join(rx_adapter->rx_intr_thread, NULL); + err = rte_thread_join(rx_adapter->rx_intr_thread, NULL); if (err) RTE_EDEV_LOG_ERR("Can't join interrupt thread err = %d\n", err); diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c index 1876fada33..134414fb4b 100644 --- a/lib/vhost/fd_man.c +++ b/lib/vhost/fd_man.c @@ -212,7 +212,7 @@ fdset_try_del(struct fdset *pfdset, int fd) * will wait until the flag is reset to zero(which indicates the callback is * finished), then it could free the context after fdset_del. */ -void * +uint32_t fdset_event_dispatch(void *arg) { int i; @@ -227,7 +227,7 @@ fdset_event_dispatch(void *arg) int val; if (pfdset == NULL) - return NULL; + return 0; while (1) { @@ -303,7 +303,7 @@ fdset_event_dispatch(void *arg) fdset_shrink(pfdset); } - return NULL; + return 0; } static void diff --git a/lib/vhost/fd_man.h b/lib/vhost/fd_man.h index 6f4499bdfa..6315904c8e 100644 --- a/lib/vhost/fd_man.h +++ b/lib/vhost/fd_man.h @@ -46,7 +46,7 @@ int fdset_add(struct fdset *pfdset, int fd, void *fdset_del(struct fdset *pfdset, int fd); int fdset_try_del(struct fdset *pfdset, int fd); -void *fdset_event_dispatch(void *arg); +uint32_t fdset_event_dispatch(void *arg); int fdset_pipe_init(struct fdset *fdset); diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index 12095b0e1a..5882e44176 100644 --- a/lib/vhost/socket.c +++ b/lib/vhost/socket.c @@ -13,8 +13,8 @@ #include #include #include -#include +#include #include #include "fd_man.h" @@ -431,7 +431,7 @@ struct vhost_user_reconnect_list { }; static struct vhost_user_reconnect_list reconn_list; -static pthread_t reconn_tid; +static rte_thread_t reconn_tid; static int vhost_user_connect_nonblock(char *path, int fd, struct sockaddr *un, size_t sz) @@ -455,7 +455,7 @@ vhost_user_connect_nonblock(char *path, int fd, struct sockaddr *un, size_t sz) return 0; } -static void * +static uint32_t vhost_user_client_reconnect(void *arg __rte_unused) { int ret; @@ -496,7 +496,7 @@ vhost_user_client_reconnect(void *arg __rte_unused) sleep(1); } - return NULL; + return 0; } static int @@ -511,8 +511,8 @@ vhost_user_reconnect_init(void) } TAILQ_INIT(&reconn_list.head); - ret = rte_ctrl_thread_create(&reconn_tid, "dpdk-vhost-reco", NULL, - vhost_user_client_reconnect, NULL); + ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco", + vhost_user_client_reconnect, NULL); if (ret != 0) { VHOST_LOG_CONFIG("thread", ERR, "failed to create reconnect thread\n"); if (pthread_mutex_destroy(&reconn_list.mutex)) @@ -1004,7 +1004,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags) if (!vsocket->is_vduse) { if ((flags & RTE_VHOST_USER_CLIENT) != 0) { vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT); - if (vsocket->reconnect && reconn_tid == 0) { + if (vsocket->reconnect && reconn_tid.opaque_id == 0) { if (vhost_user_reconnect_init() != 0) goto out_mutex; } @@ -1174,7 +1174,7 @@ int rte_vhost_driver_start(const char *path) { struct vhost_user_socket *vsocket; - static pthread_t fdset_tid; + static rte_thread_t fdset_tid; pthread_mutex_lock(&vhost_user.mutex); vsocket = find_vhost_user_socket(path); @@ -1186,7 +1186,7 @@ rte_vhost_driver_start(const char *path) if (vsocket->is_vduse) return vduse_device_create(path, vsocket->net_compliant_ol_flags); - if (fdset_tid == 0) { + if (fdset_tid.opaque_id == 0) { /** * create a pipe which will be waited by poll and notified to * rebuild the wait list of poll. @@ -1196,9 +1196,8 @@ rte_vhost_driver_start(const char *path) return -1; } - int ret = rte_ctrl_thread_create(&fdset_tid, - "dpdk-vhost-evt", NULL, fdset_event_dispatch, - &vhost_user.fdset); + int ret = rte_thread_create_internal_control(&fdset_tid, + "vhost-evt", fdset_event_dispatch, &vhost_user.fdset); if (ret != 0) { VHOST_LOG_CONFIG(path, ERR, "failed to create fdset handling thread\n"); fdset_pipe_uninit(&vhost_user.fdset); diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c index 7770259f37..e342f53b81 100644 --- a/lib/vhost/vduse.c +++ b/lib/vhost/vduse.c @@ -16,6 +16,7 @@ #include #include +#include #include "fd_man.h" #include "iotlb.h" @@ -415,7 +416,7 @@ int vduse_device_create(const char *path, bool compliant_ol_flags) { int control_fd, dev_fd, vid, ret; - pthread_t fdset_tid; + rte_thread_t fdset_tid; uint32_t i, max_queue_pairs, total_queues; struct virtio_net *dev; struct virtio_net_config vnet_config = {{ 0 }}; @@ -435,7 +436,7 @@ vduse_device_create(const char *path, bool compliant_ol_flags) return -1; } - ret = rte_ctrl_thread_create(&fdset_tid, "dpdk-vduse-evt", NULL, + ret = rte_thread_create_internal_control(&fdset_tid, "vduse-evt", fdset_event_dispatch, &vduse.fdset); if (ret != 0) { VHOST_LOG_CONFIG(path, ERR, "failed to create vduse fdset handling thread\n"); From patchwork Wed Sep 13 10:34:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131382 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2750042588; Wed, 13 Sep 2023 12:37:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15B744067C; Wed, 13 Sep 2023 12:37:52 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id E6885402E2 for ; Wed, 13 Sep 2023 12:37:49 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 333D1320091C; Wed, 13 Sep 2023 06:37:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 13 Sep 2023 06:37:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601465; x=1694687865; bh=lBicXkbl7p6iD8AYhNBdzSBYrbBSMa+/z2j JChdqbe0=; b=a8ockrLw17X+WFHZvVzEAsI8kiMvh2f1hQfTQonc0EViHn7kuE+ 66o9q0beeijG/AcOJF3/YZAXDI/zldq3ilTkn+e3erXSlsgIr99fTI3LKvC7zIuf fu4cvoARo8ZTqIdkvTyT7Fr3seOGapwYY9XcCM3/v0zqmCbG4cLwR9E4U7Yda/hD a9wcmKpSCDjP6vuC02EbB8v9ffi1WNvXX3KhaSjeKaY2XNsiaVw29OZE3ZYrXyGp BTEnEBekBOJyrIrmApcf4Wx+YnxG1clBIr8M+8Z0jimJzdp0QfMHAk8ftBWWwm+d HnvOECdQlOKEv2uXnX5jjvqPyy3UCAJKjfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601465; x=1694687865; bh=lBicXkbl7p6iD8AYhNBdzSBYrbBSMa+/z2j JChdqbe0=; b=U2ZOq4w7/92qM62EQJuGcfzHQaQ0Quc9ncmoOJBOiTF6a2snZXv M5Sk7YT7jy/TbZlrb/mDC3BWlH0tYNktp8YTUZI3xD3/dLIHZo7hSR9nH2JhEpxo 1axYESWMWCEWYDMVOZsavL7JaeTIAG+/dePX/Vs83C6cP6atsjldVvLv2VYaLLEG awTp5OlxNjBV9popRtiehq1e2ziSpyiSVmckn7oXe93C6Q9BdKHcRNwFf5iV3+JU UIjlhyQSod/SM3RdHWFEvegW8NWMdahX/Xc4SSeP/cc3jaSxwUnqJvay9CY1v/lt 2cRYEir+6nkplLGsNBq76PvO9BjzXsv5bYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnhephfejtdejheeuffettdetgefgueetueelgeegffejhedutdek vdeuvdeujefhffeknecuffhomhgrihhnpehthhhrvggrugdrrhhunhdpthhhrhgvrggurd hiugenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeht hhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:37:40 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Andrew Rybchenko , Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Chengwen Feng , Kevin Laatz , Bruce Richardson , Abdullah Sevincer , Shepard Siegel , Ed Czeck , John Miller , Jingjing Wu , Beilei Xing , Qiming Yang , Qi Zhang , Rosen Xu , Wenjun Wu , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Jiawen Wu , Jian Wang , Tianfei Zhang , Xiao Wang , Vijay Kumar Srivastava Subject: [PATCH v2 07/11] drivers: convert to internal control threads Date: Wed, 13 Sep 2023 12:34:26 +0200 Message-ID: <20230913103600.1935292-8-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Calls to rte_ctrl_thread_create() are replaced with rte_thread_create_internal_control(). Other pthread-related functions are replaced with the rte_thread API. Only pthread_cancel() has no replacement. The mlx5 vDPA control threads were real-time threads with an affinity on the core specified by the devarg "event_core". As there is no heavy performance requirement, these threads are converted into real control threads. Some threads in dlb2 and mlx5 are not control threads because they are designed to run on some specific cores. It would be interesting to rework them in future. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff Acked-by: Andrew Rybchenko --- drivers/common/cnxk/roc_dev.c | 16 ++-- drivers/common/cnxk/roc_dev_priv.h | 2 +- drivers/common/cnxk/roc_nix_inl_dev.c | 9 +-- drivers/common/cnxk/roc_nix_inl_priv.h | 2 +- drivers/common/cnxk/roc_platform.h | 3 +- drivers/dma/skeleton/skeleton_dmadev.c | 7 +- drivers/event/dlb2/pf/base/dlb2_osdep.h | 14 ++-- drivers/event/dlb2/pf/base/dlb2_resource.c | 39 +++++----- drivers/event/dlb2/pf/dlb2_main.h | 1 - drivers/net/ark/ark_ethdev.c | 11 ++- drivers/net/ark/ark_pktgen.c | 8 +- drivers/net/ark/ark_pktgen.h | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/ice_dcf_parent.c | 7 +- drivers/net/ipn3ke/ipn3ke_representor.c | 17 ++--- drivers/net/ixgbe/ixgbe_ethdev.c | 7 +- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_hws_cnt.c | 42 ++++++----- drivers/net/sfc/sfc_mae.h | 2 +- drivers/net/sfc/sfc_mae_counter.c | 11 ++- drivers/net/txgbe/txgbe_ethdev.c | 6 +- drivers/raw/ifpga/ifpga_rawdev.c | 19 +++-- drivers/vdpa/ifc/ifcvf_vdpa.c | 86 ++++++++++------------ drivers/vdpa/mlx5/mlx5_vdpa.c | 2 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 10 +-- drivers/vdpa/mlx5/mlx5_vdpa_cthread.c | 70 +++++------------- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 64 +++++----------- drivers/vdpa/sfc/sfc_vdpa_ops.c | 15 ++-- drivers/vdpa/sfc/sfc_vdpa_ops.h | 3 +- 29 files changed, 203 insertions(+), 276 deletions(-) diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index 13d3eece47..08fd13f741 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -18,7 +18,7 @@ #define ROC_PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */ /* VF Mbox handler thread name */ -#define MBOX_HANDLER_NAME_MAX_LEN 25 +#define MBOX_HANDLER_NAME_MAX_LEN RTE_THREAD_INTERNAL_NAME_SIZE /* VF interrupt message pending bits - mbox or flr */ #define ROC_DEV_MBOX_PEND BIT_ULL(0) @@ -1070,7 +1070,7 @@ vf_flr_handle_msg(void *param, dev_intr_t *flr) } } -static void * +static uint32_t pf_vf_mbox_thread_main(void *arg) { struct dev *dev = arg; @@ -1114,7 +1114,7 @@ pf_vf_mbox_thread_main(void *arg) pthread_mutex_unlock(&dev->sync.mutex); - return NULL; + return 0; } static void @@ -1455,10 +1455,10 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev) pthread_cond_init(&dev->sync.pfvf_msg_cond, NULL); pthread_mutex_init(&dev->sync.mutex, NULL); - snprintf(name, MBOX_HANDLER_NAME_MAX_LEN, "pf%d_vf_msg_hndlr", dev->pf); + snprintf(name, MBOX_HANDLER_NAME_MAX_LEN, "mbox_pf%d", dev->pf); dev->sync.start_thread = true; - rc = plt_ctrl_thread_create(&dev->sync.pfvf_msg_thread, name, NULL, - pf_vf_mbox_thread_main, dev); + rc = plt_thread_create_control(&dev->sync.pfvf_msg_thread, name, + pf_vf_mbox_thread_main, dev); if (rc != 0) { plt_err("Failed to create thread for VF mbox handling\n"); goto iounmap; @@ -1488,7 +1488,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev) if (dev->sync.start_thread) { dev->sync.start_thread = false; pthread_cond_signal(&dev->sync.pfvf_msg_cond); - pthread_join(dev->sync.pfvf_msg_thread, NULL); + plt_thread_join(dev->sync.pfvf_msg_thread, NULL); pthread_mutex_destroy(&dev->sync.mutex); pthread_cond_destroy(&dev->sync.pfvf_msg_cond); } @@ -1519,7 +1519,7 @@ dev_fini(struct dev *dev, struct plt_pci_device *pci_dev) if (dev->sync.start_thread) { dev->sync.start_thread = false; pthread_cond_signal(&dev->sync.pfvf_msg_cond); - pthread_join(dev->sync.pfvf_msg_thread, NULL); + plt_thread_join(dev->sync.pfvf_msg_thread, NULL); pthread_mutex_destroy(&dev->sync.mutex); pthread_cond_destroy(&dev->sync.pfvf_msg_cond); } diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h index 1f84f74ff3..c1a37aa4f0 100644 --- a/drivers/common/cnxk/roc_dev_priv.h +++ b/drivers/common/cnxk/roc_dev_priv.h @@ -73,7 +73,7 @@ dev_is_afvf(uint16_t pf_func) struct mbox_sync { bool start_thread; uint8_t msg_avail; - pthread_t pfvf_msg_thread; + rte_thread_t pfvf_msg_thread; pthread_cond_t pfvf_msg_cond; pthread_mutex_t mutex; }; diff --git a/drivers/common/cnxk/roc_nix_inl_dev.c b/drivers/common/cnxk/roc_nix_inl_dev.c index d76158e30d..7400069309 100644 --- a/drivers/common/cnxk/roc_nix_inl_dev.c +++ b/drivers/common/cnxk/roc_nix_inl_dev.c @@ -746,7 +746,7 @@ inl_outb_soft_exp_poll(struct nix_inl_dev *inl_dev, uint32_t ring_idx) } } -static void * +static uint32_t nix_inl_outb_poll_thread(void *args) { struct nix_inl_dev *inl_dev = args; @@ -816,9 +816,8 @@ nix_inl_outb_poll_thread_setup(struct nix_inl_dev *inl_dev) soft_exp_consumer_cnt = 0; soft_exp_poll_thread_exit = false; - rc = plt_ctrl_thread_create(&inl_dev->soft_exp_poll_thread, - "OUTB_SOFT_EXP_POLL_THREAD", NULL, - nix_inl_outb_poll_thread, inl_dev); + rc = plt_thread_create_control(&inl_dev->soft_exp_poll_thread, + "outb-poll", nix_inl_outb_poll_thread, inl_dev); if (rc) { plt_bitmap_free(inl_dev->soft_exp_ring_bmap); plt_free(inl_dev->soft_exp_ring_bmap_mem); @@ -1020,7 +1019,7 @@ roc_nix_inl_dev_fini(struct roc_nix_inl_dev *roc_inl_dev) if (inl_dev->set_soft_exp_poll) { soft_exp_poll_thread_exit = true; - pthread_join(inl_dev->soft_exp_poll_thread, NULL); + rte_thread_join(inl_dev->soft_exp_poll_thread, NULL); plt_bitmap_free(inl_dev->soft_exp_ring_bmap); plt_free(inl_dev->soft_exp_ring_bmap_mem); plt_free(inl_dev->sa_soft_exp_ring); diff --git a/drivers/common/cnxk/roc_nix_inl_priv.h b/drivers/common/cnxk/roc_nix_inl_priv.h index b0a8976c6b..b2b89227b1 100644 --- a/drivers/common/cnxk/roc_nix_inl_priv.h +++ b/drivers/common/cnxk/roc_nix_inl_priv.h @@ -67,7 +67,7 @@ struct nix_inl_dev { struct roc_cpt_lf cpt_lf; /* OUTB soft expiry poll thread */ - pthread_t soft_exp_poll_thread; + rte_thread_t soft_exp_poll_thread; uint32_t soft_exp_poll_freq; uint64_t *sa_soft_exp_ring; bool set_soft_exp_poll; diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h index 08f83aba12..d8f2707a6e 100644 --- a/drivers/common/cnxk/roc_platform.h +++ b/drivers/common/cnxk/roc_platform.h @@ -134,7 +134,8 @@ #define plt_intr_disable rte_intr_disable #define plt_thread_is_intr rte_thread_is_intr #define plt_intr_callback_fn rte_intr_callback_fn -#define plt_ctrl_thread_create rte_ctrl_thread_create +#define plt_thread_create_control rte_thread_create_internal_control +#define plt_thread_join rte_thread_join #define plt_intr_efd_counter_size_get rte_intr_efd_counter_size_get #define plt_intr_efd_counter_size_set rte_intr_efd_counter_size_set diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index 4fc2319668..eabe88fada 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -100,7 +100,7 @@ static int skeldma_start(struct rte_dma_dev *dev) { struct skeldma_hw *hw = dev->data->dev_private; - char name[RTE_MAX_THREAD_NAME_LEN]; + char name[RTE_THREAD_INTERNAL_NAME_SIZE]; rte_cpuset_t cpuset; int ret; @@ -127,8 +127,9 @@ skeldma_start(struct rte_dma_dev *dev) rte_mb(); - snprintf(name, sizeof(name), "dpdk-dma-skel%d", dev->data->dev_id); - ret = rte_thread_create_control(&hw->thread, name, cpucopy_thread, dev); + snprintf(name, sizeof(name), "dma-skel%d", dev->data->dev_id); + ret = rte_thread_create_internal_control(&hw->thread, name, + cpucopy_thread, dev); if (ret) { SKELDMA_LOG(ERR, "Start cpucopy thread fail!"); return -EINVAL; diff --git a/drivers/event/dlb2/pf/base/dlb2_osdep.h b/drivers/event/dlb2/pf/base/dlb2_osdep.h index 75860cca4d..06d69f39b1 100644 --- a/drivers/event/dlb2/pf/base/dlb2_osdep.h +++ b/drivers/event/dlb2/pf/base/dlb2_osdep.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -154,7 +153,7 @@ static inline void os_fence_hcw(struct dlb2_hw *hw, u64 *pp_addr) * map and unmap requests. To prevent deadlock, this function gives other * threads a chance to grab the resource mutex and configure hardware. */ -static void *dlb2_complete_queue_map_unmap(void *__args) +static uint32_t dlb2_complete_queue_map_unmap(void *__args) { struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)__args; int ret; @@ -180,7 +179,7 @@ static void *dlb2_complete_queue_map_unmap(void *__args) rte_spinlock_unlock(&dlb2_dev->resource_mutex); - return NULL; + return 0; } @@ -194,16 +193,13 @@ static void *dlb2_complete_queue_map_unmap(void *__args) static inline void os_schedule_work(struct dlb2_hw *hw) { struct dlb2_dev *dlb2_dev; - pthread_t complete_queue_map_unmap_thread; + rte_thread_t complete_queue_map_unmap_thread; int ret; dlb2_dev = container_of(hw, struct dlb2_dev, hw); - ret = rte_ctrl_thread_create(&complete_queue_map_unmap_thread, - "dpdk-dlb-qunmap", - NULL, - dlb2_complete_queue_map_unmap, - dlb2_dev); + ret = rte_thread_create_internal_control(&complete_queue_map_unmap_thread, + "dlb-qunmap", dlb2_complete_queue_map_unmap, dlb2_dev); if (ret) DLB2_ERR(dlb2_dev, "Could not create queue complete map/unmap thread, err=%d\n", diff --git a/drivers/event/dlb2/pf/base/dlb2_resource.c b/drivers/event/dlb2/pf/base/dlb2_resource.c index dd8390a013..7ce3e3531c 100644 --- a/drivers/event/dlb2/pf/base/dlb2_resource.c +++ b/drivers/event/dlb2/pf/base/dlb2_resource.c @@ -759,18 +759,13 @@ static int dlb2_attach_ldb_queues(struct dlb2_hw *hw, } static int -dlb2_pp_profile(struct dlb2_hw *hw, int port, int cpu, bool is_ldb) +dlb2_pp_profile(struct dlb2_hw *hw, int port, bool is_ldb) { u64 cycle_start = 0ULL, cycle_end = 0ULL; struct dlb2_hcw hcw_mem[DLB2_HCW_MEM_SIZE], *hcw; void __iomem *pp_addr; - cpu_set_t cpuset; int i; - CPU_ZERO(&cpuset); - CPU_SET(cpu, &cpuset); - sched_setaffinity(0, sizeof(cpuset), &cpuset); - pp_addr = os_map_producer_port(hw, port, is_ldb); /* Point hcw to a 64B-aligned location */ @@ -797,18 +792,15 @@ dlb2_pp_profile(struct dlb2_hw *hw, int port, int cpu, bool is_ldb) return (int)(cycle_end - cycle_start); } -static void * +static uint32_t dlb2_pp_profile_func(void *data) { struct dlb2_pp_thread_data *thread_data = data; - int cycles; - cycles = dlb2_pp_profile(thread_data->hw, thread_data->pp, - thread_data->cpu, thread_data->is_ldb); + thread_data->cycles = dlb2_pp_profile(thread_data->hw, + thread_data->pp, thread_data->is_ldb); - thread_data->cycles = cycles; - - return NULL; + return 0; } static int dlb2_pp_cycle_comp(const void *a, const void *b) @@ -831,7 +823,9 @@ dlb2_get_pp_allocation(struct dlb2_hw *hw, int cpu, int port_type) int num_ports_per_sort, num_ports, num_sort, i, err; bool is_ldb = (port_type == DLB2_LDB_PORT); int *port_allocations; - pthread_t pthread; + rte_thread_t thread; + rte_thread_attr_t th_attr; + char th_name[RTE_THREAD_INTERNAL_NAME_SIZE]; if (is_ldb) { port_allocations = hw->ldb_pp_allocations; @@ -857,16 +851,25 @@ dlb2_get_pp_allocation(struct dlb2_hw *hw, int cpu, int port_type) dlb2_thread_data[i].pp = i; dlb2_thread_data[i].cycles = 0; dlb2_thread_data[i].hw = hw; - dlb2_thread_data[i].cpu = cpu; - err = pthread_create(&pthread, NULL, &dlb2_pp_profile_func, - &dlb2_thread_data[i]); + err = rte_thread_attr_init(&th_attr); + if (err != 0) { + DLB2_LOG_ERR(": thread attribute failed! err=%d", err); + return; + } + CPU_SET(cpu, &th_attr.cpuset); + + err = rte_thread_create(&thread, &th_attr, + &dlb2_pp_profile_func, &dlb2_thread_data[i]); if (err) { DLB2_LOG_ERR(": thread creation failed! err=%d", err); return; } - err = pthread_join(pthread, NULL); + snprintf(th_name, sizeof(th_name), "dlb2-pp%d", cpu); + rte_thread_set_prefixed_name(thread, th_name); + + err = rte_thread_join(thread, NULL); if (err) { DLB2_LOG_ERR(": thread join failed! err=%d", err); return; diff --git a/drivers/event/dlb2/pf/dlb2_main.h b/drivers/event/dlb2/pf/dlb2_main.h index 4c64d72e9c..12912a2dec 100644 --- a/drivers/event/dlb2/pf/dlb2_main.h +++ b/drivers/event/dlb2/pf/dlb2_main.h @@ -52,7 +52,6 @@ struct dlb2_dev { struct dlb2_pp_thread_data { struct dlb2_hw *hw; int pp; - int cpu; bool is_ldb; int cycles; }; diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 30814650bf..3ddcc9b461 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -598,17 +598,16 @@ eth_ark_dev_start(struct rte_eth_dev *dev) ark_pktchkr_run(ark->pc); if (!ark->isvf && ark->start_pg && !ark->pg_running) { - pthread_t thread; + rte_thread_t thread; /* Delay packet generator start allow the hardware to be ready * This is only used for sanity checking with internal generator */ - char tname[32]; - snprintf(tname, sizeof(tname), "dpdk-ark-pg%d", - dev->data->port_id); + char tname[RTE_THREAD_INTERNAL_NAME_SIZE]; + snprintf(tname, sizeof(tname), "ark-pg%d", dev->data->port_id); - if (rte_ctrl_thread_create(&thread, tname, NULL, - ark_pktgen_delay_start, ark->pg)) { + if (rte_thread_create_internal_control(&thread, tname, + ark_pktgen_delay_start, ark->pg)) { ARK_PMD_LOG(ERR, "Could not create pktgen " "starter thread\n"); return -1; diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c index cd2d3adc51..69ff7072b2 100644 --- a/drivers/net/ark/ark_pktgen.c +++ b/drivers/net/ark/ark_pktgen.c @@ -4,10 +4,10 @@ #include #include -#include #include #include +#include #include "ark_pktgen.h" #include "ark_logs.h" @@ -467,7 +467,7 @@ ark_pktgen_setup(ark_pkt_gen_t handle) } } -void * +uint32_t ark_pktgen_delay_start(void *arg) { struct ark_pkt_gen_inst *inst = (struct ark_pkt_gen_inst *)arg; @@ -476,8 +476,8 @@ ark_pktgen_delay_start(void *arg) * perform a blind sleep here to ensure that the external test * application has time to setup the test before we generate packets */ - pthread_detach(pthread_self()); + rte_thread_detach(rte_thread_self()); usleep(100000); ark_pktgen_run(inst); - return NULL; + return 0; } diff --git a/drivers/net/ark/ark_pktgen.h b/drivers/net/ark/ark_pktgen.h index 7147fe1bd4..925058367c 100644 --- a/drivers/net/ark/ark_pktgen.h +++ b/drivers/net/ark/ark_pktgen.h @@ -75,6 +75,6 @@ void ark_pktgen_set_hdr_dW(ark_pkt_gen_t handle, uint32_t *hdr); void ark_pktgen_set_start_offset(ark_pkt_gen_t handle, uint32_t x); void ark_pktgen_parse(char *argv); void ark_pktgen_setup(ark_pkt_gen_t handle); -void *ark_pktgen_delay_start(void *arg); +uint32_t ark_pktgen_delay_start(void *arg); #endif diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 6baa6d5955..b3e106b41f 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -135,7 +135,7 @@ iavf_dev_event_handler_init(void) TAILQ_INIT(&handler->pending); pthread_mutex_init(&handler->lock, NULL); - if (rte_thread_create_control(&handler->tid, "dpdk-iavf-event", + if (rte_thread_create_internal_control(&handler->tid, "iavf-event", iavf_dev_event_handle, NULL)) { __atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED); return -1; diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index d3bb65874f..173ed9f81d 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -165,9 +165,8 @@ ice_dcf_vsi_update_service_handler(void *param) static void start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id) { -#define THREAD_NAME_LEN 16 struct ice_dcf_reset_event_param *param; - char name[THREAD_NAME_LEN]; + char name[RTE_THREAD_INTERNAL_NAME_SIZE]; rte_thread_t thread; int ret; @@ -181,8 +180,8 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id) param->vfr = vfr; param->vf_id = vf_id; - snprintf(name, sizeof(name), "dpdk-ice-rst%u", vf_id); - ret = rte_thread_create_control(&thread, name, + snprintf(name, sizeof(name), "ice-rst%u", vf_id); + ret = rte_thread_create_internal_control(&thread, name, ice_dcf_vsi_update_service_handler, param); if (ret != 0) { PMD_DRV_LOG(ERR, "Failed to start the thread for reset handling"); diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c index c82f8b5333..57ec7a19bc 100644 --- a/drivers/net/ipn3ke/ipn3ke_representor.c +++ b/drivers/net/ipn3ke/ipn3ke_representor.c @@ -27,7 +27,7 @@ #include "ipn3ke_ethdev.h" static int ipn3ke_rpst_scan_num; -static pthread_t ipn3ke_rpst_scan_thread; +static rte_thread_t ipn3ke_rpst_scan_thread; /** Double linked list of representor port. */ TAILQ_HEAD(ipn3ke_rpst_list, ipn3ke_rpst); @@ -2558,7 +2558,7 @@ ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst) return 0; } -static void * +static uint32_t ipn3ke_rpst_scan_handle_request(__rte_unused void *param) { struct ipn3ke_rpst *rpst; @@ -2580,10 +2580,10 @@ ipn3ke_rpst_scan_handle_request(__rte_unused void *param) rte_delay_us(50 * MS); if (num == 0 || num == 0xffffff) - return NULL; + return 0; } - return NULL; + return 0; } static int @@ -2592,20 +2592,19 @@ ipn3ke_rpst_scan_check(void) int ret; if (ipn3ke_rpst_scan_num == 1) { - ret = rte_ctrl_thread_create(&ipn3ke_rpst_scan_thread, - "dpdk-ipn3ke-scn", - NULL, + ret = rte_thread_create_internal_control(&ipn3ke_rpst_scan_thread, + "ipn3ke-scn", ipn3ke_rpst_scan_handle_request, NULL); if (ret) { IPN3KE_AFU_PMD_ERR("Fail to create ipn3ke rpst scan thread"); return -1; } } else if (ipn3ke_rpst_scan_num == 0) { - ret = pthread_cancel(ipn3ke_rpst_scan_thread); + ret = pthread_cancel((pthread_t)ipn3ke_rpst_scan_thread.opaque_id); if (ret) IPN3KE_AFU_PMD_ERR("Can't cancel the thread"); - ret = pthread_join(ipn3ke_rpst_scan_thread, NULL); + ret = rte_thread_join(ipn3ke_rpst_scan_thread, NULL); if (ret) IPN3KE_AFU_PMD_ERR("Can't join the thread"); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 64e7e5d7d6..cd4a85b3a7 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4328,10 +4328,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, * when there is no link thread running. */ intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; - if (rte_thread_create_control(&ad->link_thread_tid, - "dpdk-ixgbe-link", - ixgbe_dev_setup_link_thread_handler, - dev) < 0) { + if (rte_thread_create_internal_control(&ad->link_thread_tid, + "ixgbe-link", + ixgbe_dev_setup_link_thread_handler, dev) < 0) { PMD_DRV_LOG(ERR, "Create link thread failed!"); /* NOTE: review for potential ordering optimization */ diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 3785103308..c587e13c63 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1368,7 +1368,7 @@ struct mlx5_hws_cnt_svc_mng { uint32_t refcnt; uint32_t service_core; uint32_t query_interval; - pthread_t service_thread; + rte_thread_t service_thread; uint8_t svc_running; struct mlx5_hws_aso_mng aso_mng __rte_cache_aligned; }; diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c index a0f0febbc7..f556a9fbcc 100644 --- a/drivers/net/mlx5/mlx5_hws_cnt.c +++ b/drivers/net/mlx5/mlx5_hws_cnt.c @@ -9,6 +9,7 @@ #include #include #include +#include #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H) @@ -286,7 +287,7 @@ mlx5_hws_cnt_raw_data_alloc(struct mlx5_dev_ctx_shared *sh, uint32_t n) return NULL; } -static void * +static uint32_t mlx5_hws_cnt_svc(void *opaque) { struct mlx5_dev_ctx_shared *sh = @@ -318,7 +319,7 @@ mlx5_hws_cnt_svc(void *opaque) if (interval > query_us) rte_delay_us_sleep(sleep_us); } - return NULL; + return 0; } static void @@ -438,36 +439,37 @@ mlx5_hws_cnt_pool_init(struct mlx5_dev_ctx_shared *sh, int mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh) { - char name[RTE_MAX_THREAD_NAME_LEN]; - rte_cpuset_t cpuset; + char name[RTE_THREAD_INTERNAL_NAME_SIZE]; + rte_thread_attr_t attr; int ret; uint32_t service_core = sh->cnt_svc->service_core; - CPU_ZERO(&cpuset); + ret = rte_thread_attr_init(&attr); + if (ret != 0) + goto error; + CPU_SET(service_core, &attr.cpuset); sh->cnt_svc->svc_running = 1; - ret = pthread_create(&sh->cnt_svc->service_thread, NULL, - mlx5_hws_cnt_svc, sh); - if (ret != 0) { - DRV_LOG(ERR, "Failed to create HW steering's counter service thread."); - return -ENOSYS; - } - snprintf(name, RTE_MAX_THREAD_NAME_LEN, "dpdk-mlx5-%d", service_core); - rte_thread_set_name((rte_thread_t){(uintptr_t)sh->cnt_svc->service_thread}, - name); - CPU_SET(service_core, &cpuset); - pthread_setaffinity_np(sh->cnt_svc->service_thread, sizeof(cpuset), - &cpuset); + ret = rte_thread_create(&sh->cnt_svc->service_thread, + &attr, mlx5_hws_cnt_svc, sh); + if (ret != 0) + goto error; + snprintf(name, sizeof(name), "mlx5-cn%d", service_core); + rte_thread_set_prefixed_name(sh->cnt_svc->service_thread, name); + return 0; +error: + DRV_LOG(ERR, "Failed to create HW steering's counter service thread."); + return ret; } void mlx5_hws_cnt_service_thread_destroy(struct mlx5_dev_ctx_shared *sh) { - if (sh->cnt_svc->service_thread == 0) + if (sh->cnt_svc->service_thread.opaque_id == 0) return; sh->cnt_svc->svc_running = 0; - pthread_join(sh->cnt_svc->service_thread, NULL); - sh->cnt_svc->service_thread = 0; + rte_thread_join(sh->cnt_svc->service_thread, NULL); + sh->cnt_svc->service_thread.opaque_id = 0; } static int diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h index 646d055ac1..7988424449 100644 --- a/drivers/net/sfc/sfc_mae.h +++ b/drivers/net/sfc/sfc_mae.h @@ -196,7 +196,7 @@ struct sfc_mae_counter_registry { } service; struct { /** Counter thread ID */ - pthread_t id; + rte_thread_t id; /** The thread should keep running */ bool run; } thread; diff --git a/drivers/net/sfc/sfc_mae_counter.c b/drivers/net/sfc/sfc_mae_counter.c index 631b54afeb..ba17295719 100644 --- a/drivers/net/sfc/sfc_mae_counter.c +++ b/drivers/net/sfc/sfc_mae_counter.c @@ -490,7 +490,7 @@ sfc_mae_counter_service_routine(void *arg) return 0; } -static void * +static uint32_t sfc_mae_counter_thread(void *data) { struct sfc_adapter *sa = data; @@ -521,7 +521,7 @@ sfc_mae_counter_thread(void *data) } } - return NULL; + return 0; } static void @@ -687,7 +687,7 @@ sfc_mae_counter_thread_stop(struct sfc_adapter *sa) __atomic_store_n(&counter_registry->polling.thread.run, false, __ATOMIC_RELEASE); - rc = pthread_join(counter_registry->polling.thread.id, NULL); + rc = rte_thread_join(counter_registry->polling.thread.id, NULL); if (rc != 0) sfc_err(sa, "failed to join the MAE counter polling thread"); @@ -710,9 +710,8 @@ sfc_mae_counter_thread_spawn(struct sfc_adapter *sa, counter_registry->polling_mode = SFC_MAE_COUNTER_POLLING_THREAD; counter_registry->polling.thread.run = true; - rc = rte_ctrl_thread_create(&sa->mae.counter_registry.polling.thread.id, - "dpdk-sfc-maecnt", NULL, - sfc_mae_counter_thread, sa); + rc = rte_thread_create_internal_control(&sa->mae.counter_registry.polling.thread.id, + "sfc-maecnt", sfc_mae_counter_thread, sa); return rc; } diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 198fac8318..15911a3621 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -2896,9 +2896,9 @@ txgbe_dev_link_update_share(struct rte_eth_dev *dev, * when there is no link thread running. */ intr->flags |= TXGBE_FLAG_NEED_LINK_CONFIG; - if (rte_thread_create_control(&ad->link_thread_tid, - "dpdk-txgbe-link", - txgbe_dev_setup_link_thread_handler, dev) < 0) { + if (rte_thread_create_internal_control(&ad->link_thread_tid, + "txgbe-link", + txgbe_dev_setup_link_thread_handler, dev) < 0) { PMD_DRV_LOG(ERR, "Create link thread failed!"); __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); } diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index a7b18299de..f89bd3f9e2 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -74,7 +74,7 @@ static const struct rte_pci_id pci_ifpga_map[] = { static struct ifpga_rawdev ifpga_rawdevices[IFPGA_RAWDEV_NUM]; static int ifpga_monitor_refcnt; -static pthread_t ifpga_monitor_start_thread; +static rte_thread_t ifpga_monitor_start_thread; static struct ifpga_rawdev * ifpga_rawdev_allocate(struct rte_rawdev *rawdev); @@ -504,7 +504,7 @@ static int set_surprise_link_check_aer( return -EFAULT; } -static void * +static uint32_t ifpga_rawdev_gsd_handle(__rte_unused void *param) { struct ifpga_rawdev *ifpga_rdev; @@ -532,7 +532,7 @@ ifpga_rawdev_gsd_handle(__rte_unused void *param) rte_delay_us(100 * MS); } - return NULL; + return 0; } static int @@ -550,11 +550,10 @@ ifpga_monitor_start_func(struct ifpga_rawdev *dev) dev->poll_enabled = 1; if (!__atomic_fetch_add(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED)) { - ret = rte_ctrl_thread_create(&ifpga_monitor_start_thread, - "dpdk-ifpga-mon", NULL, - ifpga_rawdev_gsd_handle, NULL); + ret = rte_thread_create_internal_control(&ifpga_monitor_start_thread, + "ifpga-mon", ifpga_rawdev_gsd_handle, NULL); if (ret != 0) { - ifpga_monitor_start_thread = 0; + ifpga_monitor_start_thread.opaque_id = 0; IFPGA_RAWDEV_PMD_ERR( "Fail to create ifpga monitor thread"); return -1; @@ -575,12 +574,12 @@ ifpga_monitor_stop_func(struct ifpga_rawdev *dev) dev->poll_enabled = 0; if (!(__atomic_fetch_sub(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) - 1) && - ifpga_monitor_start_thread) { - ret = pthread_cancel(ifpga_monitor_start_thread); + ifpga_monitor_start_thread.opaque_id != 0) { + ret = pthread_cancel((pthread_t)ifpga_monitor_start_thread.opaque_id); if (ret) IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread"); - ret = pthread_join(ifpga_monitor_start_thread, NULL); + ret = rte_thread_join(ifpga_monitor_start_thread, NULL); if (ret) IFPGA_RAWDEV_PMD_ERR("Can't join the thread"); diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index 55346bbc08..f034bd59ba 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -58,8 +58,8 @@ struct ifcvf_internal { int vfio_container_fd; int vfio_group_fd; int vfio_dev_fd; - pthread_t tid; /* thread for notify relay */ - pthread_t intr_tid; /* thread for config space change interrupt relay */ + rte_thread_t tid; /* thread for notify relay */ + rte_thread_t intr_tid; /* thread for config space change interrupt relay */ int epfd; int csc_epfd; int vid; @@ -496,7 +496,7 @@ vdpa_disable_vfio_intr(struct ifcvf_internal *internal) return 0; } -static void * +static uint32_t notify_relay(void *arg) { int i, kickfd, epfd, nfds = 0; @@ -514,7 +514,7 @@ notify_relay(void *arg) epfd = epoll_create(IFCVF_MAX_QUEUES * 2); if (epfd < 0) { DRV_LOG(ERR, "failed to create epoll instance."); - return NULL; + return 1; } internal->epfd = epfd; @@ -527,7 +527,7 @@ notify_relay(void *arg) ev.data.u64 = qid | (uint64_t)vring.kickfd << 32; if (epoll_ctl(epfd, EPOLL_CTL_ADD, vring.kickfd, &ev) < 0) { DRV_LOG(ERR, "epoll add error: %s", strerror(errno)); - return NULL; + return 1; } } @@ -537,7 +537,7 @@ notify_relay(void *arg) if (errno == EINTR) continue; DRV_LOG(ERR, "epoll_wait return fail\n"); - return NULL; + return 1; } for (i = 0; i < nfds; i++) { @@ -561,18 +561,18 @@ notify_relay(void *arg) } } - return NULL; + return 0; } static int setup_notify_relay(struct ifcvf_internal *internal) { - char name[THREAD_NAME_LEN]; + char name[RTE_THREAD_INTERNAL_NAME_SIZE]; int ret; - snprintf(name, sizeof(name), "dpdk-ifc-noti%d", internal->vid); - ret = rte_ctrl_thread_create(&internal->tid, name, NULL, notify_relay, - (void *)internal); + snprintf(name, sizeof(name), "ifc-noti%d", internal->vid); + ret = rte_thread_create_internal_control(&internal->tid, name, + notify_relay, internal); if (ret != 0) { DRV_LOG(ERR, "failed to create notify relay pthread."); return -1; @@ -584,13 +584,11 @@ setup_notify_relay(struct ifcvf_internal *internal) static int unset_notify_relay(struct ifcvf_internal *internal) { - void *status; - - if (internal->tid) { - pthread_cancel(internal->tid); - pthread_join(internal->tid, &status); + if (internal->tid.opaque_id != 0) { + pthread_cancel((pthread_t)internal->tid.opaque_id); + rte_thread_join(internal->tid, NULL); } - internal->tid = 0; + internal->tid.opaque_id = 0; if (internal->epfd >= 0) close(internal->epfd); @@ -610,7 +608,7 @@ virtio_interrupt_handler(struct ifcvf_internal *internal) DRV_LOG(ERR, "failed to notify the guest about configuration space change."); } -static void * +static uint32_t intr_relay(void *arg) { struct ifcvf_internal *internal = (struct ifcvf_internal *)arg; @@ -623,7 +621,7 @@ intr_relay(void *arg) csc_epfd = epoll_create(1); if (csc_epfd < 0) { DRV_LOG(ERR, "failed to create epoll for config space change."); - return NULL; + return 1; } ev.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP | EPOLLHUP; @@ -672,18 +670,18 @@ intr_relay(void *arg) close(csc_epfd); internal->csc_epfd = -1; - return NULL; + return 0; } static int setup_intr_relay(struct ifcvf_internal *internal) { - char name[THREAD_NAME_LEN]; + char name[RTE_THREAD_INTERNAL_NAME_SIZE]; int ret; - snprintf(name, sizeof(name), "dpdk-ifc-int%d", internal->vid); - ret = rte_ctrl_thread_create(&internal->intr_tid, name, NULL, - intr_relay, (void *)internal); + snprintf(name, sizeof(name), "ifc-int%d", internal->vid); + ret = rte_thread_create_internal_control(&internal->intr_tid, name, + intr_relay, (void *)internal); if (ret) { DRV_LOG(ERR, "failed to create notify relay pthread."); return -1; @@ -694,13 +692,11 @@ setup_intr_relay(struct ifcvf_internal *internal) static void unset_intr_relay(struct ifcvf_internal *internal) { - void *status; - - if (internal->intr_tid) { - pthread_cancel(internal->intr_tid); - pthread_join(internal->intr_tid, &status); + if (internal->intr_tid.opaque_id != 0) { + pthread_cancel((pthread_t)internal->intr_tid.opaque_id); + rte_thread_join(internal->intr_tid, NULL); } - internal->intr_tid = 0; + internal->intr_tid.opaque_id = 0; if (internal->csc_epfd >= 0) close(internal->csc_epfd); @@ -922,7 +918,7 @@ update_used_ring(struct ifcvf_internal *internal, uint16_t qid) rte_vhost_vring_call(internal->vid, qid); } -static void * +static uint32_t vring_relay(void *arg) { int i, vid, epfd, fd, nfds; @@ -941,7 +937,7 @@ vring_relay(void *arg) epfd = epoll_create(IFCVF_MAX_QUEUES * 2); if (epfd < 0) { DRV_LOG(ERR, "failed to create epoll instance."); - return NULL; + return 1; } internal->epfd = epfd; @@ -952,7 +948,7 @@ vring_relay(void *arg) ev.data.u64 = qid << 1 | (uint64_t)vring.kickfd << 32; if (epoll_ctl(epfd, EPOLL_CTL_ADD, vring.kickfd, &ev) < 0) { DRV_LOG(ERR, "epoll add error: %s", strerror(errno)); - return NULL; + return 1; } } @@ -966,7 +962,7 @@ vring_relay(void *arg) if (epoll_ctl(epfd, EPOLL_CTL_ADD, internal->intr_fd[qid], &ev) < 0) { DRV_LOG(ERR, "epoll add error: %s", strerror(errno)); - return NULL; + return 1; } update_used_ring(internal, qid); } @@ -982,7 +978,7 @@ vring_relay(void *arg) if (errno == EINTR) continue; DRV_LOG(ERR, "epoll_wait return fail."); - return NULL; + return 1; } for (i = 0; i < nfds; i++) { @@ -1010,18 +1006,18 @@ vring_relay(void *arg) } } - return NULL; + return 0; } static int setup_vring_relay(struct ifcvf_internal *internal) { - char name[THREAD_NAME_LEN]; + char name[RTE_THREAD_INTERNAL_NAME_SIZE]; int ret; - snprintf(name, sizeof(name), "dpdk-ifc-ring%d", internal->vid); - ret = rte_ctrl_thread_create(&internal->tid, name, NULL, vring_relay, - (void *)internal); + snprintf(name, sizeof(name), "ifc-ring%d", internal->vid); + ret = rte_thread_create_internal_control(&internal->tid, name, + vring_relay, internal); if (ret != 0) { DRV_LOG(ERR, "failed to create ring relay pthread."); return -1; @@ -1033,13 +1029,11 @@ setup_vring_relay(struct ifcvf_internal *internal) static int unset_vring_relay(struct ifcvf_internal *internal) { - void *status; - - if (internal->tid) { - pthread_cancel(internal->tid); - pthread_join(internal->tid, &status); + if (internal->tid.opaque_id != 0) { + pthread_cancel((pthread_t)internal->tid.opaque_id); + rte_thread_join(internal->tid, NULL); } - internal->tid = 0; + internal->tid.opaque_id = 0; if (internal->epfd >= 0) close(internal->epfd); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index f1737f82a8..01a5877d08 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -844,7 +844,7 @@ mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev, mlx5_vdpa_config_get(mkvlist, priv); if (priv->use_c_thread) { if (conf_thread_mng.initializer_priv == priv) - if (mlx5_vdpa_mult_threads_create(priv->event_core)) + if (mlx5_vdpa_mult_threads_create()) goto error; __atomic_fetch_add(&conf_thread_mng.refcnt, 1, __ATOMIC_RELAXED); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h index dc4dfba5ed..7b37c98e74 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/mlx5_vdpa.h @@ -19,6 +19,7 @@ #endif #include #include +#include #include #include @@ -99,7 +100,7 @@ struct mlx5_vdpa_task { /* Generic mlx5_vdpa_c_thread information. */ struct mlx5_vdpa_c_thread { - pthread_t tid; + rte_thread_t tid; struct rte_ring *rng; pthread_cond_t c_cond; }; @@ -182,7 +183,7 @@ struct mlx5_vdpa_priv { rte_spinlock_t db_lock; pthread_mutex_t steer_update_lock; uint64_t no_traffic_counter; - pthread_t timer_tid; + rte_thread_t timer_tid; int event_mode; int event_core; /* Event thread cpu affinity core. */ uint32_t event_us; @@ -563,14 +564,11 @@ mlx5_vdpa_is_modify_virtq_supported(struct mlx5_vdpa_priv *priv); /** * Create configuration multi-threads resource * - * @param[in] cpu_core - * CPU core number to set configuration threads affinity to. - * * @return * 0 on success, a negative value otherwise. */ int -mlx5_vdpa_mult_threads_create(int cpu_core); +mlx5_vdpa_mult_threads_create(void); /** * Destroy configuration multi-threads resource diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_cthread.c b/drivers/vdpa/mlx5/mlx5_vdpa_cthread.c index a1d291bf71..1a5fd3eb17 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_cthread.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_cthread.c @@ -96,11 +96,10 @@ mlx5_vdpa_c_thread_wait_bulk_tasks_done(uint32_t *remaining_cnt, return false; } -static void * +static uint32_t mlx5_vdpa_c_thread_handle(void *arg) { struct mlx5_vdpa_conf_thread_mng *multhrd = arg; - pthread_t thread_id = pthread_self(); struct mlx5_vdpa_virtq *virtq; struct mlx5_vdpa_priv *priv; struct mlx5_vdpa_task task; @@ -112,10 +111,10 @@ mlx5_vdpa_c_thread_handle(void *arg) for (thrd_idx = 0; thrd_idx < multhrd->max_thrds; thrd_idx++) - if (multhrd->cthrd[thrd_idx].tid == thread_id) + if (rte_thread_equal(multhrd->cthrd[thrd_idx].tid, rte_thread_self())) break; if (thrd_idx >= multhrd->max_thrds) - return NULL; + return 1; rng = multhrd->cthrd[thrd_idx].rng; while (1) { task_num = mlx5_vdpa_c_thrd_ring_dequeue_bulk(rng, @@ -227,16 +226,17 @@ mlx5_vdpa_c_thread_handle(void *arg) __atomic_fetch_sub(task.remaining_cnt, 1, __ATOMIC_RELAXED); } - return NULL; + return 0; } static void mlx5_vdpa_c_thread_destroy(uint32_t thrd_idx, bool need_unlock) { - if (conf_thread_mng.cthrd[thrd_idx].tid) { - pthread_cancel(conf_thread_mng.cthrd[thrd_idx].tid); - pthread_join(conf_thread_mng.cthrd[thrd_idx].tid, NULL); - conf_thread_mng.cthrd[thrd_idx].tid = 0; + pthread_t *tid = (pthread_t *)&conf_thread_mng.cthrd[thrd_idx].tid.opaque_id; + if (*tid != 0) { + pthread_cancel(*tid); + rte_thread_join(conf_thread_mng.cthrd[thrd_idx].tid, NULL); + *tid = 0; if (need_unlock) pthread_mutex_init(&conf_thread_mng.cthrd_lock, NULL); } @@ -247,30 +247,14 @@ mlx5_vdpa_c_thread_destroy(uint32_t thrd_idx, bool need_unlock) } static int -mlx5_vdpa_c_thread_create(int cpu_core) +mlx5_vdpa_c_thread_create(void) { - const struct sched_param sp = { - .sched_priority = sched_get_priority_max(SCHED_RR), - }; - rte_cpuset_t cpuset; - pthread_attr_t attr; uint32_t thrd_idx; uint32_t ring_num; - char name[32]; + char name[RTE_RING_NAMESIZE]; int ret; pthread_mutex_lock(&conf_thread_mng.cthrd_lock); - pthread_attr_init(&attr); - ret = pthread_attr_setschedpolicy(&attr, SCHED_RR); - if (ret) { - DRV_LOG(ERR, "Failed to set thread sched policy = RR."); - goto c_thread_err; - } - ret = pthread_attr_setschedparam(&attr, &sp); - if (ret) { - DRV_LOG(ERR, "Failed to set thread priority."); - goto c_thread_err; - } ring_num = MLX5_VDPA_MAX_TASKS_PER_THRD / conf_thread_mng.max_thrds; if (!ring_num) { DRV_LOG(ERR, "Invalid ring number for thread."); @@ -291,35 +275,15 @@ mlx5_vdpa_c_thread_create(int cpu_core) thrd_idx); goto c_thread_err; } - ret = pthread_create(&conf_thread_mng.cthrd[thrd_idx].tid, - &attr, mlx5_vdpa_c_thread_handle, - (void *)&conf_thread_mng); + snprintf(name, RTE_THREAD_INTERNAL_NAME_SIZE, "vmlx5-c%d", thrd_idx); + ret = rte_thread_create_internal_control(&conf_thread_mng.cthrd[thrd_idx].tid, + name, + mlx5_vdpa_c_thread_handle, &conf_thread_mng); if (ret) { DRV_LOG(ERR, "Failed to create vdpa multi-threads %d.", thrd_idx); goto c_thread_err; } - CPU_ZERO(&cpuset); - if (cpu_core != -1) - CPU_SET(cpu_core, &cpuset); - else - cpuset = rte_lcore_cpuset(rte_get_main_lcore()); - ret = pthread_setaffinity_np( - conf_thread_mng.cthrd[thrd_idx].tid, - sizeof(cpuset), &cpuset); - if (ret) { - DRV_LOG(ERR, "Failed to set thread affinity for " - "vdpa multi-threads %d.", thrd_idx); - goto c_thread_err; - } - snprintf(name, sizeof(name), "dpdk-vmlx5-c%d", thrd_idx); - ret = pthread_setname_np( - conf_thread_mng.cthrd[thrd_idx].tid, name); - if (ret) - DRV_LOG(ERR, "Failed to set vdpa multi-threads name %s.", - name); - else - DRV_LOG(DEBUG, "Thread name: %s.", name); pthread_cond_init(&conf_thread_mng.cthrd[thrd_idx].c_cond, NULL); } @@ -334,10 +298,10 @@ mlx5_vdpa_c_thread_create(int cpu_core) } int -mlx5_vdpa_mult_threads_create(int cpu_core) +mlx5_vdpa_mult_threads_create(void) { pthread_mutex_init(&conf_thread_mng.cthrd_lock, NULL); - if (mlx5_vdpa_c_thread_create(cpu_core)) { + if (mlx5_vdpa_c_thread_create()) { DRV_LOG(ERR, "Cannot create vDPA configuration threads."); mlx5_vdpa_mult_threads_destroy(false); return -1; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c index c486ded598..fa26471b18 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c @@ -284,7 +284,7 @@ mlx5_vdpa_event_wait(struct mlx5_vdpa_priv *priv __rte_unused) return NULL; } -static void * +static uint32_t mlx5_vdpa_event_handle(void *arg) { struct mlx5_vdpa_priv *priv = arg; @@ -324,7 +324,7 @@ mlx5_vdpa_event_handle(void *arg) } mlx5_vdpa_timer_sleep(priv, max); } - return NULL; + return 0; case MLX5_VDPA_EVENT_MODE_ONLY_INTERRUPT: do { virtq = mlx5_vdpa_event_wait(priv); @@ -336,9 +336,9 @@ mlx5_vdpa_event_handle(void *arg) pthread_mutex_unlock(&virtq->virtq_lock); } } while (1); - return NULL; + return 0; default: - return NULL; + return 0; } } @@ -503,54 +503,31 @@ int mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv) { int ret; - rte_cpuset_t cpuset; - pthread_attr_t *attrp = NULL; - pthread_attr_t attr; - char name[16]; - const struct sched_param sp = { - .sched_priority = sched_get_priority_max(SCHED_RR) - 1, - }; + rte_thread_attr_t attr; + char name[RTE_THREAD_INTERNAL_NAME_SIZE]; if (!priv->eventc) /* All virtqs are in poll mode. */ return 0; - ret = pthread_attr_init(&attr); + ret = rte_thread_attr_init(&attr); if (ret != 0) { DRV_LOG(ERR, "Failed to initialize thread attributes"); goto out; } - attrp = &attr; - ret = pthread_attr_setschedpolicy(attrp, SCHED_RR); - if (ret) { - DRV_LOG(ERR, "Failed to set thread sched policy = RR."); - goto out; - } - ret = pthread_attr_setschedparam(attrp, &sp); - if (ret) { - DRV_LOG(ERR, "Failed to set thread priority."); - goto out; - } - ret = pthread_create(&priv->timer_tid, attrp, mlx5_vdpa_event_handle, - (void *)priv); - if (ret) { - DRV_LOG(ERR, "Failed to create timer thread."); - goto out; - } - CPU_ZERO(&cpuset); + attr.priority = RTE_THREAD_PRIORITY_REALTIME_CRITICAL; if (priv->event_core != -1) - CPU_SET(priv->event_core, &cpuset); + CPU_SET(priv->event_core, &attr.cpuset); else - cpuset = rte_lcore_cpuset(rte_get_main_lcore()); - ret = pthread_setaffinity_np(priv->timer_tid, sizeof(cpuset), &cpuset); - if (ret) { - DRV_LOG(ERR, "Failed to set thread affinity."); + attr.cpuset = rte_lcore_cpuset(rte_get_main_lcore()); + ret = rte_thread_create(&priv->timer_tid, + &attr, mlx5_vdpa_event_handle, priv); + if (ret != 0) { + DRV_LOG(ERR, "Failed to create timer thread."); goto out; } - snprintf(name, sizeof(name), "dpdk-vmlx5-%d", priv->vid); - rte_thread_set_name((rte_thread_t){(uintptr_t)priv->timer_tid}, name); + snprintf(name, sizeof(name), "vmlx5-%d", priv->vid); + rte_thread_set_prefixed_name(priv->timer_tid, name); out: - if (attrp != NULL) - pthread_attr_destroy(attrp); if (ret != 0) return -1; return 0; @@ -560,19 +537,18 @@ void mlx5_vdpa_cqe_event_unset(struct mlx5_vdpa_priv *priv) { struct mlx5_vdpa_virtq *virtq; - void *status; int i; - if (priv->timer_tid) { - pthread_cancel(priv->timer_tid); - pthread_join(priv->timer_tid, &status); + if (priv->timer_tid.opaque_id != 0) { + pthread_cancel((pthread_t)priv->timer_tid.opaque_id); + rte_thread_join(priv->timer_tid, NULL); /* The mutex may stay locked after event thread cancel, initiate it. */ for (i = 0; i < priv->nr_virtqs; i++) { virtq = &priv->virtqs[i]; pthread_mutex_init(&virtq->virtq_lock, NULL); } } - priv->timer_tid = 0; + priv->timer_tid.opaque_id = 0; } void diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c b/drivers/vdpa/sfc/sfc_vdpa_ops.c index f63af7d478..00f9a4b04c 100644 --- a/drivers/vdpa/sfc/sfc_vdpa_ops.c +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.c @@ -567,7 +567,7 @@ sfc_vdpa_get_protocol_features(struct rte_vdpa_device *vdpa_dev, return 0; } -static void * +static uint32_t sfc_vdpa_notify_ctrl(void *arg) { struct sfc_vdpa_ops_data *ops_data; @@ -575,7 +575,7 @@ sfc_vdpa_notify_ctrl(void *arg) ops_data = arg; if (ops_data == NULL) - return NULL; + return 0; sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); @@ -588,7 +588,7 @@ sfc_vdpa_notify_ctrl(void *arg) sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); - return NULL; + return 0; } static int @@ -603,8 +603,8 @@ sfc_vdpa_setup_notify_ctrl(struct sfc_vdpa_ops_data *ops_data) * dead lock scenario when multiple VFs are used in single vdpa * application and multiple VFs are passed to a single VM. */ - ret = pthread_create(&ops_data->notify_tid, NULL, - sfc_vdpa_notify_ctrl, ops_data); + ret = rte_thread_create_internal_control(&ops_data->notify_tid, + "sfc-vdpa", sfc_vdpa_notify_ctrl, ops_data); if (ret != 0) { sfc_vdpa_err(ops_data->dev_handle, "failed to create notify_ctrl thread: %s", @@ -690,15 +690,14 @@ sfc_vdpa_dev_close(int vid) sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); if (ops_data->is_notify_thread_started == true) { - void *status; - ret = pthread_cancel(ops_data->notify_tid); + ret = pthread_cancel((pthread_t)ops_data->notify_tid.opaque_id); if (ret != 0) { sfc_vdpa_err(ops_data->dev_handle, "failed to cancel notify_ctrl thread: %s", rte_strerror(ret)); } - ret = pthread_join(ops_data->notify_tid, &status); + ret = rte_thread_join(ops_data->notify_tid, NULL); if (ret != 0) { sfc_vdpa_err(ops_data->dev_handle, "failed to join terminated notify_ctrl thread: %s", diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.h b/drivers/vdpa/sfc/sfc_vdpa_ops.h index 5c8e352de3..10ea239434 100644 --- a/drivers/vdpa/sfc/sfc_vdpa_ops.h +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.h @@ -6,6 +6,7 @@ #define _SFC_VDPA_OPS_H #include +#include #define SFC_VDPA_MAX_QUEUE_PAIRS 8 @@ -48,7 +49,7 @@ struct sfc_vdpa_ops_data { struct rte_vdpa_device *vdpa_dev; enum sfc_vdpa_context vdpa_context; enum sfc_vdpa_state state; - pthread_t notify_tid; + rte_thread_t notify_tid; bool is_notify_thread_started; uint64_t dev_features; From patchwork Wed Sep 13 10:34:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131383 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C0C1A42588; Wed, 13 Sep 2023 12:38:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1813406B7; Wed, 13 Sep 2023 12:37:56 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 9B6F5406BC for ; Wed, 13 Sep 2023 12:37:54 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 339D2320085B; Wed, 13 Sep 2023 06:37:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 13 Sep 2023 06:37:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601472; x=1694687872; bh=yAqhi5WcODEXLT25jJCPVZkr3LmIozel/Ly duQuyWpA=; b=B6PP5Xh91Yt58WKznL3yyrAooQNUfLk1Lo5du+sHnvW8vkne9A6 aJ3LM9xmyuYhDVJbgZSxLgc7y+SFEazAo1rAEv6UeTIJBKWpPOjRMS2xVpeBlT8Y F/slUKCAgfwBlF/vDLv8ual4hb/Y4iZxx1Z7sBXdqiut/X8yXJdqwyBn6LDjGIzj lDNpXPlXzdyAB8PqTAnICSzNUfnnisCod7t31m1jT64GCxV5I6nVJQ2ZWmzcXqCa KPC6HYtpl2C0UlDVckPxsDZ7yPJDqtrOxKbcvc2EnMPmpzwAriEXtD/l2Mx3XMKL uYAuIn9UvZNB7EaEFpJHGmft6QZagKvCInw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601472; x=1694687872; bh=yAqhi5WcODEXLT25jJCPVZkr3LmIozel/Ly duQuyWpA=; b=TNx0NS+Ib9ZX57cXZWHvh/3vno8sKQippnYlUOyJFhxMxK11xjQ 8lfS3seeNY/OaJzHzd39J4lqySiRpts8KhM4Eznx0tHtZat9tpWCkTZ4Q8AkeION AePlYWdOMhafNd76Y2ICvp2wyUsKWJKXNp3HiHgpTop1iujJtjgQK1A3T3ONI7Q3 LGLBlbXRRdwPix8/C+5xWV+0Tyw7Gr7zMVzR/iFzwiN6a1fbaH/jMhEXVRq6Osax 5/g9a3ptkVuVaX8/kCopJJP3Z06cfLLxPZYTWAC6rpf8dDrWM2nboVzfUKl+mlzX 9pDCvH2anRhKQS3i0EjkLvOsTnstPztx8ig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:37:51 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 08/11] examples: convert to normal control threads Date: Wed, 13 Sep 2023 12:34:27 +0200 Message-ID: <20230913103600.1935292-9-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Calls to rte_ctrl_thread_create() are replaced with rte_thread_create_control(). In vhost_blk, the control thread is not forced to be scheduled on core 0 anymore. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- examples/vhost/main.c | 9 +++++---- examples/vhost_blk/vhost_blk.c | 21 ++++++--------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 9ff2c1f31b..ce5c1efddf 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "main.h" @@ -1807,7 +1808,7 @@ static const struct rte_vhost_device_ops virtio_net_device_ops = * This is a thread will wake up after a period to print stats if the user has * enabled them. */ -static void * +static uint32_t print_stats(__rte_unused void *arg) { struct vhost_dev *vdev; @@ -1852,7 +1853,7 @@ print_stats(__rte_unused void *arg) fflush(stdout); } - return NULL; + return 0; } static void @@ -1907,7 +1908,7 @@ main(int argc, char *argv[]) unsigned nb_ports, valid_num_ports; int ret, i; uint16_t portid; - static pthread_t tid; + rte_thread_t tid; uint64_t flags = RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS; signal(SIGINT, sigint_handler); @@ -1986,7 +1987,7 @@ main(int argc, char *argv[]) /* Enable stats if the user option is set. */ if (enable_stats) { - ret = rte_ctrl_thread_create(&tid, "dpdk-vhost-stat", NULL, + ret = rte_thread_create_control(&tid, "dpdk-vhost-stat", print_stats, NULL); if (ret < 0) rte_exit(EXIT_FAILURE, diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c index 45699eb0b3..376f7b89a7 100644 --- a/examples/vhost_blk/vhost_blk.c +++ b/examples/vhost_blk/vhost_blk.c @@ -5,8 +5,6 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include -#include #include #include @@ -529,12 +527,10 @@ process_vq(struct vhost_blk_queue *vq) } } -static void * +static uint32_t ctrlr_worker(void *arg) { struct vhost_blk_ctrlr *ctrlr = (struct vhost_blk_ctrlr *)arg; - cpu_set_t cpuset; - pthread_t thread; int i; fprintf(stdout, "Ctrlr Worker Thread start\n"); @@ -546,11 +542,6 @@ ctrlr_worker(void *arg) exit(0); } - thread = pthread_self(); - CPU_ZERO(&cpuset); - CPU_SET(0, &cpuset); - pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); - for (i = 0; i < NUM_OF_BLK_QUEUES; i++) submit_inflight_vq(&ctrlr->queues[i]); @@ -560,7 +551,7 @@ ctrlr_worker(void *arg) fprintf(stdout, "Ctrlr Worker Thread Exiting\n"); sem_post(&exit_sem); - return NULL; + return 0; } static int @@ -605,7 +596,7 @@ new_device(int vid) struct vhost_blk_queue *vq; char path[PATH_MAX]; uint64_t features, protocol_features; - pthread_t tid; + rte_thread_t tid; int i, ret; bool packed_ring, inflight_shmfd; @@ -686,15 +677,15 @@ new_device(int vid) /* start polling vring */ worker_thread_status = WORKER_STATE_START; fprintf(stdout, "New Device %s, Device ID %d\n", path, vid); - if (rte_ctrl_thread_create(&tid, "dpdk-vhost-blk", NULL, - &ctrlr_worker, ctrlr) != 0) { + if (rte_thread_create_control(&tid, "dpdk-vhost-blk", + &ctrlr_worker, ctrlr) != 0) { fprintf(stderr, "Worker Thread Started Failed\n"); return -1; } /* device has been started */ ctrlr->started = 1; - pthread_detach(tid); + rte_thread_detach(tid); return 0; } From patchwork Wed Sep 13 10:34:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131384 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF98742588; Wed, 13 Sep 2023 12:38:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D540940A73; Wed, 13 Sep 2023 12:38:02 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 66B794064A for ; Wed, 13 Sep 2023 12:38:00 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id F357F3200413; Wed, 13 Sep 2023 06:37:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 13 Sep 2023 06:37:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601478; x=1694687878; bh=yuYb/FScGlE53o8sIBUUC4AbBWAHIA9MsQv NXxUbr+k=; b=SsHTuO/ctEtEqbs58CbNHRl8pR4D5YbMhiVtAmSq/+cQDlMvs6c wHXAOrcwCRJseSkpp6t0DVoMhlQgEw/NajWAy9kGL9F9uHKsGIPN4FJlSltOHJzY mcVPLMs3MEDR5pX1+aMPDF1I3lG1Oid25UNLeOh1YgQEJkTq+UWVTRjEAj7YjXxT WhsksrX7bQSLIfSOYP1WyNoUeLHp+3rYRLkhu7Jrzu2IBo1kipoDEgwXOfgP3h3L xMS6kgBDJyNhS0gGmkM3bjwdc4jaO8pjBLU/N97ay9ljCNB9fOIRE596Hl1jHhpC Qr2/zjHad1u83UT1s4Ma30jqCdG/+iamwow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601478; x=1694687878; bh=yuYb/FScGlE53o8sIBUUC4AbBWAHIA9MsQv NXxUbr+k=; b=pLoMKEeEd71/ug/91NS/zEfwfGj1Gi+OTyIAdTQGNam9a8+lz7L fJHvdL2UhNbNtkZcaZhqbb3QO6i2gLv+LHao2RL8VYYn+SpoamtH0WzOgSneO1Hc H5okxwcXsIB1Gm6iH2jny88blTD4hWBXJT4PpB4M/1Hq1ao/htWpNEI2CIshEPEx HMlBapq+/pPdBEYzRRIsky5ON+bYWoOaBYtgqvoVRvqTMMqq/KyrLgFMWwn8pKxv 0qkJNvYTJBi1x71vbLRy4GD778JsnDCwfmhp+g8jD+3vnhIgiwfwKu6Hqc8Vlu0K Gz4MX8wDqyNvsoGrufD7+UGTDtvoOOxfDWQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:37:56 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Reshma Pattan , Stephen Hemminger Subject: [PATCH v2 09/11] test: convert threads creation Date: Wed, 13 Sep 2023 12:34:28 +0200 Message-ID: <20230913103600.1935292-10-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Calls to pthread for thread creation are replaced with the rte_thread API. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- app/test/process.h | 10 +++++----- app/test/test_lcores.c | 9 ++++----- app/test/test_pdump.c | 6 +++--- app/test/test_pdump.h | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/test/process.h b/app/test/process.h index 1f073b9c5c..af7bc3e0de 100644 --- a/app/test/process.h +++ b/app/test/process.h @@ -28,8 +28,8 @@ #ifdef RTE_LIB_PDUMP #ifdef RTE_NET_RING -#include -extern void *send_pkts(void *empty); +#include +extern uint32_t send_pkts(void *empty); extern uint16_t flag_for_send_pkts; #endif #endif @@ -49,7 +49,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) char path[32]; #ifdef RTE_LIB_PDUMP #ifdef RTE_NET_RING - pthread_t thread; + rte_thread_t thread; int rc; #endif #endif @@ -136,7 +136,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) #ifdef RTE_LIB_PDUMP #ifdef RTE_NET_RING if ((strcmp(env_value, "run_pdump_server_tests") == 0)) { - rc = pthread_create(&thread, NULL, &send_pkts, NULL); + rc = rte_thread_create(&thread, NULL, send_pkts, NULL); if (rc != 0) { rte_panic("Cannot start send pkts thread: %s\n", strerror(rc)); @@ -151,7 +151,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) #ifdef RTE_NET_RING if ((strcmp(env_value, "run_pdump_server_tests") == 0)) { flag_for_send_pkts = 0; - pthread_join(thread, NULL); + rte_thread_join(thread, NULL); } #endif #endif diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index 0c96faa4cb..22225a9fd3 100644 --- a/app/test/test_lcores.c +++ b/app/test/test_lcores.c @@ -2,7 +2,6 @@ * Copyright (c) 2020 Red Hat, Inc. */ -#include #include #include @@ -341,7 +340,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count) return -1; } -static void *ctrl_thread_loop(void *arg) +static uint32_t ctrl_thread_loop(void *arg) { struct thread_context *t = arg; @@ -350,7 +349,7 @@ static void *ctrl_thread_loop(void *arg) /* Set the thread state to DONE */ t->state = Thread_DONE; - return NULL; + return 0; } static int @@ -362,8 +361,8 @@ test_ctrl_thread(void) /* Create one control thread */ t = &ctrl_thread_context; t->state = Thread_INIT; - if (rte_ctrl_thread_create((pthread_t *)&t->id, "dpdk-test-ctrlt", - NULL, ctrl_thread_loop, t) != 0) + if (rte_thread_create_control(&t->id, "dpdk-test-ctrlt", + ctrl_thread_loop, t) != 0) return -1; /* Wait till the control thread exits. diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c index ea03056b47..adf49f0b54 100644 --- a/app/test/test_pdump.c +++ b/app/test/test_pdump.c @@ -136,8 +136,8 @@ test_pdump_uninit(void) return ret; } -void * -send_pkts(void *empty) +uint32_t +send_pkts(void *empty __rte_unused) { int ret = 0; struct rte_mbuf *pbuf[NUM_PACKETS] = { }; @@ -161,7 +161,7 @@ send_pkts(void *empty) rte_eth_dev_stop(portid); test_put_mbuf_to_pool(mp, pbuf); - return empty; + return 0; } /* diff --git a/app/test/test_pdump.h b/app/test/test_pdump.h index abef9a85ec..8746d61269 100644 --- a/app/test/test_pdump.h +++ b/app/test/test_pdump.h @@ -9,7 +9,7 @@ #define NUM_ITR 3 /* sample test to send packets to the pdump client recursively */ -void *send_pkts(void *port); +uint32_t send_pkts(void *empty); /* Sample test to create setup for the pdump server tests */ int test_pdump_init(void); From patchwork Wed Sep 13 10:34:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131385 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8AB542589; Wed, 13 Sep 2023 12:38:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2827740A89; Wed, 13 Sep 2023 12:38:07 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 7092F40A7A for ; Wed, 13 Sep 2023 12:38:05 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id AAD483200805; Wed, 13 Sep 2023 06:38:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 13 Sep 2023 06:38:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601483; x=1694687883; bh=168jX+opV7QFZxlQju1Kt6n1F9xG/ZGzZOi hmwVq0vA=; b=cFs0JmXfWgTEa4AK1B6qS+gdUH+g7+gopMyxA5EulMBfkTr/LNW i3kHYh60zZnARorAEi8j3eAtTpd/kwNuiP36/zSnuUM9fLfK8yYH3UJfwzubNVcd EzzDhFEwDhgH6tnME3lgu6hURrE/7TtpSjO789e7/uFrpWJYgGsT5B1879EXIBbz 14PS6JJomtm3TdHCFiJrECew/BZu9SZsIeYLTunf/a4iB+Y2O4zaBk0BQ0WhToQg 9f4DiYyP8Zkxqq4z8AYeLKwZ1SWeraiOBG7CnDwBMr8+KoodMqh7ocbDhq7GOGCk /9oIEu6Aj2i1Xn/IJ9gCC3bMv4X6WjN7CWg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601483; x=1694687883; bh=168jX+opV7QFZxlQju1Kt6n1F9xG/ZGzZOi hmwVq0vA=; b=X3oBpCGIz2XNl5zSzHOHyNaWQ2wxB8MCMCJ0ZMmeEYhzSgqYsrY 5mCJiF0rp05FN0wSa73p15qmeEmUuKI14YOwWmjlzJ3oeFMWEadI4Llnz9Peb+1R c6ld4R8C16gkWui9p92kVMGoFMg7Dl8Vx4/qDABpGfJC6eMUhtUz+FGKlSQ9Ofz6 PiPwlF0B9L4ygayR253YXkOiMjos4gRho3byVLqj2GvszTIvx7YdCSUfBYI2DsIR YssCtKLg03NOIWUNWhUaJ9WpAn7EzHoTLo199qcbPmMYZ7M0qh69VaBA/UcbVf13 Q+kRwRZ8baypfQwmZrg6vwT+tAa6ZI0EjPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:38:01 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Anatoly Burakov , Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v2 10/11] eal: remove deprecated thread functions Date: Wed, 13 Sep 2023 12:34:29 +0200 Message-ID: <20230913103600.1935292-11-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The deprecated functions rte_thread_setname() and rte_ctrl_thread_create() are replaced with the new rte_thread API: rte_thread_setname() can be replaced with rte_thread_set_name() or rte_thread_set_prefixed_name() rte_ctrl_thread_create() can be replaced with rte_thread_create_control() or rte_thread_create_internal_control() Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- v2: clean control thread params struct --- .../prog_guide/env_abstraction_layer.rst | 2 +- doc/guides/rel_notes/deprecation.rst | 5 - doc/guides/rel_notes/release_23_11.rst | 4 +- lib/eal/common/eal_common_thread.c | 93 +++---------------- lib/eal/freebsd/eal_thread.c | 7 -- lib/eal/include/rte_lcore.h | 42 --------- lib/eal/linux/eal_thread.c | 16 ---- lib/eal/version.map | 2 - lib/eal/windows/eal_thread.c | 8 -- 9 files changed, 18 insertions(+), 161 deletions(-) diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst index 89014789de..6debf54efb 100644 --- a/doc/guides/prog_guide/env_abstraction_layer.rst +++ b/doc/guides/prog_guide/env_abstraction_layer.rst @@ -756,7 +756,7 @@ Control Thread API ~~~~~~~~~~~~~~~~~~ It is possible to create Control Threads using the public API -``rte_ctrl_thread_create()``. +``rte_thread_create_control()``. Those threads can be used for management/infrastructure tasks and are used internally by DPDK for multi process support and interrupt handling. diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 3e48908b51..8c8873006d 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -29,11 +29,6 @@ Deprecation Notices are renamed to ``rte_tel_data_add_array_uint`` and ``rte_tel_data_add_dict_uint`` respectively. As such, the old function names are deprecated and will be removed in a future release. -* eal: The functions ``rte_thread_setname`` and ``rte_ctrl_thread_create`` - are planned to be deprecated starting with the 23.07 release, subject to - the replacement API rte_thread_set_name and rte_thread_create_control being - marked as stable, and planned to be removed by the 23.11 release. - * eal: ``RTE_CPUFLAG_NUMFLAGS`` will be removed in DPDK 23.11 release. This is to allow new CPU features to be added without ABI breakage. diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index d7562fd646..9746809a66 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -115,7 +115,9 @@ API Changes * eal: The thread API has changed. The function ``rte_thread_create_control()`` does not take attributes anymore. - The whole thread API was promoted to stable level. + The whole thread API was promoted to stable level, + except ``rte_thread_setname()`` and ``rte_ctrl_thread_create()`` which are + replaced with ``rte_thread_set_name()`` and ``rte_thread_create_control()``. ABI Changes diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c index cd6e00fe8a..a71142662a 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -235,25 +235,22 @@ enum __rte_ctrl_thread_status { CTRL_THREAD_ERROR /* Control thread encountered an error */ }; -struct rte_thread_ctrl_params { - union { - void *(*ctrl_start_routine)(void *arg); - rte_thread_func control_start_routine; - } u; +struct control_thread_params { + rte_thread_func start_routine; void *arg; int ret; /* Control thread status. * If the status is CTRL_THREAD_ERROR, 'ret' has the error code. */ - enum __rte_ctrl_thread_status ctrl_thread_status; + enum __rte_ctrl_thread_status status; }; -static int ctrl_thread_init(void *arg) +static int control_thread_init(void *arg) { struct internal_config *internal_conf = eal_get_internal_configuration(); rte_cpuset_t *cpuset = &internal_conf->ctrl_cpuset; - struct rte_thread_ctrl_params *params = arg; + struct control_thread_params *params = arg; __rte_thread_init(rte_lcore_id(), cpuset); /* Set control thread socket ID to SOCKET_ID_ANY @@ -262,96 +259,34 @@ static int ctrl_thread_init(void *arg) RTE_PER_LCORE(_socket_id) = SOCKET_ID_ANY; params->ret = rte_thread_set_affinity_by_id(rte_thread_self(), cpuset); if (params->ret != 0) { - __atomic_store_n(¶ms->ctrl_thread_status, + __atomic_store_n(¶ms->status, CTRL_THREAD_ERROR, __ATOMIC_RELEASE); return 1; } - __atomic_store_n(¶ms->ctrl_thread_status, + __atomic_store_n(¶ms->status, CTRL_THREAD_RUNNING, __ATOMIC_RELEASE); return 0; } -static void *ctrl_thread_start(void *arg) -{ - struct rte_thread_ctrl_params *params = arg; - void *start_arg = params->arg; - void *(*start_routine)(void *) = params->u.ctrl_start_routine; - - if (ctrl_thread_init(arg) != 0) - return NULL; - - return start_routine(start_arg); -} - static uint32_t control_thread_start(void *arg) { - struct rte_thread_ctrl_params *params = arg; + struct control_thread_params *params = arg; void *start_arg = params->arg; - rte_thread_func start_routine = params->u.control_start_routine; + rte_thread_func start_routine = params->start_routine; - if (ctrl_thread_init(arg) != 0) + if (control_thread_init(arg) != 0) return 0; return start_routine(start_arg); } -int -rte_ctrl_thread_create(pthread_t *thread, const char *name, - const pthread_attr_t *attr, - void *(*start_routine)(void *), void *arg) -{ - struct rte_thread_ctrl_params *params; - enum __rte_ctrl_thread_status ctrl_thread_status; - int ret; - - params = malloc(sizeof(*params)); - if (!params) - return -ENOMEM; - - params->u.ctrl_start_routine = start_routine; - params->arg = arg; - params->ret = 0; - params->ctrl_thread_status = CTRL_THREAD_LAUNCHING; - - ret = pthread_create(thread, attr, ctrl_thread_start, (void *)params); - if (ret != 0) { - free(params); - return -ret; - } - - if (name != NULL) - rte_thread_set_name((rte_thread_t){(uintptr_t)*thread}, name); - - /* Wait for the control thread to initialize successfully */ - while ((ctrl_thread_status = - __atomic_load_n(¶ms->ctrl_thread_status, - __ATOMIC_ACQUIRE)) == CTRL_THREAD_LAUNCHING) { - /* Yield the CPU. Using sched_yield call requires maintaining - * another implementation for Windows as sched_yield is not - * supported on Windows. - */ - rte_delay_us_sleep(1); - } - - /* Check if the control thread encountered an error */ - if (ctrl_thread_status == CTRL_THREAD_ERROR) { - /* ctrl thread is exiting */ - rte_thread_join((rte_thread_t){(uintptr_t)*thread}, NULL); - } - - ret = params->ret; - free(params); - - return -ret; -} - int rte_thread_create_control(rte_thread_t *thread, const char *name, rte_thread_func start_routine, void *arg) { - struct rte_thread_ctrl_params *params; + struct control_thread_params *params; enum __rte_ctrl_thread_status ctrl_thread_status; int ret; @@ -359,10 +294,10 @@ rte_thread_create_control(rte_thread_t *thread, const char *name, if (params == NULL) return -ENOMEM; - params->u.control_start_routine = start_routine; + params->start_routine = start_routine; params->arg = arg; params->ret = 0; - params->ctrl_thread_status = CTRL_THREAD_LAUNCHING; + params->status = CTRL_THREAD_LAUNCHING; ret = rte_thread_create(thread, NULL, control_thread_start, params); if (ret != 0) { @@ -375,7 +310,7 @@ rte_thread_create_control(rte_thread_t *thread, const char *name, /* Wait for the control thread to initialize successfully */ while ((ctrl_thread_status = - __atomic_load_n(¶ms->ctrl_thread_status, + __atomic_load_n(¶ms->status, __ATOMIC_ACQUIRE)) == CTRL_THREAD_LAUNCHING) { rte_delay_us_sleep(1); } diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c index ba9b25c2c0..6f97a3c2c1 100644 --- a/lib/eal/freebsd/eal_thread.c +++ b/lib/eal/freebsd/eal_thread.c @@ -42,10 +42,3 @@ void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name) pthread_set_name_np((pthread_t)thread_id.opaque_id, truncated); } - -int rte_thread_setname(pthread_t id, const char *name) -{ - /* this BSD function returns no error */ - pthread_set_name_np(id, name); - return 0; -} diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 6ce810b876..7deae47af3 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -385,20 +385,6 @@ void rte_lcore_register_usage_cb(rte_lcore_usage_cb cb); void rte_lcore_dump(FILE *f); -/** - * Set thread names. - * - * @note It fails with glibc < 2.12. - * - * @param id - * Thread id. - * @param name - * Thread name to set. - * @return - * On success, return 0; otherwise return a negative value. - */ -int rte_thread_setname(pthread_t id, const char *name); - /** * Register current non-EAL thread as a lcore. * @@ -421,34 +407,6 @@ rte_thread_register(void); void rte_thread_unregister(void); -/** - * Create a control thread. - * - * Creates a control thread with the given name and attributes. The - * affinity of the new thread is based on the CPU affinity retrieved - * at the time rte_eal_init() was called, the dataplane and service - * lcores are then excluded. If setting the name of the thread fails, - * the error is ignored and a debug message is logged. - * - * @param thread - * Filled with the thread id of the new created thread. - * @param name - * The name of the control thread (max 16 characters including '\0'). - * @param attr - * Attributes for the new thread. - * @param start_routine - * Function to be executed by the new thread. - * @param arg - * Argument passed to start_routine. - * @return - * On success, returns 0; on error, it returns a negative value - * corresponding to the error number. - */ -int -rte_ctrl_thread_create(pthread_t *thread, const char *name, - const pthread_attr_t *attr, - void *(*start_routine)(void *), void *arg); - #ifdef __cplusplus } #endif diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c index b9a126f3a8..880070c627 100644 --- a/lib/eal/linux/eal_thread.c +++ b/lib/eal/linux/eal_thread.c @@ -39,19 +39,3 @@ void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name) if (ret != 0) RTE_LOG(DEBUG, EAL, "Failed to set thread name\n"); } - -int rte_thread_setname(pthread_t id, const char *name) -{ - int ret = ENOSYS; -#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) -#if __GLIBC_PREREQ(2, 12) - char truncated[16]; - - strlcpy(truncated, name, sizeof(truncated)); - ret = pthread_setname_np(id, truncated); -#endif -#endif - RTE_SET_USED(id); - RTE_SET_USED(name); - return -ret; -} diff --git a/lib/eal/version.map b/lib/eal/version.map index 6d32c19286..915057b325 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -20,7 +20,6 @@ DPDK_24 { rte_cpu_get_flag_enabled; rte_cpu_get_flag_name; rte_cpu_is_supported; # WINDOWS_NO_EXPORT - rte_ctrl_thread_create; rte_cycles_vmware_tsc_map; # WINDOWS_NO_EXPORT rte_delay_us; rte_delay_us_block; @@ -278,7 +277,6 @@ DPDK_24 { rte_thread_set_affinity_by_id; rte_thread_set_name; rte_thread_set_priority; - rte_thread_setname; rte_thread_unregister; rte_thread_value_get; rte_thread_value_set; diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c index 464d510838..9e3df200b9 100644 --- a/lib/eal/windows/eal_thread.c +++ b/lib/eal/windows/eal_thread.c @@ -76,11 +76,3 @@ rte_sys_gettid(void) { return GetCurrentThreadId(); } - -int -rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name) -{ - /* TODO */ - /* This is a stub, not the expected result */ - return 0; -} From patchwork Wed Sep 13 10:34:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131386 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5E8E442588; Wed, 13 Sep 2023 12:38:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 14B2E40A72; Wed, 13 Sep 2023 12:38:17 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 3C51A402E2 for ; Wed, 13 Sep 2023 12:38:15 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 2DAEE3200991; Wed, 13 Sep 2023 06:38:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 13 Sep 2023 06:38:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1694601491; x=1694687891; bh=CmRpyHZnRwrd/WVgmOtZhSc3zNRrJ91JaeY 4VGVqLbM=; b=JOhOgplPAnzJX2AarUyD13RbGta+HZgVjWrIMkLnzTt37PKZROc AjYaBDPU/6cYnOq/caTaizZozTDlLxAuZTLkEeo8LB239OtrWDgDZYxhP95cP96T l2r6uv7mEzZvZAppin8xK59Y6rasuAy77NOWOAireHcJUZ9SzisJCoQL2ztdSs0z y/E1agdih+VkRJyN1zT1YkdzSWZN5R8FilYYNoDMnEf8iFLPwLkYqT/eUYvys53/ y9Dw4HW+BBEyJYZhQN1Ly1+w6JNvcYbNk8oCXwclqi/A1RTmd6jDROVIr1Yfru1W 2li+feFF/XpExfhftUkJyKTzWxGrrYbYn9Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694601491; x=1694687891; bh=CmRpyHZnRwrd/WVgmOtZhSc3zNRrJ91JaeY 4VGVqLbM=; b=hsmkN22heEFOGLoKRpO70wxbe2Wv6d+I+doLhbEl3VWyAThf7PW 6xlMrJ3VIl87S5Fwxx7jWKdiNoksI4uLMRWzMrfXWUuZnTDqn1yGlfAh6+ny5RhU lSwkxOucfj9DY2tUKEOpqYx+mwyEgvjUjbw7SzpazTK43XghedmTzZuMlOTPX7XY UJuxxctqzOcFrIB8HAZqx+mOkvDAvKcyCJJpspZfZYeg3fXUv1Jskn3sBC6SiY3e KKp272jocYrP5wAS+qtOnCKOK1dE7su6uHSJ0I36386PCZBRL5Q53rSqUBj49WYn lJrz8A/YJ7VL+6LKVNSXWk0YKyMHsquaDuw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Sep 2023 06:38:07 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , =?utf-8?q?Morten_Br=C3=B8rup?= , Ajit Khaparde , Rosen Xu , Chas Williams , "Min Hu (Connor)" , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Somnath Kotur , Devendra Singh Rawat , Alok Prasad , Tianfei Zhang , Vijay Kumar Srivastava , Jerin Jacob , Sunil Kumar Kori , Anatoly Burakov , Bruce Richardson , Andrew Rybchenko , Naga Harish K S V , Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 11/11] lib: remove pthread.h from includes Date: Wed, 13 Sep 2023 12:34:30 +0200 Message-ID: <20230913103600.1935292-12-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913103600.1935292-1-thomas@monjalon.net> References: <20230906162226.1618088-1-thomas@monjalon.net> <20230913103600.1935292-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The header files should have the minimum embedded includes. The file pthread.h can logically be removed from rte_per_lcore.h and rte_ethdev_core.h files. Signed-off-by: Thomas Monjalon Acked-by: Morten Brørup Acked-by: Tyler Retzlaff Acked-by: Ajit Khaparde Acked-by: Rosen Xu --- app/test/test_link_bonding.c | 2 ++ drivers/common/mlx5/mlx5_common.c | 1 + drivers/common/mlx5/windows/mlx5_win_ext.h | 2 ++ drivers/net/bnxt/bnxt.h | 1 + drivers/net/qede/base/bcm_osal.h | 1 + drivers/raw/ifpga/base/opae_osdep.h | 1 + drivers/vdpa/sfc/sfc_vdpa.c | 1 + lib/eal/common/eal_common_options.c | 1 + lib/eal/common/eal_common_trace.c | 1 + lib/eal/common/malloc_mp.c | 1 + lib/eal/freebsd/eal_alarm.c | 1 + lib/eal/include/rte_per_lcore.h | 2 -- lib/eal/linux/eal_alarm.c | 1 + lib/ethdev/ethdev_driver.c | 1 + lib/ethdev/ethdev_driver.h | 2 ++ lib/ethdev/rte_ethdev_core.h | 2 -- lib/ethdev/rte_flow.c | 1 + lib/eventdev/rte_event_eth_rx_adapter.c | 1 + lib/vhost/vhost.c | 1 + 19 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c index 2f46e4c6ee..d6b6ebc2f2 100644 --- a/app/test/test_link_bonding.c +++ b/app/test/test_link_bonding.c @@ -10,8 +10,10 @@ #include #include #include +#include #include #include + #include #include #include diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 0ad14a48c7..ca8543e36e 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/drivers/common/mlx5/windows/mlx5_win_ext.h b/drivers/common/mlx5/windows/mlx5_win_ext.h index 6f69329a6f..a71c69bff5 100644 --- a/drivers/common/mlx5/windows/mlx5_win_ext.h +++ b/drivers/common/mlx5/windows/mlx5_win_ext.h @@ -5,6 +5,8 @@ #ifndef __MLX5_WIN_ETX_H__ #define __MLX5_WIN_ETX_H__ +#include + #include "mlx5_prm.h" #include "mlx5devx.h" diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index ed21ba7f29..0e01b1d4ba 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h index 97e261d306..11019b5623 100644 --- a/drivers/net/qede/base/bcm_osal.h +++ b/drivers/net/qede/base/bcm_osal.h @@ -8,6 +8,7 @@ #define __BCM_OSAL_H #include +#include #include #include #include diff --git a/drivers/raw/ifpga/base/opae_osdep.h b/drivers/raw/ifpga/base/opae_osdep.h index 033b7e098c..e91205f536 100644 --- a/drivers/raw/ifpga/base/opae_osdep.h +++ b/drivers/raw/ifpga/base/opae_osdep.h @@ -7,6 +7,7 @@ #include #include +#include #ifdef RTE_LIB_EAL #include "osdep_rte/osdep_generic.h" diff --git a/drivers/vdpa/sfc/sfc_vdpa.c b/drivers/vdpa/sfc/sfc_vdpa.c index bd6ecde450..9db87fcb7d 100644 --- a/drivers/vdpa/sfc/sfc_vdpa.c +++ b/drivers/vdpa/sfc/sfc_vdpa.c @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index d74b581567..a6d21f1cba 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -5,6 +5,7 @@ #include #include +#include #ifndef RTE_EXEC_ENV_WINDOWS #include #endif diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index cb980af06d..b21e61bf39 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c index 7270c2ec90..4d62397aba 100644 --- a/lib/eal/common/malloc_mp.c +++ b/lib/eal/common/malloc_mp.c @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c index acdcf53804..e5b0909a45 100644 --- a/lib/eal/freebsd/eal_alarm.c +++ b/lib/eal/freebsd/eal_alarm.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h index 2b846f9337..5a1497631a 100644 --- a/lib/eal/include/rte_per_lcore.h +++ b/lib/eal/include/rte_per_lcore.h @@ -22,8 +22,6 @@ extern "C" { #endif -#include - #ifdef RTE_TOOLCHAIN_MSVC /** * Macro to define a per lcore variable "var" of type "type", don't diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c index 397f25d7d5..766ba2c251 100644 --- a/lib/eal/linux/eal_alarm.c +++ b/lib/eal/linux/eal_alarm.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c index 0be1e8ca04..30db839a77 100644 --- a/lib/ethdev/ethdev_driver.c +++ b/lib/ethdev/ethdev_driver.c @@ -3,6 +3,7 @@ */ #include +#include #include #include diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 980f837ab6..3fa8b309c1 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -18,6 +18,8 @@ extern "C" { * use them. */ +#include + #include #include #include diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h index 46e9721e07..8d260584b4 100644 --- a/lib/ethdev/rte_ethdev_core.h +++ b/lib/ethdev/rte_ethdev_core.h @@ -5,8 +5,6 @@ #ifndef _RTE_ETHDEV_CORE_H_ #define _RTE_ETHDEV_CORE_H_ -#include - /** * @file * diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 271d854f78..0c5aabea45 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c index c166ef69a8..2145d803e4 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.c +++ b/lib/eventdev/rte_event_eth_rx_adapter.c @@ -4,6 +4,7 @@ */ #include #include +#include #if defined(LINUX) #include #endif diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index eb6309b681..c03bb9c6eb 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -6,6 +6,7 @@ #include #include #include +#include #ifdef RTE_LIBRTE_VHOST_NUMA #include #include