Thread (36 messages) 36 messages, 6 authors, 2021-02-11

Re: [dpdk-dev] [PATCH v9 2/2] eal: add generic thread-local-storage functions

From: Burakov, Anatoly <hidden>
Date: 2021-02-10 13:33:18

On 06-Jan-21 8:35 PM, Tal Shnaiderman wrote:
Add support for TLS functionality in EAL.

The following functions are added:
rte_thread_tls_key_create - create a TLS data key.
rte_thread_tls_key_delete - delete a TLS data key.
rte_thread_tls_value_set - set value bound to the TLS key
rte_thread_tls_value_get - get value bound to the TLS key

TLS key is defined by the new type rte_tls_key.

The API allocates the thread local storage (TLS) key.
Any thread of the process can subsequently use this key
to store and retrieve values that are local to the thread.

Those functions are added in addition to TLS capability
in rte_per_lcore.h to allow abstraction of the pthread
layer for all operating systems.

Windows implementation is under librte_eal/windows and
implemented using WIN32 API for Windows only.

Unix implementation is under librte_eal/unix and
implemented using pthread for UNIX compilation.

Signed-off-by: Tal Shnaiderman <redacted>
---
I'm a bit late to the party as the patch has been merged already, but 
perhaps as a further enhancement, you could add rte_errno setting for 
errors? You seem to have it only for get() API but not for others, and 
you pass pthread_setspecific()'s return value unmodified, even though it 
might return an error. Presumably, these error codes would be different 
on Unix and Windows, so return values would effectively be potentially 
different on different OS's, so perhaps it's better to return -1 with 
rte_errno to indicate which specific error was seen.

-- 
Thanks,
Anatoly
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help