From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D27F4A0579; Wed, 18 Mar 2020 20:02:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 21C7D1BF82; Wed, 18 Mar 2020 20:02:16 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 637292C28 for ; Wed, 18 Mar 2020 20:02:14 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02IJ1Qgc019385; Wed, 18 Mar 2020 12:02:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=UoJXm3fTVz14nw3TNUvWrPFW5H/t7IbgHLrKZogimag=; b=dehUKleJJQDvLZjbKVq+IwRwLJR1BjIEZktISgUUUVWGnXg+0MzCTPnOZ5DL6cnu89rJ HC6TYtV6kL7R3cw/Dun7U4ZhYDBHEvNrQCLjaSvsCHQxqK8T4gO8pYL16+PiYke5FreV XWJe/IuzzzckujmLsSg1rsLbU6bVAFucGKWkIMpRODgS+n+3llZgNiv40JQY7Te+AhBU 64JBPTtwqgDZzuH+51lwn8bnitE5UqKvGKoJVfo4Df7uVnLaDoT2Ms+s2Wh8Tht+KGZ6 oykHM6h7BT7BcPBBXLLohaWFQsuOPdKusZMG0O6thXnGsYbs1V6wDV7qevpIhNZyKFdI 6w== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rpbret-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 12:02:13 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 12:02:11 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 12:02:10 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 18 Mar 2020 12:02:10 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 46AA33F703F; Wed, 18 Mar 2020 12:02:08 -0700 (PDT) From: To: Bruce Richardson CC: , , , , , Jerin Jacob Date: Thu, 19 Mar 2020 00:32:10 +0530 Message-ID: <20200318190241.3150971-2-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318190241.3150971-1-jerinj@marvell.com> References: <20200318190241.3150971-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_07:2020-03-18, 2020-03-18 signatures=0 Subject: [dpdk-dev] [PATCH v1 01/32] eal: introduce API for getting thread name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jerin Jacob Introduce rte_thread_getname() API to get the thread name and implement it for Linux and FreeBSD. FreeBSD does not support getting the thread name. One of the consumers of this API will be the trace subsystem where it used as an informative purpose. Signed-off-by: Jerin Jacob --- lib/librte_eal/common/include/rte_lcore.h | 17 +++++++++++++++++ lib/librte_eal/freebsd/eal/eal_thread.c | 9 +++++++++ lib/librte_eal/linux/eal/eal_thread.c | 15 +++++++++++++++ lib/librte_eal/rte_eal_version.map | 3 +++ 4 files changed, 44 insertions(+) diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index 476b8ef3a..339046bc8 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -240,6 +240,23 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); */ 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); + /** * Create a control thread. * diff --git a/lib/librte_eal/freebsd/eal/eal_thread.c b/lib/librte_eal/freebsd/eal/eal_thread.c index 309b58726..ae7b57672 100644 --- a/lib/librte_eal/freebsd/eal/eal_thread.c +++ b/lib/librte_eal/freebsd/eal/eal_thread.c @@ -175,3 +175,12 @@ 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/librte_eal/linux/eal/eal_thread.c b/lib/librte_eal/linux/eal/eal_thread.c index 379773b68..3f82b286c 100644 --- a/lib/librte_eal/linux/eal/eal_thread.c +++ b/lib/librte_eal/linux/eal/eal_thread.c @@ -186,3 +186,18 @@ 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/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 6cf507068..cadfa6465 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -335,4 +335,7 @@ EXPERIMENTAL { # added in 20.02 rte_thread_is_intr; + + # added in 20.05 + rte_thread_getname; }; -- 2.25.1