From patchwork Wed Sep 6 16:12:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131198 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 566B942529; Wed, 6 Sep 2023 18:22:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 66D9F402D1; Wed, 6 Sep 2023 18:22:46 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id C5A2E402D0 for ; Wed, 6 Sep 2023 18:22:45 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 9D7DE320031A; Wed, 6 Sep 2023 12:22:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 06 Sep 2023 12:22:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017364; x= 1694103764; bh=o7X+JH83KDILLQ+AXBN0uumHj/dS70o4vgFk7IRx5uo=; b=Q VKm1LP8IRCYryaeJxF8BPJGlL7FLW6b2EPDMHxVTzOkMcSVydVQRKRVRS1+Nau7Z IGOYeaI2Vz02UGuBNhiyuMMBrzW2r77zhjMkiYG3Qaq4m5Wj+IpIzI+yPl4kDq8e N75AFYoiok1uYXwUDl/PVh3+kEvDTT7ror8Yo2OghtoeWc9pgTSD9Sw3J1VNo5IF ctq7X2sU46jZQi544YuOoOlSer8sdqFMXFmSG1fg2JXb/JRBJYDdI6nKgVG4aZjy YDa2t4H7lAmJ7Jtr1Vl8ua13rsOoCgzKTzUjNYwRF1UNuhTFyxBQaOO/X+94bTPE YdVcuBFZ5pRF8wS14wy3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017364; x= 1694103764; bh=o7X+JH83KDILLQ+AXBN0uumHj/dS70o4vgFk7IRx5uo=; b=J ZMSDVSZJ9ya9GXuNrJcSoXdK+Xvm3ZbLvGVQY8k6rNjG6Eg/3CI/tafW0+FHX9/z maVYarVZdNtaQP0/7/tp7KnvwS+7bZaeKSWIaYWnRwSfXXop0NCswViWakteRxOv VHd/03FV9w4KW39j1k9FR2YqWQj0YOimrHFROQWOAeFhfXRXWlSyM5+BA9o6c8Yz Kbot8chginvl5lAzkUYvMKzT/AjMWpbxirLS9oNH6oqg7M/93Ng2v/gODrFMwTmm 0sm1X3WlXC/FmMySJfQbOMK8HUtUXxHATxJwfS6HS18PedJ/tTMSTwhYmrzkT1kG 1rC747F0BGXeJhiGrRuIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvjefhudeghedvtdeijeeigeetuedugfejueekieeltdfhteev keehhfeilefhtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:22:43 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit Subject: [PATCH 01/11] devtools: warn when adding some pthread calls Date: Wed, 6 Sep 2023 18:12:18 +0200 Message-ID: <20230906162226.1618088-2-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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 --- devtools/checkpatches.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index 55fabc5458..131ffbcebe 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 6 16:12:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131199 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 281D742529; Wed, 6 Sep 2023 18:23:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F773402C7; Wed, 6 Sep 2023 18:22:58 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 42226402C4 for ; Wed, 6 Sep 2023 18:22:57 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id A865032005C1; Wed, 6 Sep 2023 12:22:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 06 Sep 2023 12:22:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017375; x= 1694103775; bh=OB5H0SECAP+AeAiZynEl0iheHrKCmFTeAW1M1SMNZCU=; b=o j/s0bJiJLz4RnTcPnbN/sFyLqExd2uUHxrpCg+d1Ove4vi9P/VEEDolDmglLkH5L nUbr+jICfrx0ZbY44Eg7FcOjndZkavIFp5p4U5BbsvvtlNpd3zwhOzhbncNZIGb5 4KE6nBITGrDTPiowcQ/DK144v0RpR/hCFb84tslisQt/W3La2Kbyi/tIBvjvGslI Da4a9iXkku8d9YKmgYt2zuvqmNm79KJzaYyJjMvbU61GPjvzKawPIQngCIJh+31F GG5ftWGroTwy5v/tso72jDwNs1j6GDy8vBNZ8KbfeK+1p4aIXujXSNS22IbKWH+g /3kZ8UUAMSTipgol0bn/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017375; x= 1694103775; bh=OB5H0SECAP+AeAiZynEl0iheHrKCmFTeAW1M1SMNZCU=; b=R ALKs27lo44o6IpFKVP9oSoGs3H8kXz4TCjunXj9D+fr6oTpHJBNP2nnqh8wlJ/Q0 YQtQf4UvyMPkWfh42Yqzei2pYPb4Lp5nB4Ta7TsmYoQy8zsJ4hr2MktRKzroYFWX 9DlNrAALF1AIdSHAMUMPGTPyTu5euQjvmGnWx60AxspWip/Zv7QnufoCCvFS7lAz KfgHiedAnaGBTn5jYaIrxlAxqHnkT6dN3zROUgRem6yFJdapXfkQ9+OrvI9B1eUB xEXqwRdYvOPEuWWqSx3pN6SkAPziDF+tE86ns3gLTR8joKfyKqnK3CLr4XRZ8cBL iUZxv/cIrFFR6HqhLSbuw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnhepvdejhfdugeehvddtieejieegteeuudfgjeeukeeiledthfet veekhefhieelhfdtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:22:53 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH 02/11] eal: rename thread name length definition Date: Wed, 6 Sep 2023 18:12:19 +0200 Message-ID: <20230906162226.1618088-3-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: 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 6 16:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131200 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 915E642529; Wed, 6 Sep 2023 18:23:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8CBA0402DB; Wed, 6 Sep 2023 18:23:12 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 69C28402D9 for ; Wed, 6 Sep 2023 18:23:11 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E57103200962; Wed, 6 Sep 2023 12:23:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 06 Sep 2023 12:23:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017388; x= 1694103788; bh=mwxBovMGR9M0BztQPLX3+3QDroZ7I5vVRzNtOcoP37o=; b=f m0iX98QWLnzbEstvqQ7TV4U60rbja1WLwGMDjWtf6LQMSRbugo5hHZDNciXT/ACs qnJ1qxMYHSOF015xmbNPIieVBu0b6rKdElbjzvJ3TZRsMgu6BRaY6OXTiEcE8GMT n4EfVRxYRB37sf9ISCNwQghJdJXO41WVtfkcAR1qXmZtiLlZczv7ri4ZkfN/GL/Q gM+2zwIo8xd6flytywwSjfZw9QuPnOxy5181GJqK3fuysdPh/zFaW8naNkD953JM 9ipGeu0EAXEAKXbA+YTRgiUKFf8kTim+qjrzoII2WOkCi9y8iswLfkrtwwv6Xzq8 VOrWPDl47OvQTF91HZmdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017388; x= 1694103788; bh=mwxBovMGR9M0BztQPLX3+3QDroZ7I5vVRzNtOcoP37o=; b=B BN1mKPN95cLmEhfxXscdEPp0alhlwCexewJbNdhSJMta8ewM4wfl+6v1kbrOSpsq D27ognCwDnRsw9XtXirGmdQJ7tc5sBHVNmFuve6ajO3y3pbT9tZ0B6u+8bhaquA2 9BFEFebJH/L9cqpJmX8IWGP9sPBYeWIgPyQrSe4VomfJ/7dDJN9cdFbcmW3hcaz/ fG7wzbxqko+F3VHJ551uIBpRPkiUXCP44T3KVszbnTG3bXGgNtBSVIi3AHMd8NaK cN1qUsAU39UOwNBqiXIQJuAFXRksTuNc5NMICqRsJwyY3HxplL9ePfUijCqcMOpA EfeDMjQrGli0XeOEfudFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvjefhudeghedvtdeijeeigeetuedugfejueekieeltdfhteev keehhfeilefhtdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:04 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , 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 03/11] eal: remove attributes from control thread creation Date: Wed, 6 Sep 2023 18:12:20 +0200 Message-ID: <20230906162226.1618088-4-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: 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 6 16:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131201 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 F39A742529; Wed, 6 Sep 2023 18:23:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89CAA402D9; Wed, 6 Sep 2023 18:23:18 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 06198402D5 for ; Wed, 6 Sep 2023 18:23:17 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id D671C32009C2; Wed, 6 Sep 2023 12:23:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 06 Sep 2023 12:23:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017395; x= 1694103795; bh=0lpDfhHwjfLZK1JilIzChNCZ4EeSH9bmTDe7CCJ/rWE=; b=P hZsidOna5AyYOTpO7aRgRk4lYyXhLg/qADs/YghgkryUejMuQ4jgj44NFO41Pai+ 90NB3vsHVqErss3Q0XbjgRnqamRib1SIK1R4exGKyPjP7bSQbxC5teJ4lYzIce4I r+Du3hpfXOYNzb402uB5ksKkwlsKSqHMuj87pIo2mrkja7tlfzpBYlp/eGASWK++ OnbpY8YEIGl1zVx6cQGgkCulqTTT+JKEFcSJvE6nI6NhVoUSedeRaVq1jM6a0NHE JZeXxZMaECXhlkiEscub2uiffwFEZFwqfgj9g9GdyXG3G8bJZo5pUOhhbbMDxN7a EfhjErR6OUOxvkkjYpbzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017395; x= 1694103795; bh=0lpDfhHwjfLZK1JilIzChNCZ4EeSH9bmTDe7CCJ/rWE=; b=G LnVGJtj7JPmJ2X6NNIBYxLWfQkE6lU47T5fRxeVbv7LNvK10oync41V26dqwYT7X zwAeNSU2vU1itrgPKit16ylYzEGfDh6L5BUZ9dKojO9v6P1T6SSijrixxB2Jcfj4 GGAFlnV3a54lZlCCE4f6dikjGV10mZn4tp41MIKgVrFpaKu3lK4JXn1T/IGWFA7d Qog5Xry0QKE5Pk4Y39svnGf34PSQaCGaIdO+yJ83kVwCXhDt69eNa57byQkUiN0Z NggDqjZr+wtA0kMiWz5gMKp9HPzQPiCUZtDxlf+O84IZSx4z+L7b9VDCBH8dJYnb ySmRp6TGSVoXPxVaZHYiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvjefhudeghedvtdeijeeigeetuedugfejueekieeltdfhteev keehhfeilefhtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:14 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit Subject: [PATCH 04/11] eal: promote thread API as stable Date: Wed, 6 Sep 2023 18:12:21 +0200 Message-ID: <20230906162226.1618088-5-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: 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 6 16:12:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131202 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 5028B42529; Wed, 6 Sep 2023 18:23:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C826D4027E; Wed, 6 Sep 2023 18:23:24 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 98363402E2 for ; Wed, 6 Sep 2023 18:23:23 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 73D24320096D; Wed, 6 Sep 2023 12:23:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 06 Sep 2023 12:23:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017401; x= 1694103801; bh=rxG68et7JQxcK2X0nZ4GmZrJdcC0SauWMLlPbucInN8=; b=j x/GpcZieNepdFXHXoqtAK+c7fwpg3g5yEvjYP78tnoSnq0ifzeJ5AyWV25//68MU cLolvQj+vH6SMmnsZHx4NQqADqNLhKGbkvxuKKuuIkWHGcBk/az5onpKxSq6s6Am EJult3w2jqRfGBxj2CrLMD2Ui6T67XbLPRvk7EZvnVvRhWSbA0rr7mK1EJ/6IFzG f5fRhu28tAvNM7lZznBp7z78sVp23v8EvdlaANxzis7bq71QtT7VtQbIWER2vohi DQnThJB+FjJn3Fo01OhIIyoZxN+flm2zt96pZQ+5Mgp7/nICfQPjXg+8aWl9Ee28 q2QChL7vsxEydnYv5IBuA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017401; x= 1694103801; bh=rxG68et7JQxcK2X0nZ4GmZrJdcC0SauWMLlPbucInN8=; b=P ADcsmdtpSBiCEbxaPhIcqp7RLutC2blKTfV9zFyX5EorokF/iNrSrIOVQCJxDpas uPLPZisyZmdps6VGxTdU1HLEvvgpKD7B0XMqJOd1IsM5g4uqV9iQnp5acKMK2ZJn fxY2kbxXTUyiebpl0glpB6kUVyDdUcoAMT1fZRe4Ar2yhrQ0/NmO/eae21jUGrP/ Iu50kOLE65shq41+VRKkvOw1+gS7zR09iUO2rD2uZqsDDABtgnOarKkcPgy1ma6f 6X/CwHIBQ6YZo9BaL637UxK8UrT1rMvVn4rLKPYTmM0MmLM5ZGTHNpYoVo6de4eK kMoErj7suShCG6OklqG8A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvjefhudeghedvtdeijeeigeetuedugfejueekieeltdfhteev keehhfeilefhtdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:20 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit Subject: [PATCH 05/11] eal: force prefix for internal threads Date: Wed, 6 Sep 2023 18:12:22 +0200 Message-ID: <20230906162226.1618088-6-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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 --- devtools/checkpatches.sh | 8 +++++ lib/eal/common/eal_common_thread.c | 30 ++++++++++++++++ lib/eal/include/rte_thread.h | 57 +++++++++++++++++++++++++++++- lib/eal/version.map | 2 ++ 4 files changed, 96 insertions(+), 1 deletion(-) diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index 131ffbcebe..18ad6fbb7f 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..31c37e3102 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -392,6 +392,36 @@ 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) +{ + const char *prefix = "dpdk-"; + size_t prefixlen; + + prefixlen = strlen(prefix); + strlcpy(prefixed_name, 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..4b1135df4f 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -28,6 +28,9 @@ extern "C" { /* Old definition, aliased for compatibility. */ #define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE +/** Maximum internal thread name length (including '\0'). */ +#define RTE_THREAD_INTERNAL_NAME_SIZE 11 + /** * Thread id descriptor. */ @@ -112,7 +115,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 +124,36 @@ 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 with "dpdk-". + * 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 + * (maximum 10 characters excluding terminating '\0'). + * See RTE_THREAD_INTERNAL_NAME_SIZE. + * The name of the driver or library should be first, + * then followed by a hyphen and more details. + * It will be prefixed with "dpdk-" 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 +192,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 +207,27 @@ 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 adding a "dpdk-" 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 + * (maximum 10 characters excluding terminating '\0'). + * See RTE_THREAD_INTERNAL_NAME_SIZE. + * The name of the driver or library should be first, + * then followed by a hyphen and more details. + * It will be prefixed with "dpdk-" 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 6 16:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131203 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 3092442529; Wed, 6 Sep 2023 18:23:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE882402CF; Wed, 6 Sep 2023 18:23:32 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id CB595402CF for ; Wed, 6 Sep 2023 18:23:31 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id ABE3A3200961; Wed, 6 Sep 2023 12:23:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 06 Sep 2023 12:23:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017409; x= 1694103809; bh=igwCenGrRZHCYI88j+lV8THyohyOAN1qiFsN5MB8Jrw=; b=b gVKEIk+lkEznGI/WPKvoHBo2z+O5JLqtRtPKG42jojruck3efrVIpfOqfl4NW8gM JBkGpoICe2raRkOxXqf2VoAynCGQLiVERxdVnZlG92SFVg0cXzmwWbb2mkmVnY+d 1+HAumX8e9aYmCncNiKr4r4/tji4zu/xvAhkxeBh8llQ2xIRSCyzHTn5gEB7Fgkp hH2uH+6EWrXkwd1W8UrPKYj57BNGvd3uHykzAQoXm7biMg15yx/Yas+w8yQSEXaB 3NB6dp/WOLs+8EuFiEodpbwG9k33mgpFaLB0j1lpua0VVgX+e01JkfScNN9v6Mh1 tRchmc3ucOBSfHmcMAonA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017409; x= 1694103809; bh=igwCenGrRZHCYI88j+lV8THyohyOAN1qiFsN5MB8Jrw=; b=m 9+PxmCnRiaLqd2bWeA8XYdYVVcr6hdPxh33DZOawEBvUe+jIaKgisHfZz9Gb7y4Y Zc632X06JE+OimeqNkkQxB4ah0icUNL7Y04d8giHeVg4+5M4P0gAeLxgxRwM281b 4iuDXKQm3B/UcFdFrrOc9hbgUxs0ijM4c8nCoZD0CuB1tplRkGCGA2/osoRUA/7y Nt9390HRceFnpmHs1ELVAJAM8+hrn0Z4hcTwtfUXFWjhhrqWNtNzBMwHs/W40bAK eHZkutkP2B7ldexvlbc6PIbOoSy9+9MTYJCBJVBb04il//eY+p4fdADOJr1rVx80 RsGIaOOp/Lw2Iehw1p7Kg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvjefhudeghedvtdeijeeigeetuedugfejueekieeltdfhteev keehhfeilefhtdenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:26 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , 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 06/11] lib: convert to internal control threads Date: Wed, 6 Sep 2023 18:12:23 +0200 Message-ID: <20230906162226.1618088-7-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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 --- 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 6 16:12:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131204 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 55EE842529; Wed, 6 Sep 2023 18:23:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C822402D7; Wed, 6 Sep 2023 18:23:48 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id BD018402CE for ; Wed, 6 Sep 2023 18:23:46 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 355F8320096D; Wed, 6 Sep 2023 12:23:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 06 Sep 2023 12:23:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017422; x= 1694103822; bh=SE1GveakvOprmbx5k3Vt97bFvLNl3YKwQpOcv6oQs4U=; b=q ZVxcq5q+28YYduzXguXw9OyO5LrFyp2CnXgm/HucQDRurj2mwsR/wtorjPJbSBzH opFXbwHAdyaAtBdFmATY9WxQAt5WxFCstTDqJZJSQ1hX8ydLOxgPPm27PjpqE64z PRUdMMZ9emGEQM0vildhVNUidhCqPx+R8Z8bSy0hNhFNorPoUrC6ynR5L85giNg2 oc9FwAH5HzzrY/OV5VMFyG26RCS2RU+uU8K7KEHvcS3WlRfcbX8j/Vr+iRjrshD0 7aWG64xsbFedFq8GlvzWke0S1dIxJlWfdmSQG1VgTsWuvlZDJQ4dbX32SJYOGvWR +5f78L4epqq7bi7nomxmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017422; x= 1694103822; bh=SE1GveakvOprmbx5k3Vt97bFvLNl3YKwQpOcv6oQs4U=; b=X jYWoNRcJsKvPrHHGHzfBWaouth+9xbrzuqoXDIqUlCD/PKABuNEfuJ4hQKyFjzwh CKX+WF+6MaNAV+wMFVanAVnjQJwDtrijXOcacHSYILamTRr+UWqd+7DJ30J15jlS ns1J/pPC9Rw6B3/l7kSpLbz0fzgDS9YWLgO8a0D9pd+fn4w/JLsgUvj6H4R3HyNr Sgd1erElHS/E34Re7Evupem7CULae7bVULDzBvEHU/uwH12fMO2oEBMUks21n982 Qo24bOOKPnVfk1VWuKwRx+nBXr5Y8UoipKn7j8pNmjpSSjxQirQtMkN1EDGW3ymA ahRozdrEJI3nXBCtyUuqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnhepgfejueehhfeiudfhvdekleffleeuvddtuedvfeeigfdvvddu leefteejtddvudeinecuffhomhgrihhnpehthhhrvggrugdrrhhunhdpthhhrhgvrggurd hiugenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeht hhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:36 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , 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 , Andrew Rybchenko , Jiawen Wu , Jian Wang , Tianfei Zhang , Xiao Wang , Vijay Kumar Srivastava Subject: [PATCH 07/11] drivers: convert to internal control threads Date: Wed, 6 Sep 2023 18:12:24 +0200 Message-ID: <20230906162226.1618088-8-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: 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 6 16:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131205 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 78D5542529; Wed, 6 Sep 2023 18:23:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A2801402DB; Wed, 6 Sep 2023 18:23:54 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 66052402D1 for ; Wed, 6 Sep 2023 18:23:52 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 17FA03200983; Wed, 6 Sep 2023 12:23:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 06 Sep 2023 12:23:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017430; x= 1694103830; bh=Bpq3EzfPk3YeaV5w/zADO/Q60SW+CgY7G6pAJOXm2U4=; b=I EjbmqmuZKBGsA6mu/UAMKe38TX3PV7w/3IBtoGAulZxVyVxsjmkkXkTq/mQtVDCz 2NAjDdf30ZVUP4Zi+rSAb4OhbWJWbnWr0DHPzwxUdzxptO6gKwMx0zXMe1EcFqba Xk8eFa0Lpmdg/NDms//WSkwMbDHxtNp2IkDds/5q/tTxAqRSycbK6a1ixS5agvWZ a7bBPJZQ8jfkpBXEZQ4Aa658xFFe9rQ9fo8PelsxqjQIUPT98sSVo3l1xawWxaEc RKM9jieCUKG91CzuoGKG0CTGx2f3pFIhkfrrG44W86SpLGJ60bKlHVDfdMs8QfsL bpDZTA6LPtV1vooOaPC+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017430; x= 1694103830; bh=Bpq3EzfPk3YeaV5w/zADO/Q60SW+CgY7G6pAJOXm2U4=; b=q 582XytPR9MVkNb6IShV8iOe55D+ayAdbEqI5FKs9NtomhGHzMZwhb9zsJs2mgIum xq12Tul00Mhtf9X/S8BEdtXeHxxxWUdjU9DSV3EG0MM3dgnw9vKgeG1S7pgtL+e7 QeeU+x7EIpuU4thf0Bmj1ngDbmiK8ikBseOo1RQmOsQ9H85KPH1nfuSBeGKmWajc XtXvlyC+PjFY5CxqB9HrN2gHfa7UbuVSHQV6t8uLNuwkW92scRP3Xqg8qTkFQVEm 1LUGSy8YYFdeKU1OARvF0orudtlFlT2VB6uJYwRjsLjHnpXHLotWaiAhzBai2Sf2 ZqtUGRLUzH4jarbYyZgMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnhepvdejhfdugeehvddtieejieegteeuudfgjeeukeeiledthfet veekhefhieelhfdtnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:49 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , Maxime Coquelin , Chenbo Xia Subject: [PATCH 08/11] examples: convert to normal control threads Date: Wed, 6 Sep 2023 18:12:25 +0200 Message-ID: <20230906162226.1618088-9-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: 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 6 16:12:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131206 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 C390442529; Wed, 6 Sep 2023 18:24:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B0318402F1; Wed, 6 Sep 2023 18:23:58 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id A5246402E3 for ; Wed, 6 Sep 2023 18:23:56 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 54A8832004AE; Wed, 6 Sep 2023 12:23:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 06 Sep 2023 12:23:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017434; x= 1694103834; bh=1ju67lAKKDS00A0PCUGCUdDu8iEiMW6LIw6MSEQb598=; b=W tQzKuewq5eylAGeWVB8NmS831BAn8QC+Nj6AVEPxVzeosI8ztkPPAsh+X/uBP8qf cIyZ3cvY3hJpVMsPs5uG3C5crWlO8pGS8zHAslOzSqXDaDc0RdwnhsWAfhbx2trL Q23IyvdB1f+kPG/7djg7wxdfDhuaWJLFXEeajK5eQCDD+gLSIrCiNnhUYNyG7ZlH Gzsey/T6tEW6p8GUME66V8mZYBl6jjtzLziB1IsumQuoopOXwtQS5guCRiIsbz+x hchHiGMU3u6cZxOgc9/X1ekWlBUxny4oMAwHzyfLYDtVoSeJ0yb5vVUaQGONoNWJ Wj04uI3eEJDUPIJJt9kYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017434; x= 1694103834; bh=1ju67lAKKDS00A0PCUGCUdDu8iEiMW6LIw6MSEQb598=; b=L GrkQY8LSH3LmHzY5gXP19Uwt1guU3NWxrNFW3PcKYhWTRQA6Ii5EB+br+T6ghy+e m8ynhhR/7hKC8SJFK/rYD0+s797LQpIlo1jUjVwlhbHdcPulzgvKBWae2yz8Krcc haAiuac8eqK/2yMEr/Dchld8A3ivQXexiOnbv2/7bkXKx8KKsSJmeJT7KncgHWjx 4p5sJ6OqU0Ab7OdDup8ZmpZ2guH6dpc1u2a5gb6AU0LsSiftFhcaA5lqKPkbRvDo FiDUrSOUJ9Jj/bKa56SbNqO8JPw+xQ2fH9AtVY0mh4PzBnbW82YiFwuJQBJPf8g6 UB0u98GxkHl1g3nYq2/Jg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnhepvdejhfdugeehvddtieejieegteeuudfgjeeukeeiledthfet veekhefhieelhfdtnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:53 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , Reshma Pattan , Stephen Hemminger Subject: [PATCH 09/11] test: convert threads creation Date: Wed, 6 Sep 2023 18:12:26 +0200 Message-ID: <20230906162226.1618088-10-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: 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 6 16:12:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131207 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 6A93F42529; Wed, 6 Sep 2023 18:24:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D7C26402EA; Wed, 6 Sep 2023 18:24:04 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id C5248402E3 for ; Wed, 6 Sep 2023 18:24:02 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 22D08320098E; Wed, 6 Sep 2023 12:24:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 06 Sep 2023 12:24:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017440; x= 1694103840; bh=f0yMxo+a3ynaiFmcKMPRWqILQsKlowga946+J9ZefmM=; b=C HxZilOallysRDSgWw8N8zkmhaiM/iP/hyGmCdBG29/HiXtqjlc10xCzVgVBlRS7t /ujKDt4VaiMvHX1UOu7yF0At+1LkWZNL+L1aSXoSeLzyyzM91QdJTUM2ZxMZoHxs KqGbi9DU+6X04d6vEmcUVcKOgSU7EJ9oQoqqQvRanUViKxjhS15Flh/dhdGXjyvL AsJ6QCOWE38gYU7nBNqwHArbwwCiPQar7eunyCsAh81VUvwXeU7HGy01jQp2ubcb NWcBdoPWC0SeBD0vebPMG+rVPk7NcU1y5bCy4FjGkkXdgQ9QUVlQ0n2dC3x/fX/T cbMkRsqiLJwSovwTDSQQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017440; x= 1694103840; bh=f0yMxo+a3ynaiFmcKMPRWqILQsKlowga946+J9ZefmM=; b=q /qyvtyABSpO3UVfWSssfNXBzAGZOHRH9q5z0wUJHenktGlZeOezWKzNTdtPqmOGq HkNlxFshsVlbGS2G56TgYrp6jqzT8JZzr6H47mMv+pFx2ASTToaDd2u68H6eF3Al tHSJR9wnpGbQcQF+CmVIJ9Y/WrFozm7t5AGr7O3Cg2of8fWoWNafG8SLWcdo5rUK liORHhZUSrDEcxg4aqZobTjGs0bgR7IfvJB639x3MhIODk7v9YFgstQhLu7R7dWF P95xiewmzGhD3K1NJk+Vm7TPKCa8J8/R6B7/wg5KVWNPaxeCBbPgDg5bNh0zowwS RTbWR9VeG8oikdLfY1WqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnhepvdejhfdugeehvddtieejieegteeuudfgjeeukeeiledthfet veekhefhieelhfdtnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:23:58 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , Anatoly Burakov , Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH 10/11] eal: remove deprecated thread functions Date: Wed, 6 Sep 2023 18:12:27 +0200 Message-ID: <20230906162226.1618088-11-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: Tyler Retzlaff --- .../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 | 66 +------------------ 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, 6 insertions(+), 146 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 31c37e3102..78f643af73 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -248,7 +248,7 @@ struct rte_thread_ctrl_params { enum __rte_ctrl_thread_status ctrl_thread_status; }; -static int ctrl_thread_init(void *arg) +static int control_thread_init(void *arg) { struct internal_config *internal_conf = eal_get_internal_configuration(); @@ -273,80 +273,18 @@ static int ctrl_thread_init(void *arg) 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; void *start_arg = params->arg; rte_thread_func start_routine = params->u.control_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) 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 6 16:12:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 131208 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 031AA42529; Wed, 6 Sep 2023 18:24:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CD09402E3; Wed, 6 Sep 2023 18:24:12 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id E7DF24027C for ; Wed, 6 Sep 2023 18:24:10 +0200 (CEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id EC5A532001AB; Wed, 6 Sep 2023 12:24:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 06 Sep 2023 12:24:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding: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=fm1; t=1694017447; x= 1694103847; bh=AioJth0kLX7yQEsx9IqAJJXRAQdmzcFy8m7gwGwgLKk=; b=X /kyUENwFUpovss3b7YtloEOs2gUFzTCfujIDj/tHNFPpskSbJ+9U6SMj729SIz1u pLhgmK/b0DM4/ku8lWtLLsq/VlDOwfnwnMtIUMbmL4Tevg2dujNR1vmjB9fNMKXO N1HnH5C5hyB2sY12C/Bl1OQSzmDidn7x7GNqnfAwQCUeF9LMYPeAhWvtRRo8T15A 0bQQisEIFSlrZMArxHqC7RNilAjsPer/G4TCBMlfZFE36c2BBoaKpo3h1IRs14Wz y7vYQPp7xgRz/wBPCu+dpAQH6PLdOsAj7A+9IiuCoIulB23LJW1DyuPY59cEX5XR 3Pbd2sZVa1cMfI2Z6T4CQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm1; t=1694017447; x= 1694103847; bh=AioJth0kLX7yQEsx9IqAJJXRAQdmzcFy8m7gwGwgLKk=; b=m Rya9ZOzlSxWoxN40cN+YMTHLegEFFU21OsfobTnvnHJJSlyS5JjP16r8uEyyRhTa KUDbXlIvrRri/U1bjkHCTrDqD0mJL8uPJSUsOa3wBIXung4xKMl2d+/LdlLkTS3X e5j/n7nn/9mICtj1zHXMi5zJGMRIWCX/L9cgi/XPx3ZBjDo+oPPBy+7F/70PoAF4 KRyU8lOIofFHveBM2bJcil6GKgrv5bcbsalaR5l/GztTSy1S4BFtWS0GiLMhtxGS cVEo9mZGl9yhl4b+ZuYz1xfdBmVn9gNaYXY8HaVQXzVg0BgP0RkAwYH20WX8OBpW RIluPFaHyteWa/KMVn1uQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhho mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne cuggftrfgrthhtvghrnhepvdejhfdugeehvddtieejieegteeuudfgjeeukeeiledthfet veekhefhieelhfdtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Sep 2023 12:24:03 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Tyler Retzlaff , David Marchand , Ferruh Yigit , Chas Williams , "Min Hu (Connor)" , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Ajit Khaparde , Somnath Kotur , Devendra Singh Rawat , Alok Prasad , Rosen Xu , 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 11/11] lib: remove pthread.h from includes Date: Wed, 6 Sep 2023 18:12:28 +0200 Message-ID: <20230906162226.1618088-12-thomas@monjalon.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net> References: <20230906162226.1618088-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: 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