From 7d1af09e9857c7854bea1d7cae38feb212a8defd Mon Sep 17 00:00:00 2001 From: David Marchand Date: Fri, 10 Jul 2020 11:45:50 +0200 Subject: [PATCH 1/1] eal/linux: truncate thread name pthread_setname_np refuses names larger than 16 bytes (\0 included). Rather than return an error, truncate the name to this limit in the rte_thread_setname helper. Caught with ixgbe which creates control thread with name "ixgbe-link-handler": Configuring Port 0 (socket 0) EAL: Cannot set name for ctrl thread ... EAL: Cannot set name for ctrl thread Port 0: link state change event ... EAL: Cannot set name for ctrl thread Port 0: link state change event Note: before this change, the thread would keep its original name, which meant in my test for the ixgbe handler either "dpdk-testpmd" or "eal-intr-thread". Signed-off-by: David Marchand Acked-by: Thomas Monjalon --- lib/librte_eal/linux/eal_thread.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linux/eal_thread.c b/lib/librte_eal/linux/eal_thread.c index 48a2c1124b..068de25595 100644 --- a/lib/librte_eal/linux/eal_thread.c +++ b/lib/librte_eal/linux/eal_thread.c @@ -153,7 +153,10 @@ int rte_thread_setname(pthread_t id, const char *name) int ret = ENOSYS; #if defined(__GLIBC__) && defined(__GLIBC_PREREQ) #if __GLIBC_PREREQ(2, 12) - ret = pthread_setname_np(id, name); + char truncated[16]; + + strlcpy(truncated, name, sizeof(truncated)); + ret = pthread_setname_np(id, truncated); #endif #endif RTE_SET_USED(id); -- 2.20.1