[dpdk-dev] [PATCH v4 07/17] eal: add rte_gettid() to acquire unique system tid

Olivier MATZ olivier.matz at 6wind.com
Tue Feb 10 18:16:17 CET 2015


Hi,

On 02/10/2015 07:57 AM, Liang, Cunming wrote:
>>> +/**
>>> + * Get system unique thread id.
>>> + *
>>> + * @return
>>> + *   On success, returns the thread ID of calling process.
>>> + *   It always successful.
>>> + */
>>> +static inline int rte_gettid(void)
>>> +{
>>> +	static RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;
>>> +	if (RTE_PER_LCORE(_thread_id) == -1)
>>> +		RTE_PER_LCORE(_thread_id) = rte_sys_gettid();
>>> +	return RTE_PER_LCORE(_thread_id);
>>> +}
>>
>> Instead of doing the test each time rte_gettid() is called, why not
>> having 2 functions:
>>    rte_init_tid() -> assign the per_lcore variable
>>    rte_gettid() -> return the per_lcore variable
>
> [LCM] The rte_gettid() mainly used in recursive spinlock.
> For non-EAL thread, we don't expect new user thread has to explicit call something.
> The purpose to call it in EAL thread init, is to lower down the overhead of the first calling for EAL thread.

Got it. So that's fine like you proposed.

Olivier



More information about the dev mailing list