[dpdk-dev,v3,3/5] eal: set name when creating a control thread

Message ID 20180424144651.13145-4-olivier.matz@6wind.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Olivier Matz April 24, 2018, 2:46 p.m. UTC
  To avoid code duplication, add a parameter to rte_ctrl_thread_create()
to specify the name of the thread.

This requires to add a wrapper for the thread start routine in
rte_thread_init(), which will first wait that the thread is configured.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/kni/rte_eth_kni.c                |  3 +-
 lib/librte_eal/common/eal_common_proc.c      | 15 +++-----
 lib/librte_eal/common/eal_common_thread.c    | 52 +++++++++++++++++++++++++---
 lib/librte_eal/common/include/rte_lcore.h    |  7 ++--
 lib/librte_eal/linuxapp/eal/eal_interrupts.c | 13 ++-----
 lib/librte_eal/linuxapp/eal/eal_timer.c      | 12 +------
 lib/librte_vhost/socket.c                    | 25 +++----------
 7 files changed, 66 insertions(+), 61 deletions(-)
  

Comments

Anatoly Burakov April 24, 2018, 4:08 p.m. UTC | #1
On 24-Apr-18 3:46 PM, Olivier Matz wrote:
> To avoid code duplication, add a parameter to rte_ctrl_thread_create()
> to specify the name of the thread.
> 
> This requires to add a wrapper for the thread start routine in
> rte_thread_init(), which will first wait that the thread is configured.
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---

For IPC/thread parts,

Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Jianfeng Tan April 27, 2018, 3:46 p.m. UTC | #2
Hi Olivier,

After this patch, I find the two IPC threads block at 
pthread_barrier_wait(), and never wake up. Please refer below for more 
information. The system is Ubuntu 16.04.

On 4/24/2018 10:46 PM, Olivier Matz wrote:
> To avoid code duplication, add a parameter to rte_ctrl_thread_create()
> to specify the name of the thread.
>
> This requires to add a wrapper for the thread start routine in
> rte_thread_init(), which will first wait that the thread is configured.
>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>   drivers/net/kni/rte_eth_kni.c                |  3 +-
>   lib/librte_eal/common/eal_common_proc.c      | 15 +++-----
>   lib/librte_eal/common/eal_common_thread.c    | 52 +++++++++++++++++++++++++---
>   lib/librte_eal/common/include/rte_lcore.h    |  7 ++--
>   lib/librte_eal/linuxapp/eal/eal_interrupts.c | 13 ++-----
>   lib/librte_eal/linuxapp/eal/eal_timer.c      | 12 +------
>   lib/librte_vhost/socket.c                    | 25 +++----------
>   7 files changed, 66 insertions(+), 61 deletions(-)
[...]
> diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c
> index efbccddbc..94d2a6e42 100644
> --- a/lib/librte_eal/common/eal_common_thread.c
> +++ b/lib/librte_eal/common/eal_common_thread.c
> @@ -7,6 +7,7 @@
>   #include <stdint.h>
>   #include <unistd.h>
>   #include <pthread.h>
> +#include <signal.h>
>   #include <sched.h>
>   #include <assert.h>
>   #include <string.h>
> @@ -141,10 +142,53 @@ eal_thread_dump_affinity(char *str, unsigned size)
>   	return ret;
>   }
>   
> +
> +struct rte_thread_ctrl_params {
> +	void *(*start_routine)(void *);
> +	void *arg;
> +	pthread_barrier_t configured;
> +};
> +
> +static void *rte_thread_init(void *arg)
> +{
> +	struct rte_thread_ctrl_params *params = arg;
> +	void *(*start_routine)(void *) = params->start_routine;
> +	void *routine_arg = params->arg;
> +
> +	pthread_barrier_wait(&params->configured);

This thread never wakes up. The call trace as below:

#0  0x00007ffff72a8154 in futex_wait (private=0, expected=0, 
futex_word=0x7fffffffcff4)
     at ../sysdeps/unix/sysv/linux/futex-internal.h:61
