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;