From patchwork Wed Dec 7 19:00:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 120538 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 DF2F1A00C3; Wed, 7 Dec 2022 20:00:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D4A242D35; Wed, 7 Dec 2022 20:00:23 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C4BAE40156 for ; Wed, 7 Dec 2022 20:00:19 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2798620B83E2; Wed, 7 Dec 2022 11:00:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2798620B83E2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670439619; bh=nG0CdWpxgmoCEvWM8kTrb0r/QcHNwioQY+/9+vfi1Zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rHcYoYeA4PBNxHZ18hUJA6vWZOccZNO2YyDolMYb18TDYpVa2ONWNXysezzIBsPvE QDUtGBYwAoFId9SGJVf9cFuri00hz4wFnh6vMPQGL9Q3BPLjJXPX8Kyf12kebnwXEE il/rnhmrPZIPgb1JeD81rwQa20wXFbJJDF9CB/Uk= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, olivier.matz@6wind.com, stephen@networkplumber.org, Tyler Retzlaff Subject: [PATCH 1/5] eal: add lcore set name and get name API Date: Wed, 7 Dec 2022 11:00:13 -0800 Message-Id: <1670439617-9054-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> References: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> 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 Add two new APIs that allow set and get of a name for an lcore that do not explose platform thread details via the public interface. If the underlying platform thread API does allow set of a name for the lcore thread id it is called as a side-effect of set but lack of support or failure from the platform-specific API does will not cause the call to fail allowing for "debugging" on platforms that happen to support the feature without exposing it as a part of the EAL. Signed-off-by: Tyler Retzlaff --- lib/eal/common/eal_common_lcore.c | 32 +++++++++++++++++++++++++++ lib/eal/common/eal_common_thread.c | 15 ++++++------- lib/eal/common/eal_common_trace.c | 2 +- lib/eal/freebsd/eal.c | 5 ++++- lib/eal/freebsd/eal_thread.c | 6 ++++++ lib/eal/include/rte_lcore.h | 44 ++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_thread.h | 8 +++++++ lib/eal/linux/eal.c | 5 ++--- lib/eal/linux/eal_thread.c | 19 ++++++++++++++++ lib/eal/version.map | 5 +++++ lib/eal/windows/rte_thread.c | 41 +++++++++++++++++++++++++++++++++++ 11 files changed, 169 insertions(+), 13 deletions(-) diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c index 06c594b..700362a 100644 --- a/lib/eal/common/eal_common_lcore.c +++ b/lib/eal/common/eal_common_lcore.c @@ -14,6 +14,38 @@ #include "eal_private.h" #include "eal_thread.h" +static char lcore_names[RTE_MAX_LCORE][RTE_LCORE_NAME_MAX_LEN]; + +int +rte_lcore_set_name(unsigned int lcore_id, const char *name) +{ + if (unlikely(lcore_id >= RTE_MAX_LCORE)) + return -EINVAL; + + if (strlen(name) >= RTE_LCORE_NAME_MAX_LEN) + return -ERANGE; + + (void)strcpy(&lcore_names[lcore_id][0], name); + + rte_thread_set_name((rte_thread_t){lcore_config[lcore_id].thread_id}, name); + + return 0; +} + +int +rte_lcore_get_name(unsigned int lcore_id, char *name, size_t len) +{ + if (unlikely(lcore_id >= RTE_MAX_LCORE)) + return -EINVAL; + + if (len < RTE_LCORE_NAME_MAX_LEN) + return -EINVAL; + + (void)strcpy(name, &lcore_names[lcore_id][0]); + + return 0; +} + unsigned int rte_get_main_lcore(void) { return rte_eal_get_configuration()->main_lcore; diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c index c5d8b43..91066e6 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -272,6 +272,7 @@ static void *ctrl_thread_init(void *arg) const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { + rte_thread_t id; struct rte_thread_ctrl_params *params; enum __rte_ctrl_thread_status ctrl_thread_status; int ret; @@ -285,18 +286,16 @@ static void *ctrl_thread_init(void *arg) params->ret = 0; params->ctrl_thread_status = CTRL_THREAD_LAUNCHING; - ret = pthread_create(thread, attr, ctrl_thread_init, (void *)params); + ret = pthread_create((pthread_t *)&id.opaque_id, attr, ctrl_thread_init, params); if (ret != 0) { free(params); return -ret; } - if (name != NULL) { - ret = rte_thread_setname(*thread, name); - if (ret < 0) - RTE_LOG(DEBUG, EAL, - "Cannot set name for ctrl thread\n"); - } + if (name != NULL) + rte_thread_set_name(id, name); + + *thread = (pthread_t)id.opaque_id; /* Wait for the control thread to initialize successfully */ while ((ctrl_thread_status = @@ -312,7 +311,7 @@ static void *ctrl_thread_init(void *arg) /* Check if the control thread encountered an error */ if (ctrl_thread_status == CTRL_THREAD_ERROR) { /* ctrl thread is exiting */ - pthread_join(*thread, NULL); + (void)rte_thread_join(id, NULL); } ret = params->ret; diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index 5caaac8..03c1055 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -356,7 +356,7 @@ rte_trace_mode rte_trace_mode_get(void) /* Store the thread name */ char *name = header->stream_header.thread_name; memset(name, 0, __RTE_TRACE_EMIT_STRING_LEN_MAX); - rte_thread_getname(pthread_self(), name, + (void)rte_lcore_get_name(rte_lcore_id(), name, __RTE_TRACE_EMIT_STRING_LEN_MAX); trace->lcore_meta[count].mem = header; diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 607684c..e6a76de 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -817,7 +817,10 @@ static void rte_eal_init_alert(const char *msg) /* Set thread_name for aid in debugging. */ snprintf(thread_name, sizeof(thread_name), "rte-worker-%d", i); - rte_thread_setname(lcore_config[i].thread_id, thread_name); + ret = rte_lcore_set_name(i, thread_name); + if (ret != 0) + RTE_LOG(DEBUG, EAL, + "Cannot set name for lcore\n"); ret = pthread_setaffinity_np(lcore_config[i].thread_id, sizeof(rte_cpuset_t), &lcore_config[i].cpuset); diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c index ab81b52..af85c48 100644 --- a/lib/eal/freebsd/eal_thread.c +++ b/lib/eal/freebsd/eal_thread.c @@ -32,6 +32,12 @@ int rte_sys_gettid(void) return (int)lwpid; } +void rte_thread_set_name(rte_thread_t id, const char *name) +{ + /* this BSD function returns no error */ + pthread_set_name_np(id.opaque_id, name); +} + int rte_thread_setname(pthread_t id, const char *name) { /* this BSD function returns no error */ diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 6938c3f..251208f 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -25,6 +26,7 @@ #endif #define LCORE_ID_ANY UINT32_MAX /**< Any lcore. */ +#define RTE_LCORE_NAME_MAX_LEN RTE_MAX_THREAD_NAME_LEN RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); /**< Per thread "lcore id". */ @@ -90,6 +92,48 @@ enum rte_lcore_role_t { unsigned int rte_get_main_lcore(void); /** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Sets the name of an lcore and (if supported) implicitly sets the + * debugging name of the lcores thread. + * + * @param lcore_id + * The targeted lcore. + * + * @param name + * The name to set for the specified lcore_id. strlen(name) shall be + * no more than RTE_LCORE_NAME_MAX_LEN - 1 long. + * + * @return + * 0 on success or, -errno on failure. + */ +__rte_experimental +int rte_lcore_set_name(unsigned int lcore_id, const char *name); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Gets the name of an lcore thread. + * + * @param lcore_id + * The targeted lcore. + * + * @param name + * The buffer used to receive the lcore name. + * + * @param len + * The length of the buffer name. The buffer len shall be at + * least RTE_LCORE_NAME_MAX_LEN. + * + * @return + * 0 on success or, -errno on failure. + */ +__rte_experimental +int rte_lcore_get_name(unsigned int lcore_id, char *name, size_t len); + +/** * Return the number of execution units (lcores) on the system. * * @return diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index b9edf70..713330c 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -143,6 +143,14 @@ int rte_thread_create(rte_thread_t *thread_id, rte_thread_t rte_thread_self(void); /** + * @internal + * Set the name of the thread. + */ +__rte_internal +void +rte_thread_set_name(rte_thread_t id, const char *name); + +/** * @warning * @b EXPERIMENTAL: this API may change without prior notice. * diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 8c118d0..97e2fec 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1255,11 +1255,10 @@ static void rte_eal_init_alert(const char *msg) /* Set thread_name for aid in debugging. */ snprintf(thread_name, sizeof(thread_name), "rte-worker-%d", i); - ret = rte_thread_setname(lcore_config[i].thread_id, - thread_name); + ret = rte_lcore_set_name(i, thread_name); if (ret != 0) RTE_LOG(DEBUG, EAL, - "Cannot set name for lcore thread\n"); + "Cannot set name for lcore\n"); ret = pthread_setaffinity_np(lcore_config[i].thread_id, sizeof(rte_cpuset_t), &lcore_config[i].cpuset); diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c index 625bde6..2413bc6 100644 --- a/lib/eal/linux/eal_thread.c +++ b/lib/eal/linux/eal_thread.c @@ -10,6 +10,7 @@ #include #include +#include #include /* require calling thread tid by gettid() */ @@ -18,6 +19,24 @@ int rte_sys_gettid(void) return (int)syscall(SYS_gettid); } +void rte_thread_set_name(rte_thread_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.opaque_id, truncated); +#endif +#endif + RTE_SET_USED(id); + RTE_SET_USED(name); + + if (ret != 0) + RTE_LOG(DEBUG, EAL, "Cannot set thread name\n"); +} + int rte_thread_setname(pthread_t id, const char *name) { int ret = ENOSYS; diff --git a/lib/eal/version.map b/lib/eal/version.map index 7ad12a7..4110f75 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -440,6 +440,10 @@ EXPERIMENTAL { rte_thread_detach; rte_thread_equal; rte_thread_join; + + # added in 23.03 + rte_lcore_get_name; + rte_lcore_set_name; }; INTERNAL { @@ -483,4 +487,5 @@ INTERNAL { rte_mem_map; rte_mem_page_size; rte_mem_unmap; + rte_thread_set_name; }; diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c index 1c1e9d0..51028ef 100644 --- a/lib/eal/windows/rte_thread.c +++ b/lib/eal/windows/rte_thread.c @@ -4,7 +4,9 @@ */ #include +#include +#include #include #include #include @@ -305,6 +307,45 @@ struct thread_routine_ctx { return thread_id; } +void +rte_thread_set_name(rte_thread_t id, const char *name) +{ + int ret = 0; + wchar_t wname[RTE_MAX_THREAD_NAME_LEN]; + mbstate_t state = {0}; + size_t rv; + HANDLE thread_handle; + + thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, id.opaque_id); + if (thread_handle == NULL) { + ret = thread_log_last_error("OpenThread()"); + goto cleanup; + } + + rv = mbsrtowcs(wname, &name, sizeof(wname) / sizeof(wname[0]), &state); + if (rv == (size_t)-1) { + ret = EILSEQ; + goto cleanup; + } + + if (name != NULL) { + ret = ERANGE; + goto cleanup; + } + + if (FAILED(SetThreadDescription(thread_handle, wname))) { + ret = EINVAL; + goto cleanup; + } + +cleanup: + if (thread_handle != NULL) + CloseHandle(thread_handle); + + if (ret != 0) + RTE_LOG(DEBUG, EAL, "Cannot set name for lcore\n"); +} + int rte_thread_get_priority(rte_thread_t thread_id, enum rte_thread_priority *priority) From patchwork Wed Dec 7 19:00:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 120536 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 6B214A00C3; Wed, 7 Dec 2022 20:00:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D91B42D1D; Wed, 7 Dec 2022 20:00:21 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DAE51410FB for ; Wed, 7 Dec 2022 20:00:19 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 353D920B83E5; Wed, 7 Dec 2022 11:00:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 353D920B83E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670439619; bh=Em4fUYC6ZCDwSrQGlc2E3eKzdYj/rxPsPWp+7LAFo+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5iuChtXBgSGRRCXhoU2BChuY9W064Kk9kjxrPvZMPAEG/moUDBRUVLyz+zIvYilD DbcDJsnAYC7g65UVEibv1G+F21qUqT0NSvOp0FBf48PZhVyzUmHip7ytVCH9eb5Itq qcXEH3RpbJRLXd8Rhav+bELsE717Krgp8XGukXIU= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, olivier.matz@6wind.com, stephen@networkplumber.org, Tyler Retzlaff Subject: [PATCH 2/5] eal: set lcore config thread for lcore main Date: Wed, 7 Dec 2022 11:00:14 -0800 Message-Id: <1670439617-9054-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> References: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> 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 Set the lcore_config[].thread_id for lcore_main during initialization. This allows the new rte_lcore_{set,get}_name() APIs to work with lcore_main consistent with other worker lcores. Signed-off-by: Tyler Retzlaff --- lib/eal/common/eal_common_thread.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c index 91066e6..fb1dfc9 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -151,6 +151,9 @@ unsigned rte_socket_id(void) /* acquire system unique id */ rte_gettid(); + if (lcore_id == rte_get_main_lcore()) + lcore_config[lcore_id].thread_id = + (pthread_t)(rte_thread_self()).opaque_id; thread_update_affinity(cpuset); From patchwork Wed Dec 7 19:00:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 120537 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 6284CA00C3; Wed, 7 Dec 2022 20:00:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75AFA42D2C; Wed, 7 Dec 2022 20:00:22 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E0B9E41611 for ; Wed, 7 Dec 2022 20:00:19 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 41E3F20B83E7; Wed, 7 Dec 2022 11:00:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 41E3F20B83E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670439619; bh=abDnkdqhU+B0VkAyIXFOG20TAXQsjHYao1QsSnBwsbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kICSShHSULzPYvfeVCiunmYpt0+G5JwW/ofZv/WFtObooeA51/B8bcW/anrva2+tO I/VpRedvNvjhjQZBlmf7JrLSJUbDJMG1tINnbWrjCzgSmkqHzsIYtHPYJtH3XrE42K 6aVKm7xd8SxIOEhIwXi+p9maWLySaZcacI64vEEE= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, olivier.matz@6wind.com, stephen@networkplumber.org, Tyler Retzlaff Subject: [PATCH 3/5] test: add a unit test for set and get lcore name APIs Date: Wed, 7 Dec 2022 11:00:15 -0800 Message-Id: <1670439617-9054-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> References: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> 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 Signed-off-by: Tyler Retzlaff --- app/test/test_lcores.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index a6bb412..153b6f4 100644 --- a/app/test/test_lcores.c +++ b/app/test/test_lcores.c @@ -379,6 +379,55 @@ static void *ctrl_thread_loop(void *arg) } static int +test_lcores_set_get_name(void) +{ + char out[RTE_LCORE_NAME_MAX_LEN]; + char outcmp[RTE_LCORE_NAME_MAX_LEN]; + const unsigned int lcore_id = rte_get_main_lcore(); + const size_t outlen = sizeof(out); + const char empty[] = ""; + const char valid[] = "0123456789abcde"; + const char invalid[] = "0123456789abcdef"; + + memset(outcmp, 0xff, outlen); + + memset(out, 0xff, outlen); + RTE_TEST_ASSERT(rte_lcore_set_name(lcore_id, empty) == 0, + "Failed to set empty lcore name."); + RTE_TEST_ASSERT(rte_lcore_get_name(lcore_id, out, outlen) == 0, + "Failed to get empty lcore name."); + RTE_TEST_ASSERT(strcmp(empty, out) == 0, + "Failed to set and get empty lcore name."); + + memset(out, 0xff, outlen); + RTE_TEST_ASSERT(rte_lcore_set_name(lcore_id, valid) == 0, + "Failed to set valid lcore name."); + RTE_TEST_ASSERT(rte_lcore_get_name(lcore_id, out, outlen) == 0, + "Failed to get valid lcore name."); + RTE_TEST_ASSERT(strcmp(valid, out) == 0, + "Failed to set and get valid lcore name."); + + memset(out, 0xff, outlen); + RTE_TEST_ASSERT(rte_lcore_set_name(lcore_id, invalid) == -ERANGE, + "Failed to fail set with invalid lcore name."); + RTE_TEST_ASSERT(memcmp(outcmp, out, outlen) == 0, + "Failed to preserve caller buffer after set failure."); + + RTE_TEST_ASSERT(rte_lcore_get_name(lcore_id, out, outlen) == 0, + "Failed to get valid lcore name after set failure."); + RTE_TEST_ASSERT(strcmp(valid, out) == 0, + "Failed to preserve valid lcore name after set failure."); + + memset(out, 0xff, outlen); + RTE_TEST_ASSERT(rte_lcore_get_name(lcore_id, out, outlen - 1) == -EINVAL, + "Failed to fail get with output buffer too small."); + RTE_TEST_ASSERT(memcmp(outcmp, out, outlen) == 0, + "Failed to preserve caller buffer after get failure."); + + return TEST_SUCCESS; +} + +static int test_lcores(void) { unsigned int eal_threads_count = 0; @@ -411,6 +460,9 @@ static void *ctrl_thread_loop(void *arg) if (test_ctrl_thread() < 0) return TEST_FAILED; + if (test_lcores_set_get_name() < 0) + return TEST_FAILED; + return TEST_SUCCESS; } From patchwork Wed Dec 7 19:00:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 120539 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 34119A00C3; Wed, 7 Dec 2022 20:00:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 513A042D3B; Wed, 7 Dec 2022 20:00:24 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id F24954161A for ; Wed, 7 Dec 2022 20:00:19 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4EFB420B83EE; Wed, 7 Dec 2022 11:00:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4EFB420B83EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670439619; bh=jX1W/HbYKnZO39+t6y5/N1/5vWIdAj5Tr2Lh+Idb1uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V9VV6YWbQusV9RJRyPHmaez7p5f5o9OGXlzUQhP1f/4DDi+31EOE34uRke+khzdFl nWavtMbJ/N7beodvFITofzjSObOBCVvH8UJhztFtkdCipldGmcn2zJuwdyX074YfvN WpMMP+icPCR77rdc3WM8FOBGiONsNDrLb8o4HzpA= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, olivier.matz@6wind.com, stephen@networkplumber.org, Tyler Retzlaff Subject: [PATCH 4/5] eal: remove thread getname API Date: Wed, 7 Dec 2022 11:00:16 -0800 Message-Id: <1670439617-9054-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> References: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> 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 Remove the rte_thread_getname API. The API is __rte_experimental and requires no deprecation notice. Signed-off-by: Tyler Retzlaff --- lib/eal/freebsd/eal_thread.c | 9 --------- lib/eal/include/rte_lcore.h | 17 ----------------- lib/eal/linux/eal_thread.c | 15 --------------- lib/eal/version.map | 1 - 4 files changed, 42 deletions(-) diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c index af85c48..7d72c18 100644 --- a/lib/eal/freebsd/eal_thread.c +++ b/lib/eal/freebsd/eal_thread.c @@ -44,12 +44,3 @@ int rte_thread_setname(pthread_t id, const char *name) pthread_set_name_np(id, name); return 0; } - -int rte_thread_getname(pthread_t id, char *name, size_t len) -{ - RTE_SET_USED(id); - RTE_SET_USED(name); - RTE_SET_USED(len); - - return -ENOTSUP; -} diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 251208f..944d89e 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -396,23 +396,6 @@ enum rte_lcore_role_t { int rte_thread_setname(pthread_t id, const char *name); /** - * Get thread name. - * - * @note It fails with glibc < 2.12. - * - * @param id - * Thread id. - * @param name - * Thread name to set. - * @param len - * Thread name buffer length. - * @return - * On success, return 0; otherwise return a negative value. - */ -__rte_experimental -int rte_thread_getname(pthread_t id, char *name, size_t len); - -/** * Register current non-EAL thread as a lcore. * * @note This API is not compatible with the multi-process feature: diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c index 2413bc6..5f56650 100644 --- a/lib/eal/linux/eal_thread.c +++ b/lib/eal/linux/eal_thread.c @@ -52,18 +52,3 @@ int rte_thread_setname(pthread_t id, const char *name) RTE_SET_USED(name); return -ret; } - -int rte_thread_getname(pthread_t id, char *name, size_t len) -{ - int ret = ENOSYS; -#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) -#if __GLIBC_PREREQ(2, 12) - ret = pthread_getname_np(id, name, len); -#endif -#endif - RTE_SET_USED(id); - RTE_SET_USED(name); - RTE_SET_USED(len); - return -ret; - -} diff --git a/lib/eal/version.map b/lib/eal/version.map index 4110f75..6881d19 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -369,7 +369,6 @@ EXPERIMENTAL { __rte_trace_point_register; per_lcore_trace_mem; per_lcore_trace_point_sz; - rte_thread_getname; # WINDOWS_NO_EXPORT rte_trace_dump; # WINDOWS_NO_EXPORT rte_trace_is_enabled; # WINDOWS_NO_EXPORT rte_trace_metadata_dump; # WINDOWS_NO_EXPORT From patchwork Wed Dec 7 19:00:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 120540 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 D2FD6A00C3; Wed, 7 Dec 2022 20:00:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 44DC042D40; Wed, 7 Dec 2022 20:00:25 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9CE5940156 for ; Wed, 7 Dec 2022 20:00:20 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5B6B420B83F0; Wed, 7 Dec 2022 11:00:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5B6B420B83F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670439619; bh=uz+9QIaiijNUtXz7U/fiuu1nAIug/MnKc7tKxjBXfB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9gGr5iyF+j0M1sQpWB2tKEY7kneF5LV9IMEtdeYgEbfW02Lpsw7trsU/Q8cNHLq5 OTdD/T/LN5/nq5LyyTLgcS3R4kiCfiRB6f8P9DORY+yPLYYjb5ae7f6WmSXKLq2gBe zBMNn2UaCbnWaeF/iAIGm/JJGZWqM3evt4oQYvZ8= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com, olivier.matz@6wind.com, stephen@networkplumber.org, Tyler Retzlaff Subject: [PATCH 5/5] eal: deprecate rte thread setname API Date: Wed, 7 Dec 2022 11:00:17 -0800 Message-Id: <1670439617-9054-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> References: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> 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 Notify deprecation of rte_thread_setname API, it is being removed as it exposes platform-specific thread details. The functionality it provided is now implicitly provided via the rte_lcore_set_name API if the underlying platform supports it. Signed-off-by: Tyler Retzlaff --- doc/guides/rel_notes/deprecation.rst | 4 ++++ lib/eal/include/rte_lcore.h | 1 + 2 files changed, 5 insertions(+) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index b9b02dc..b03c935 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -119,3 +119,7 @@ Deprecation Notices Its removal has been postponed to let potential users report interest in maintaining it. In the absence of such interest, this library will be removed in DPDK 23.11. + +* eal: The function ``rte_thread_setname`` will be removed, continuing + the effort to decouple EAL from platform-specific thread + implementations. diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 944d89e..3ca9c52 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -393,6 +393,7 @@ enum rte_lcore_role_t { * @return * On success, return 0; otherwise return a negative value. */ +__rte_deprecated int rte_thread_setname(pthread_t id, const char *name); /**