#1  futex_wait_simple (private=0, expected=0, futex_word=0x7fffffffcff4) 
at ../sysdeps/nptl/futex-internal.h:135
#2  __pthread_barrier_wait (barrier=0x7fffffffcff0) at 
pthread_barrier_wait.c:184
#3  0x000000000055216a in rte_thread_init (arg=0x7fffffffcfe0) at 
/home/tan/git/dpdk/lib/librte_eal/common/eal_common_thread.c:160
#4  0x00007ffff72a16ba in start_thread (arg=0x7ffff6ecf700) at 
pthread_create.c:333
#5  0x00007ffff6fd741d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:109

> +
> +	return start_routine(routine_arg);
> +}
> +
>   __rte_experimental int
> -rte_ctrl_thread_create(pthread_t *thread,
> -			const pthread_attr_t *attr,
> -			void *(*start_routine)(void *), void *arg)
> +rte_ctrl_thread_create(pthread_t *thread, const char *name,
> +		const pthread_attr_t *attr,
> +		void *(*start_routine)(void *), void *arg)
>   {
> -	return pthread_create(thread, attr, start_routine, arg);
> +	struct rte_thread_ctrl_params params = {
> +		.start_routine = start_routine,
> +		.arg = arg,
> +	};
> +	int ret;
> +
> +	pthread_barrier_init(&params.configured, NULL, 2);
> +
> +	ret = pthread_create(thread, attr, rte_thread_init, (void *)&params);
> +	if (ret != 0)
> +		return ret;
> +
> +	if (name != NULL) {
> +		ret = rte_thread_setname(*thread, name);
> +		if (ret < 0)
> +			goto fail;
> +	}
> +
> +	pthread_barrier_wait(&params.configured);

Here, the thread wakes up normally, and continues.

Any idea on what's going on?

Thanks,
Jianfeng

> +
> +	return 0;
> +
> +fail:
> +	pthread_cancel(*thread);
> +	pthread_join(*thread, NULL);
> +	return ret;
>   }
  
Jianfeng Tan April 27, 2018, 4:17 p.m. UTC | #3
On 4/27/2018 11:46 PM, Tan, Jianfeng wrote:
> Hi Olivier,
>
> After this patch, I find the two IPC threads block at 
> pthread_barrier_wait(), and never wake up. Please refer below for more 
> information. The system is Ubuntu 16.04.
>
> On 4/24/2018 10:46 PM, Olivier Matz wrote:
>> To avoid code duplication, add a parameter to rte_ctrl_thread_create()
>> to specify the name of the thread.
>>
>> This requires to add a wrapper for the thread start routine in
>> rte_thread_init(), which will first wait that the thread is configured.
>>
>> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
>> ---
>>   drivers/net/kni/rte_eth_kni.c                |  3 +-
>>   lib/librte_eal/common/eal_common_proc.c      | 15 +++-----
>>   lib/librte_eal/common/eal_common_thread.c    | 52 
>> +++++++++++++++++++++++++---
>>   lib/librte_eal/common/include/rte_lcore.h    |  7 ++--
>>   lib/librte_eal/linuxapp/eal/eal_interrupts.c | 13 ++-----
>>   lib/librte_eal/linuxapp/eal/eal_timer.c      | 12 +------
>>   lib/librte_vhost/socket.c                    | 25 +++----------
>>   7 files changed, 66 insertions(+), 61 deletions(-)
> [...]
>> diff --git a/lib/librte_eal/common/eal_common_thread.c 
>> b/lib/librte_eal/common/eal_common_thread.c
>> index efbccddbc..94d2a6e42 100644
>> --- a/lib/librte_eal/common/eal_common_thread.c
>> +++ b/lib/librte_eal/common/eal_common_thread.c
>> @@ -7,6 +7,7 @@
>>   #include <stdint.h>
>>   #include <unistd.h>
>>   #include <pthread.h>
>> +#include <signal.h>
>>   #include <sched.h>
>>   #include <assert.h>
>>   #include <string.h>
>> @@ -141,10 +142,53 @@ eal_thread_dump_affinity(char *str, unsigned size)
>>       return ret;
>>   }
>>   +
>> +struct rte_thread_ctrl_params {
>> +    void *(*start_routine)(void *);
>> +    void *arg;
>> +    pthread_barrier_t configured;
>> +};
>> +
>> +static void *rte_thread_init(void *arg)
>> +{
>> +    struct rte_thread_ctrl_params *params = arg;
>> +    void *(*start_routine)(void *) = params->start_routine;
>> +    void *routine_arg = params->arg;
>> +
>> +    pthread_barrier_wait(&params->configured);
>
> This thread never wakes up. The call trace as below:
>
> #0  0x00007ffff72a8154 in futex_wait (private=0, expected=0, 
> futex_word=0x7fffffffcff4)
>     at ../sysdeps/unix/sysv/linux/futex-internal.h:61
> #1  futex_wait_simple (private=0, expected=0, 
> futex_word=0x7fffffffcff4) at ../sysdeps/nptl/futex-internal.h:135
> #2  __pthread_barrier_wait (barrier=0x7fffffffcff0) at 
> pthread_barrier_wait.c:184
> #3  0x000000000055216a in rte_thread_init (arg=0x7fffffffcfe0) at 
> /home/tan/git/dpdk/lib/librte_eal/common/eal_common_thread.c:160
> #4  0x00007ffff72a16ba in start_thread (arg=0x7ffff6ecf700) at 
> pthread_create.c:333
> #5  0x00007ffff6fd741d in clone () at 
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
>
>> +
>> +    return start_routine(routine_arg);
>> +}
>> +
>>   __rte_experimental int
>> -rte_ctrl_thread_create(pthread_t *thread,
>> -            const pthread_attr_t *attr,
>> -            void *(*start_routine)(void *), void *arg)
>> +rte_ctrl_thread_create(pthread_t *thread, const char *name,
>> +        const pthread_attr_t *attr,
>> +        void *(*start_routine)(void *), void *arg)
>>   {
>> -    return pthread_create(thread, attr, start_routine, arg);
>> +    struct rte_thread_ctrl_params params = {
>> +        .start_routine = start_routine,
>> +        .arg = arg,
>> +    };

Update:

I doubt it's due to that we defined this variable, params, on the stack; 
and the value seems be overwritten by following code. Will send a patch 
to fix it.

Thanks,
Jianfeng


>> +    int ret;
>> +
>> +    pthread_barrier_init(&params.configured, NULL, 2);
>> +
>> +    ret = pthread_create(thread, attr, rte_thread_init, (void 
>> *)&params);
>> +    if (ret != 0)
>> +        return ret;
>> +
>> +    if (name != NULL) {
>> +        ret = rte_thread_setname(*thread, name);
>> +        if (ret < 0)
>> +            goto fail;
>> +    }
>> +
>> +    pthread_barrier_wait(&params.configured);
>
> Here, the thread wakes up normally, and continues.
>
> Any idea on what's going on?
>
> Thanks,
> Jianfeng
>
>> +
>> +    return 0;
>> +
>> +fail:
>> +    pthread_cancel(*thread);
>> +    pthread_join(*thread, NULL);
>> +    return ret;
>>   }
>
  
Anatoly Burakov April 27, 2018, 4:46 p.m. UTC | #4
On 27-Apr-18 5:17 PM, Tan, Jianfeng wrote:
> 
> 
> On 4/27/2018 11:46 PM, Tan, Jianfeng wrote:
>> Hi Olivier,
>>
>> After this patch, I find the two IPC threads block at 
>> pthread_barrier_wait(), and never wake up. Please refer below for more 
>> information. The system is Ubuntu 16.04.
>>
>> On 4/24/2018 10:46 PM, Olivier Matz wrote:
>>> To avoid code duplication, add a parameter to rte_ctrl_thread_create()
>>> to specify the name of the thread.
>>>
>>> This requires to add a wrapper for the thread start routine in
>>> rte_thread_init(), which will first wait that the thread is configured.
>>>
>>> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
>>> ---
>>>   drivers/net/kni/rte_eth_kni.c                |  3 +-
>>>   lib/librte_eal/common/eal_common_proc.c      | 15 +++-----
>>>   lib/librte_eal/common/eal_common_thread.c    | 52 
>>> +++++++++++++++++++++++++---
>>>   lib/librte_eal/common/include/rte_lcore.h    |  7 ++--
>>>   lib/librte_eal/linuxapp/eal/eal_interrupts.c | 13 ++-----
>>>   lib/librte_eal/linuxapp/eal/eal_timer.c      | 12 +------
>>>   lib/librte_vhost/socket.c                    | 25 +++----------
>>>   7 files changed, 66 insertions(+), 61 deletions(-)
>> [...]
>>> diff --git a/lib/librte_eal/common/eal_common_thread.c 
>>> b/lib/librte_eal/common/eal_common_thread.c
>>> index efbccddbc..94d2a6e42 100644
>>> --- a/lib/librte_eal/common/eal_common_thread.c
>>> +++ b/lib/librte_eal/common/eal_common_thread.c
>>> @@ -7,6 +7,7 @@
>>>   #include <stdint.h>
>>>   #include <unistd.h>
>>>   #include <pthread.h>
>>> +#include <signal.h>
>>>   #include <sched.h>
>>>   #include <assert.h>
>>>   #include <string.h>
>>> @@ -141,10 +142,53 @@ eal_thread_dump_affinity(char *str, unsigned size)
>>>       return ret;
>>>   }
>>>   +
>>> +struct rte_thread_ctrl_params {
>>> +    void *(*start_routine)(void *);
>>> +    void *arg;
>>> +    pthread_barrier_t configured;
>>> +};
>>> +
>>> +static void *rte_thread_init(void *arg)
>>> +{
>>> +    struct rte_thread_ctrl_params *params = arg;
>>> +    void *(*start_routine)(void *) = params->start_routine;
>>> +    void *routine_arg = params->arg;
>>> +
>>> +    pthread_barrier_wait(&params->configured);
>>
>> This thread never wakes up. The call trace as below:
>>
>> #0  0x00007ffff72a8154 in futex_wait (private=0, expected=0, 
>> futex_word=0x7fffffffcff4)
>>     at ../sysdeps/unix/sysv/linux/futex-internal.h:61
>> #1  futex_wait_simple (private=0, expected=0, 
>> futex_word=0x7fffffffcff4) at ../sysdeps/nptl/futex-internal.h:135
>> #2  __pthread_barrier_wait (barrier=0x7fffffffcff0) at 
>> pthread_barrier_wait.c:184
>> #3  0x000000000055216a in rte_thread_init (arg=0x7fffffffcfe0) at 
>> /home/tan/git/dpdk/lib/librte_eal/common/eal_common_thread.c:160
>> #4  0x00007ffff72a16ba in start_thread (arg=0x7ffff6ecf700) at 
>> pthread_create.c:333
>> #5  0x00007ffff6fd741d in clone () at 
>> ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
>>
>>> +
>>> +    return start_routine(routine_arg);
>>> +}
>>> +
>>>   __rte_experimental int
>>> -rte_ctrl_thread_create(pthread_t *thread,
>>> -            const pthread_attr_t *attr,
>>> -            void *(*start_routine)(void *), void *arg)
>>> +rte_ctrl_thread_create(pthread_t *thread, const char *name,
>>> +        const pthread_attr_t *attr,
>>> +        void *(*start_routine)(void *), void *arg)
>>>   {
>>> -    return pthread_create(thread, attr, start_routine, arg);
>>> +    struct rte_thread_ctrl_params params = {
>>> +        .start_routine = start_routine,
>>> +        .arg = arg,
>>> +    };
> 
> Update:
> 
> I doubt it's due to that we defined this variable, params, on the stack; 
> and the value seems be overwritten by following code. Will send a patch 
> to fix it.

I'm not sure i follow you, but looking forward to the fix :)

As far as i can tell, even if the variable is on the stack, we're making 
copies of values there before destroying them, so even if param somehow 
got destroyed before the thread had a chance to start, we've already got 
all data we needed from it. I can't see how that value being allocated 
on the stack makes a difference.

Just about the only thing i can see that's slightly wrong here is lack 
of pthread_barrier_destroy(). Perhaps add that as well? :)

> 
> Thanks,
> Jianfeng
> 
> 
>>> +    int ret;
>>> +
>>> +    pthread_barrier_init(&params.configured, NULL, 2);
>>> +
>>> +    ret = pthread_create(thread, attr, rte_thread_init, (void 
>>> *)&params);
>>> +    if (ret != 0)
>>> +        return ret;
>>> +
>>> +    if (name != NULL) {
>>> +        ret = rte_thread_setname(*thread, name);
>>> +        if (ret < 0)
>>> +            goto fail;
>>> +    }
>>> +
>>> +    pthread_barrier_wait(&params.configured);
>>
>> Here, the thread wakes up normally, and continues.
>>
>> Any idea on what's going on?
>>
>> Thanks,
>> Jianfeng
>>
>>> +
>>> +    return 0;
>>> +
>>> +fail:
>>> +    pthread_cancel(*thread);
>>> +    pthread_join(*thread, NULL);
>>> +    return ret;
>>>   }
>>
> 
>
  

Patch

diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index fdd592554..35a6d3ef7 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -149,7 +149,8 @@  eth_kni_dev_start(struct rte_eth_dev *dev)
 	}
 
 	if (internals->no_request_thread == 0) {
-		ret = rte_ctrl_thread_create(&internals->thread, NULL,
+		ret = rte_ctrl_thread_create(&internals->thread,
+			"kni_handle_req", NULL,
 			kni_handle_request, internals);
 		if (ret) {
 			RTE_LOG(ERR, PMD,
diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index abaa085c4..611aba299 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -622,7 +622,6 @@  unlink_sockets(const char *filter)
 int
 rte_mp_channel_init(void)
 {
-	char thread_name[RTE_MAX_THREAD_NAME_LEN];
 	char path[PATH_MAX];
 	int dir_fd;
 	pthread_t mp_handle_tid, async_reply_handle_tid;
@@ -662,7 +661,8 @@  rte_mp_channel_init(void)
 		return -1;
 	}
 
-	if (rte_ctrl_thread_create(&mp_handle_tid, NULL, mp_handle, NULL) < 0) {
+	if (rte_ctrl_thread_create(&mp_handle_tid, "rte_mp_handle",
+			NULL, mp_handle, NULL) < 0) {
 		RTE_LOG(ERR, EAL, "failed to create mp thead: %s\n",
 			strerror(errno));
 		close(mp_fd);
@@ -671,7 +671,8 @@  rte_mp_channel_init(void)
 		return -1;
 	}
 
-	if (rte_ctrl_thread_create(&async_reply_handle_tid, NULL,
+	if (rte_ctrl_thread_create(&async_reply_handle_tid,
+			"rte_mp_async", NULL,
 			async_reply_handle, NULL) < 0) {
 		RTE_LOG(ERR, EAL, "failed to create mp thead: %s\n",
 			strerror(errno));
@@ -681,14 +682,6 @@  rte_mp_channel_init(void)
 		return -1;
 	}
 
-	/* try best to set thread name */
-	strlcpy(thread_name, "rte_mp_handle", sizeof(thread_name));
-	rte_thread_setname(mp_handle_tid, thread_name);
-
-	/* try best to set thread name */
-	strlcpy(thread_name, "rte_mp_async_handle", sizeof(thread_name));
-	rte_thread_setname(async_reply_handle_tid, thread_name);
-
 	/* unlock the directory */
 	flock(dir_fd, LOCK_UN);
 	close(dir_fd);
diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c
index efbccddbc..94d2a6e42 100644
--- a/lib/librte_eal/common/eal_common_thread.c
+++ b/lib/librte_eal/common/eal_common_thread.c
@@ -7,6 +7,7 @@ 
 #include <stdint.h>
 #include <unistd.h>
 #include <pthread.h>
+#include <signal.h>
 #include <sched.h>
 #include <assert.h>
 #include <string.h>
@@ -141,10 +142,53 @@  eal_thread_dump_affinity(char *str, unsigned size)
 	return ret;
 }
 
+
+struct rte_thread_ctrl_params {
+	void *(*start_routine)(void *);
+	void *arg;
+	pthread_barrier_t configured;
+};
+
+static void *rte_thread_init(void *arg)
+{
+	struct rte_thread_ctrl_params *params = arg;
+	void *(*start_routine)(void *) = params->start_routine;
+	void *routine_arg = params->arg;
+
+	pthread_barrier_wait(&params->configured);
+
+	return start_routine(routine_arg);
+}
+
 __rte_experimental int
-rte_ctrl_thread_create(pthread_t *thread,
-			const pthread_attr_t *attr,
-			void *(*start_routine)(void *), void *arg)
+rte_ctrl_thread_create(pthread_t *thread, const char *name,
+		const pthread_attr_t *attr,
+		void *(*start_routine)(void *), void *arg)
 {
-	return pthread_create(thread, attr, start_routine, arg);
+	struct rte_thread_ctrl_params params = {
+		.start_routine = start_routine,
+		.arg = arg,
+	};
+	int ret;
+
+	pthread_barrier_init(&params.configured, NULL, 2);
+
+	ret = pthread_create(thread, attr, rte_thread_init, (void *)&params);
+	if (ret != 0)
+		return ret;
+
+	if (name != NULL) {
+		ret = rte_thread_setname(*thread, name);
+		if (ret < 0)
+			goto fail;
+	}
+
+	pthread_barrier_wait(&params.configured);
+
+	return 0;
+
+fail:
+	pthread_cancel(*thread);
+	pthread_join(*thread, NULL);
+	return ret;
 }
diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h
index 30749d0ab..eb39c2a8b 100644
--- a/lib/librte_eal/common/include/rte_lcore.h
+++ b/lib/librte_eal/common/include/rte_lcore.h
@@ -279,10 +279,12 @@  int rte_thread_setname(pthread_t id, const char *name);
 /**
  * Create a control thread.
  *
- * Wrapper to pthread_create().
+ * Wrapper to pthread_create() and pthread_setname_np().
  *
  * @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
@@ -294,7 +296,8 @@  int rte_thread_setname(pthread_t id, const char *name);
  *   corresponding to the error number.
  */
 __rte_experimental int
-rte_ctrl_thread_create(pthread_t *thread, const pthread_attr_t *attr,
+rte_ctrl_thread_create(pthread_t *thread, const char *name,
+		const pthread_attr_t *attr,
 		void *(*start_routine)(void *), void *arg);
 
 /**
diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 9a49ae6a5..056d41c12 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -853,8 +853,7 @@  eal_intr_thread_main(__rte_unused void *arg)
 int
 rte_eal_intr_init(void)
 {
-	int ret = 0, ret_1 = 0;
-	char thread_name[RTE_MAX_THREAD_NAME_LEN];
+	int ret = 0;
 
 	/* init the global interrupt source head */
 	TAILQ_INIT(&intr_sources);
@@ -869,20 +868,12 @@  rte_eal_intr_init(void)
 	}
 
 	/* create the host thread to wait/handle the interrupt */
-	ret = rte_ctrl_thread_create(&intr_thread, NULL,
+	ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
 			eal_intr_thread_main, NULL);
 	if (ret != 0) {
 		rte_errno = -ret;
 		RTE_LOG(ERR, EAL,
 			"Failed to create thread for interrupt handling\n");
-	} else {
-		/* Set thread_name for aid in debugging. */
-		snprintf(thread_name, sizeof(thread_name),
-			"eal-intr-thread");
-		ret_1 = rte_thread_setname(intr_thread, thread_name);
-		if (ret_1 != 0)
-			RTE_LOG(DEBUG, EAL,
-			"Failed to set thread name for interrupt handling\n");
 	}
 
 	return ret;
diff --git a/lib/librte_eal/linuxapp/eal/eal_timer.c b/lib/librte_eal/linuxapp/eal/eal_timer.c
index 6f5d9fee6..2766bd789 100644
--- a/lib/librte_eal/linuxapp/eal/eal_timer.c
+++ b/lib/librte_eal/linuxapp/eal/eal_timer.c
@@ -137,7 +137,6 @@  int
 rte_eal_hpet_init(int make_default)
 {
 	int fd, ret;
-	char thread_name[RTE_MAX_THREAD_NAME_LEN];
 
 	if (internal_config.no_hpet) {
 		RTE_LOG(NOTICE, EAL, "HPET is disabled\n");
@@ -178,7 +177,7 @@  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, NULL,
+	ret = rte_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc", NULL,
 			(void *(*)(void *))hpet_msb_inc, NULL);
 	if (ret != 0) {
 		RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n");
@@ -186,15 +185,6 @@  rte_eal_hpet_init(int make_default)
 		return -1;
 	}
 
-	/*
-	 * Set thread_name for aid in debugging.
-	 */
-	snprintf(thread_name, sizeof(thread_name), "hpet-msb-inc");
-	ret = rte_thread_setname(msb_inc_thread_id, thread_name);
-	if (ret != 0)
-		RTE_LOG(DEBUG, EAL,
-			"Cannot set HPET timer thread name!\n");
-
 	if (make_default)
 		eal_timer_source = EAL_TIMER_HPET;
 	return 0;
diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index db9be6a99..4a561add9 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -467,7 +467,6 @@  static int
 vhost_user_reconnect_init(void)
 {
 	int ret;
-	char thread_name[RTE_MAX_THREAD_NAME_LEN];
 
 	ret = pthread_mutex_init(&reconn_list.mutex, NULL);
 	if (ret < 0) {
@@ -476,7 +475,7 @@  vhost_user_reconnect_init(void)
 	}
 	TAILQ_INIT(&reconn_list.head);
 
-	ret = rte_ctrl_thread_create(&reconn_tid, NULL,
+	ret = rte_ctrl_thread_create(&reconn_tid, "vhost_reconn", NULL,
 			     vhost_user_client_reconnect, NULL);
 	if (ret != 0) {
 		RTE_LOG(ERR, VHOST_CONFIG, "failed to create reconnect thread");
@@ -484,14 +483,6 @@  vhost_user_reconnect_init(void)
 			RTE_LOG(ERR, VHOST_CONFIG,
 				"failed to destroy reconnect mutex");
 		}
-	} else {
-		snprintf(thread_name, sizeof(thread_name),
-			 "vhost-reconn");
-
-		if (rte_thread_setname(reconn_tid, thread_name)) {
-			RTE_LOG(DEBUG, VHOST_CONFIG,
-				"failed to set reconnect thread name");
-		}
 	}
 
 	return ret;
@@ -1000,7 +991,6 @@  rte_vhost_driver_start(const char *path)
 {
 	struct vhost_user_socket *vsocket;
 	static pthread_t fdset_tid;
-	char thread_name[RTE_MAX_THREAD_NAME_LEN];
 
 	pthread_mutex_lock(&vhost_user.mutex);
 	vsocket = find_vhost_user_socket(path);
@@ -1020,22 +1010,15 @@  rte_vhost_driver_start(const char *path)
 			return -1;
 		}
 
-		int ret = rte_ctrl_thread_create(&fdset_tid, NULL,
-			fdset_event_dispatch, &vhost_user.fdset);
+		int ret = rte_ctrl_thread_create(&fdset_tid,
+			"vhost-events", NULL, fdset_event_dispatch,
+			&vhost_user.fdset);
 		if (ret != 0) {
 			RTE_LOG(ERR, VHOST_CONFIG,
 				"failed to create fdset handling thread");
 
 			fdset_pipe_uninit(&vhost_user.fdset);
 			return -1;
-		} else {
-			snprintf(thread_name, sizeof(thread_name),
-				 "vhost-events");
-
-			if (rte_thread_setname(fdset_tid, thread_name)) {
-				RTE_LOG(DEBUG, VHOST_CONFIG,
-					"failed to set vhost-event thread name");
-			}
 		}
 	}