* [dpdk-dev] [PATCH v2 0/2] EAL Thread TLS API enhancements @ 2021-03-02 15:26 Tal Shnaiderman 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 2/2] eal: rename key opaque pointer " Tal Shnaiderman 0 siblings, 2 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-02 15:26 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb Enhancements to the TLS API. --- v2: Rename key to avoid redundancy[MortenB]. --- Tal Shnaiderman (2): eal: error number enhancement for thread TLS API eal: rename key opaque pointer in TLS API drivers/net/mlx5/linux/mlx5_flow_os.c | 2 +- drivers/net/mlx5/windows/mlx5_flow_os.c | 2 +- lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- lib/librte_eal/unix/rte_thread.c | 14 ++++++++++---- lib/librte_eal/windows/rte_thread.c | 16 +++++++++++----- 5 files changed, 33 insertions(+), 20 deletions(-) -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API 2021-03-02 15:26 [dpdk-dev] [PATCH v2 0/2] EAL Thread TLS API enhancements Tal Shnaiderman @ 2021-03-02 15:26 ` Tal Shnaiderman 2021-03-02 17:09 ` Dmitry Kozlyuk 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 2/2] eal: rename key opaque pointer " Tal Shnaiderman 1 sibling, 2 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-02 15:26 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb add error number reporting to rte_errno in all functions in the rte_thread_tls_* API. Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> --- lib/librte_eal/include/rte_thread.h | 6 +++--- lib/librte_eal/unix/rte_thread.c | 6 ++++++ lib/librte_eal/windows/rte_thread.c | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index e640ea1857..39737d1829 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -59,7 +59,7 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. */ __rte_experimental @@ -73,7 +73,7 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. */ __rte_experimental int rte_thread_tls_key_delete(rte_tls_key key); @@ -88,7 +88,7 @@ int rte_thread_tls_key_delete(rte_tls_key key); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. */ __rte_experimental int rte_thread_tls_value_set(rte_tls_key key, const void *value); diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 86ffeebc95..86e42bf653 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -24,6 +24,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } err = pthread_key_create(&((*key)->thread_index), destructor); @@ -31,6 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) RTE_LOG(DEBUG, EAL, "pthread_key_create failed: %s\n", strerror(err)); free(*key); + rte_errno = err; return -1; } return 0; @@ -43,6 +45,7 @@ rte_thread_tls_key_delete(rte_tls_key key) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_key_delete(key->thread_index); @@ -50,6 +53,7 @@ rte_thread_tls_key_delete(rte_tls_key key) RTE_LOG(DEBUG, EAL, "pthread_key_delete failed: %s\n", strerror(err)); free(key); + rte_errno = err; return -1; } free(key); @@ -63,12 +67,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_setspecific(key->thread_index, value); if (err) { RTE_LOG(DEBUG, EAL, "pthread_setspecific failed: %s\n", strerror(err)); + rte_errno = err; return -1; } return 0; diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index 2e2ab29177..1c226b3e30 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -18,12 +18,14 @@ rte_thread_tls_key_create(rte_tls_key *key, *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } (*key)->thread_index = TlsAlloc(); if ((*key)->thread_index == TLS_OUT_OF_INDEXES) { RTE_LOG_WIN32_ERR("TlsAlloc()"); free(*key); + rte_errno = GetLastError(); return -1; } return 0; @@ -34,11 +36,13 @@ rte_thread_tls_key_delete(rte_tls_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } if (!TlsFree(key->thread_index)) { RTE_LOG_WIN32_ERR("TlsFree()"); free(key); + rte_errno = GetLastError(); return -1; } free(key); @@ -52,12 +56,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } /* discard const qualifier */ p = (char *) (uintptr_t) value; if (!TlsSetValue(key->thread_index, p)) { RTE_LOG_WIN32_ERR("TlsSetValue()"); + rte_errno = GetLastError(); return -1; } return 0; @@ -76,7 +82,7 @@ rte_thread_tls_value_get(rte_tls_key key) output = TlsGetValue(key->thread_index); if (GetLastError() != ERROR_SUCCESS) { RTE_LOG_WIN32_ERR("TlsGetValue()"); - rte_errno = ENOEXEC; + rte_errno = GetLastError(); return NULL; } return output; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-02 17:09 ` Dmitry Kozlyuk 2021-03-03 10:37 ` Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 1 sibling, 1 reply; 29+ messages in thread From: Dmitry Kozlyuk @ 2021-03-02 17:09 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, thomas, pallavi.kadam, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb 2021-03-02 17:26, Tal Shnaiderman: > add error number reporting to rte_errno in all > functions in the rte_thread_tls_* API. > > Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > --- > lib/librte_eal/include/rte_thread.h | 6 +++--- > lib/librte_eal/unix/rte_thread.c | 6 ++++++ > lib/librte_eal/windows/rte_thread.c | 8 +++++++- > 3 files changed, 16 insertions(+), 4 deletions(-) Using OS error codes for rte_errno isn't the right thing to do: this way callers cannot write a portable check of rte_thread_*() result. Consider returning some suitable stable values. OS-specific error info can be logged at debug level, as it is already is some places. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API 2021-03-02 17:09 ` Dmitry Kozlyuk @ 2021-03-03 10:37 ` Tal Shnaiderman 2021-03-03 11:10 ` Dmitry Kozlyuk 0 siblings, 1 reply; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-03 10:37 UTC (permalink / raw) To: Dmitry Kozlyuk Cc: dev, NBU-Contact-Thomas Monjalon, pallavi.kadam, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb > Subject: Re: [PATCH v2 1/2] eal: error number enhancement for thread TLS > API > > External email: Use caution opening links or attachments > > > 2021-03-02 17:26, Tal Shnaiderman: > > add error number reporting to rte_errno in all functions in the > > rte_thread_tls_* API. > > > > Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> > > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > > --- > > lib/librte_eal/include/rte_thread.h | 6 +++--- > > lib/librte_eal/unix/rte_thread.c | 6 ++++++ > > lib/librte_eal/windows/rte_thread.c | 8 +++++++- > > 3 files changed, 16 insertions(+), 4 deletions(-) > > Using OS error codes for rte_errno isn't the right thing to do: this way callers > cannot write a portable check of rte_thread_*() result. Consider returning > some suitable stable values. OS-specific error info can be logged at debug > level, as it is already is some places. In Linux the error codes return are not OS specific (namely EAGAIN, ENOMEM and EINVAL). The problem is that documentation on Windows doesn't publish which error code can be returned from GetLastError() for the TLS functions. Or do we want to use the same errno for both OSs in case the functions fail regardless to the failure reason? ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API 2021-03-03 10:37 ` Tal Shnaiderman @ 2021-03-03 11:10 ` Dmitry Kozlyuk 2021-03-03 11:53 ` Tal Shnaiderman 0 siblings, 1 reply; 29+ messages in thread From: Dmitry Kozlyuk @ 2021-03-03 11:10 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, NBU-Contact-Thomas Monjalon, pallavi.kadam, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb 2021-03-03 10:37, Tal Shnaiderman: > > Subject: Re: [PATCH v2 1/2] eal: error number enhancement for thread TLS > > API > > > > External email: Use caution opening links or attachments > > > > > > 2021-03-02 17:26, Tal Shnaiderman: > > > add error number reporting to rte_errno in all functions in the > > > rte_thread_tls_* API. > > > > > > Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> > > > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > > > --- > > > lib/librte_eal/include/rte_thread.h | 6 +++--- > > > lib/librte_eal/unix/rte_thread.c | 6 ++++++ > > > lib/librte_eal/windows/rte_thread.c | 8 +++++++- > > > 3 files changed, 16 insertions(+), 4 deletions(-) > > > > Using OS error codes for rte_errno isn't the right thing to do: this way callers > > cannot write a portable check of rte_thread_*() result. Consider returning > > some suitable stable values. OS-specific error info can be logged at debug > > level, as it is already is some places. > > In Linux the error codes return are not OS specific (namely EAGAIN, ENOMEM and EINVAL). > > The problem is that documentation on Windows doesn't publish which error code can be returned from GetLastError() for the TLS functions. > > Or do we want to use the same errno for both OSs in case the functions fail regardless to the failure reason? Yes, so that callers know which codes to check against regardless of the OS. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API 2021-03-03 11:10 ` Dmitry Kozlyuk @ 2021-03-03 11:53 ` Tal Shnaiderman 0 siblings, 0 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-03 11:53 UTC (permalink / raw) To: Dmitry Kozlyuk, anatoly.burakov Cc: dev, NBU-Contact-Thomas Monjalon, pallavi.kadam, navasile, dmitrym, david.marchand, vladimir.medvedkin, mb > Subject: Re: [PATCH v2 1/2] eal: error number enhancement for thread TLS > API > > External email: Use caution opening links or attachments > > > 2021-03-03 10:37, Tal Shnaiderman: > > > Subject: Re: [PATCH v2 1/2] eal: error number enhancement for thread > > > TLS API > > > > > > External email: Use caution opening links or attachments > > > > > > > > > 2021-03-02 17:26, Tal Shnaiderman: > > > > add error number reporting to rte_errno in all functions in the > > > > rte_thread_tls_* API. > > > > > > > > Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> > > > > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > > > > --- > > > > lib/librte_eal/include/rte_thread.h | 6 +++--- > > > > lib/librte_eal/unix/rte_thread.c | 6 ++++++ > > > > lib/librte_eal/windows/rte_thread.c | 8 +++++++- > > > > 3 files changed, 16 insertions(+), 4 deletions(-) > > > > > > Using OS error codes for rte_errno isn't the right thing to do: this > > > way callers cannot write a portable check of rte_thread_*() result. > > > Consider returning some suitable stable values. OS-specific error > > > info can be logged at debug level, as it is already is some places. > > > > In Linux the error codes return are not OS specific (namely EAGAIN, > ENOMEM and EINVAL). > > > > The problem is that documentation on Windows doesn't publish which > error code can be returned from GetLastError() for the TLS functions. > > > > Or do we want to use the same errno for both OSs in case the functions fail > regardless to the failure reason? > > Yes, so that callers know which codes to check against regardless of the OS. This is different from Anatoly's original suggestion that values would be potentially different on different OS's. Anatoly, is the approach suggested by Dmitry fine with you? ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v3 0/2] EAL Thread TLS API enhancements 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-02 17:09 ` Dmitry Kozlyuk @ 2021-03-10 12:06 ` Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 " Tal Shnaiderman 1 sibling, 2 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-10 12:06 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb --- v3: -Unify rte_errno values to a generic errno for OS compatibility [DmitryK] -Rename the TLS function to avoid redundancy[MortenB]. v2: Rename key to avoid redundancy[MortenB]. --- Tal Shnaiderman (2): eal: error number enhancement for thread TLS API eal: rename key opaque pointer and functions in TLS API drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 33 +++++++++++++++++++++------------ lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 14 ++++++++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 16 +++++++++++----- 7 files changed, 61 insertions(+), 40 deletions(-) -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v3 1/2] eal: error number enhancement for thread TLS API 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 0/2] EAL Thread TLS API enhancements Tal Shnaiderman @ 2021-03-10 12:06 ` Tal Shnaiderman 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 " Tal Shnaiderman 1 sibling, 1 reply; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-10 12:06 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb add error number reporting to rte_errno in all functions in the rte_thread_tls_* API. Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> --- lib/librte_eal/include/rte_thread.h | 14 +++++++++++--- lib/librte_eal/unix/rte_thread.c | 6 ++++++ lib/librte_eal/windows/rte_thread.c | 8 +++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index e640ea1857..8969b5d645 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -59,7 +59,9 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be set to: ENOMEM - Memory allocation error. + * EOTHER - Specific OS error. */ __rte_experimental @@ -73,7 +75,9 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be set to: EINVAL - Invalid parameter passed. + * EOTHER - Specific OS error. */ __rte_experimental int rte_thread_tls_key_delete(rte_tls_key key); @@ -88,7 +92,9 @@ int rte_thread_tls_key_delete(rte_tls_key key); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be set to: EINVAL - Invalid parameter passed. + * EOTHER - Specific OS error. */ __rte_experimental int rte_thread_tls_value_set(rte_tls_key key, const void *value); @@ -102,6 +108,8 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * @return * On success, value data pointer (can also be NULL). * On failure, NULL and an error number is set in rte_errno. + * rte_errno can be set to: EINVAL - Invalid parameter passed. + * EOTHER - Specific OS error. */ __rte_experimental void *rte_thread_tls_value_get(rte_tls_key key); diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 86ffeebc95..448dbdfcfd 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -24,6 +24,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } err = pthread_key_create(&((*key)->thread_index), destructor); @@ -31,6 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) RTE_LOG(DEBUG, EAL, "pthread_key_create failed: %s\n", strerror(err)); free(*key); + rte_errno = EOTHER; return -1; } return 0; @@ -43,6 +45,7 @@ rte_thread_tls_key_delete(rte_tls_key key) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_key_delete(key->thread_index); @@ -50,6 +53,7 @@ rte_thread_tls_key_delete(rte_tls_key key) RTE_LOG(DEBUG, EAL, "pthread_key_delete failed: %s\n", strerror(err)); free(key); + rte_errno = EOTHER; return -1; } free(key); @@ -63,12 +67,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_setspecific(key->thread_index, value); if (err) { RTE_LOG(DEBUG, EAL, "pthread_setspecific failed: %s\n", strerror(err)); + rte_errno = EOTHER; return -1; } return 0; diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index 2e2ab29177..d42f2cf62a 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -18,12 +18,14 @@ rte_thread_tls_key_create(rte_tls_key *key, *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } (*key)->thread_index = TlsAlloc(); if ((*key)->thread_index == TLS_OUT_OF_INDEXES) { RTE_LOG_WIN32_ERR("TlsAlloc()"); free(*key); + rte_errno = EOTHER; return -1; } return 0; @@ -34,11 +36,13 @@ rte_thread_tls_key_delete(rte_tls_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } if (!TlsFree(key->thread_index)) { RTE_LOG_WIN32_ERR("TlsFree()"); free(key); + rte_errno = EOTHER; return -1; } free(key); @@ -52,12 +56,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } /* discard const qualifier */ p = (char *) (uintptr_t) value; if (!TlsSetValue(key->thread_index, p)) { RTE_LOG_WIN32_ERR("TlsSetValue()"); + rte_errno = EOTHER; return -1; } return 0; @@ -76,7 +82,7 @@ rte_thread_tls_value_get(rte_tls_key key) output = TlsGetValue(key->thread_index); if (GetLastError() != ERROR_SUCCESS) { RTE_LOG_WIN32_ERR("TlsGetValue()"); - rte_errno = ENOEXEC; + rte_errno = EOTHER; return NULL; } return output; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v4 0/2] EAL Thread TLS API enhancements 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-10 12:48 ` Tal Shnaiderman 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 " Tal Shnaiderman 0 siblings, 2 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-10 12:48 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb --- v4: replace errno EOTHER with ENOEXEC as EOTHER is undefined in unix. v3: -Unify rte_errno values to a generic errno for OS compatibility [DmitryK] -Rename the TLS function to avoid redundancy[MortenB]. v2: Rename key to avoid redundancy[MortenB]. --- Tal Shnaiderman (2): eal: error number enhancement for thread TLS API eal: rename key opaque pointer and functions in TLS API drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 33 +++++++++++++++++++++------------ lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 14 ++++++++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 14 ++++++++++---- 7 files changed, 60 insertions(+), 39 deletions(-) -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 0/2] EAL Thread TLS API enhancements Tal Shnaiderman @ 2021-03-10 12:48 ` Tal Shnaiderman 2021-03-10 19:45 ` Narcisa Ana Maria Vasile ` (3 more replies) 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 " Tal Shnaiderman 1 sibling, 4 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-10 12:48 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb add error number reporting to rte_errno in all functions in the rte_thread_tls_* API. Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> --- lib/librte_eal/include/rte_thread.h | 14 +++++++++++--- lib/librte_eal/unix/rte_thread.c | 6 ++++++ lib/librte_eal/windows/rte_thread.c | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index e640ea1857..7a503b81c9 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -59,7 +59,9 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be set to: ENOMEM - Memory allocation error. + * ENOEXEC - Specific OS error. */ __rte_experimental @@ -73,7 +75,9 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be set to: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental int rte_thread_tls_key_delete(rte_tls_key key); @@ -88,7 +92,9 @@ int rte_thread_tls_key_delete(rte_tls_key key); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be set to: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental int rte_thread_tls_value_set(rte_tls_key key, const void *value); @@ -102,6 +108,8 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * @return * On success, value data pointer (can also be NULL). * On failure, NULL and an error number is set in rte_errno. + * rte_errno can be set to: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental void *rte_thread_tls_value_get(rte_tls_key key); diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 86ffeebc95..b187c69a4c 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -24,6 +24,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } err = pthread_key_create(&((*key)->thread_index), destructor); @@ -31,6 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) RTE_LOG(DEBUG, EAL, "pthread_key_create failed: %s\n", strerror(err)); free(*key); + rte_errno = ENOEXEC; return -1; } return 0; @@ -43,6 +45,7 @@ rte_thread_tls_key_delete(rte_tls_key key) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_key_delete(key->thread_index); @@ -50,6 +53,7 @@ rte_thread_tls_key_delete(rte_tls_key key) RTE_LOG(DEBUG, EAL, "pthread_key_delete failed: %s\n", strerror(err)); free(key); + rte_errno = ENOEXEC; return -1; } free(key); @@ -63,12 +67,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_setspecific(key->thread_index, value); if (err) { RTE_LOG(DEBUG, EAL, "pthread_setspecific failed: %s\n", strerror(err)); + rte_errno = ENOEXEC; return -1; } return 0; diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index 2e2ab29177..fa9e360855 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -18,12 +18,14 @@ rte_thread_tls_key_create(rte_tls_key *key, *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } (*key)->thread_index = TlsAlloc(); if ((*key)->thread_index == TLS_OUT_OF_INDEXES) { RTE_LOG_WIN32_ERR("TlsAlloc()"); free(*key); + rte_errno = ENOEXEC; return -1; } return 0; @@ -34,11 +36,13 @@ rte_thread_tls_key_delete(rte_tls_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } if (!TlsFree(key->thread_index)) { RTE_LOG_WIN32_ERR("TlsFree()"); free(key); + rte_errno = ENOEXEC; return -1; } free(key); @@ -52,12 +56,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } /* discard const qualifier */ p = (char *) (uintptr_t) value; if (!TlsSetValue(key->thread_index, p)) { RTE_LOG_WIN32_ERR("TlsSetValue()"); + rte_errno = ENOEXEC; return -1; } return 0; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-10 19:45 ` Narcisa Ana Maria Vasile 2021-03-15 15:37 ` Tal Shnaiderman 2021-03-13 2:29 ` Dmitry Kozlyuk ` (2 subsequent siblings) 3 siblings, 1 reply; 29+ messages in thread From: Narcisa Ana Maria Vasile @ 2021-03-10 19:45 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, thomas, pallavi.kadam, dmitry.kozliuk, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb On Wed, Mar 10, 2021 at 02:48:55PM +0200, Tal Shnaiderman wrote: > add error number reporting to rte_errno in all > functions in the rte_thread_tls_* API. > > Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > --- > lib/librte_eal/include/rte_thread.h | 14 +++++++++++--- > lib/librte_eal/unix/rte_thread.c | 6 ++++++ > lib/librte_eal/windows/rte_thread.c | 6 ++++++ > 3 files changed, 23 insertions(+), 3 deletions(-) > > diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h After we introduce a translation function to map from Windows error codes to errno style codes (as part of EAL threads API), should we change this to directly return the error code from the functions? Or do we follow the pattern of setting rte_errno? ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API 2021-03-10 19:45 ` Narcisa Ana Maria Vasile @ 2021-03-15 15:37 ` Tal Shnaiderman 0 siblings, 0 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-15 15:37 UTC (permalink / raw) To: Narcisa Ana Maria Vasile Cc: dev, NBU-Contact-Thomas Monjalon, pallavi.kadam, dmitry.kozliuk, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb > Subject: Re: [PATCH v4 1/2] eal: error number enhancement for thread TLS > API > > On Wed, Mar 10, 2021 at 02:48:55PM +0200, Tal Shnaiderman wrote: > > add error number reporting to rte_errno in all functions in the > > rte_thread_tls_* API. > > > > Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> > > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > > --- > > lib/librte_eal/include/rte_thread.h | 14 +++++++++++--- > > lib/librte_eal/unix/rte_thread.c | 6 ++++++ > > lib/librte_eal/windows/rte_thread.c | 6 ++++++ > > 3 files changed, 23 insertions(+), 3 deletions(-) > > > > diff --git a/lib/librte_eal/include/rte_thread.h > > b/lib/librte_eal/include/rte_thread.h > > After we introduce a translation function to map from Windows error codes > to errno style codes (as part of EAL threads API), should we change this to > directly return the error code from the functions? > Or do we follow the pattern of setting rte_errno? Sorry for the late reply, I'd stick to errors in rte_errno, note that in cases like rte_thread_value_get the only way to get the errors is with rte_errno since it's returning the value itself. BTW will you also add translation function for the UNIX errors to get identical errors? ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-10 19:45 ` Narcisa Ana Maria Vasile @ 2021-03-13 2:29 ` Dmitry Kozlyuk 2021-03-15 23:14 ` Thomas Monjalon 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 3 siblings, 0 replies; 29+ messages in thread From: Dmitry Kozlyuk @ 2021-03-13 2:29 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, thomas, pallavi.kadam, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb 2021-03-10 14:48 (UTC+0200), Tal Shnaiderman: > add error number reporting to rte_errno in all > functions in the rte_thread_tls_* API. > > Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-10 19:45 ` Narcisa Ana Maria Vasile 2021-03-13 2:29 ` Dmitry Kozlyuk @ 2021-03-15 23:14 ` Thomas Monjalon 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 3 siblings, 0 replies; 29+ messages in thread From: Thomas Monjalon @ 2021-03-15 23:14 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb 10/03/2021 13:48, Tal Shnaiderman: > --- a/lib/librte_eal/include/rte_thread.h > +++ b/lib/librte_eal/include/rte_thread.h > @@ -59,7 +59,9 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); > * > * @return > * On success, zero. > - * On failure, a negative number. > + * On failure, a negative number and an error number is set in rte_errno. > + * rte_errno can be set to: ENOMEM - Memory allocation error. > + * ENOEXEC - Specific OS error. > */ > > __rte_experimental > @@ -73,7 +75,9 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); > * > * @return > * On success, zero. > - * On failure, a negative number. > + * On failure, a negative number and an error number is set in rte_errno. > + * rte_errno can be set to: EINVAL - Invalid parameter passed. > + * ENOEXEC - Specific OS error. > */ > __rte_experimental > int rte_thread_tls_key_delete(rte_tls_key key); > @@ -88,7 +92,9 @@ int rte_thread_tls_key_delete(rte_tls_key key); > * > * @return > * On success, zero. > - * On failure, a negative number. > + * On failure, a negative number and an error number is set in rte_errno. > + * rte_errno can be set to: EINVAL - Invalid parameter passed. > + * ENOEXEC - Specific OS error. > */ > __rte_experimental > int rte_thread_tls_value_set(rte_tls_key key, const void *value); > @@ -102,6 +108,8 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); > * @return > * On success, value data pointer (can also be NULL). > * On failure, NULL and an error number is set in rte_errno. > + * rte_errno can be set to: EINVAL - Invalid parameter passed. > + * ENOEXEC - Specific OS error. Shorter (and less confusing): "rte_errno can be:" ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v5 0/2] EAL Thread TLS API enhancements 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman ` (2 preceding siblings ...) 2021-03-15 23:14 ` Thomas Monjalon @ 2021-03-16 9:15 ` Tal Shnaiderman 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 2/2] eal: rename key opaque pointer and functions in TLS API Tal Shnaiderman 3 siblings, 2 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-16 9:15 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb --- v5: shorten docu comment on rte_errno and add ABI change info to release note [Thomas] v4: replace errno EOTHER with ENOEXEC as EOTHER is undefined in unix. v3: -Unify rte_errno values to a generic errno for OS compatibility [DmitryK] -Rename the TLS function to avoid redundancy[MortenB]. v2: Rename key to avoid redundancy[MortenB]. --- Tal Shnaiderman (2): eal: error number enhancement for thread TLS API eal: rename key opaque pointer and functions in TLS API doc/guides/rel_notes/release_21_05.rst | 3 +++ drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 33 +++++++++++++++++++++------------ lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 14 ++++++++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 14 ++++++++++---- 8 files changed, 63 insertions(+), 39 deletions(-) -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v5 1/2] eal: error number enhancement for thread TLS API 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 0/2] EAL Thread TLS API enhancements Tal Shnaiderman @ 2021-03-16 9:15 ` Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 2/2] eal: rename key opaque pointer and functions in TLS API Tal Shnaiderman 1 sibling, 1 reply; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-16 9:15 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb add error number reporting to rte_errno in all functions in the rte_thread_tls_* API. Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> --- lib/librte_eal/include/rte_thread.h | 14 +++++++++++--- lib/librte_eal/unix/rte_thread.c | 6 ++++++ lib/librte_eal/windows/rte_thread.c | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index e640ea1857..e8f9365953 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -59,7 +59,9 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be: ENOMEM - Memory allocation error. + * ENOEXEC - Specific OS error. */ __rte_experimental @@ -73,7 +75,9 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental int rte_thread_tls_key_delete(rte_tls_key key); @@ -88,7 +92,9 @@ int rte_thread_tls_key_delete(rte_tls_key key); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental int rte_thread_tls_value_set(rte_tls_key key, const void *value); @@ -102,6 +108,8 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * @return * On success, value data pointer (can also be NULL). * On failure, NULL and an error number is set in rte_errno. + * rte_errno can be: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental void *rte_thread_tls_value_get(rte_tls_key key); diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 86ffeebc95..b187c69a4c 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -24,6 +24,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } err = pthread_key_create(&((*key)->thread_index), destructor); @@ -31,6 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) RTE_LOG(DEBUG, EAL, "pthread_key_create failed: %s\n", strerror(err)); free(*key); + rte_errno = ENOEXEC; return -1; } return 0; @@ -43,6 +45,7 @@ rte_thread_tls_key_delete(rte_tls_key key) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_key_delete(key->thread_index); @@ -50,6 +53,7 @@ rte_thread_tls_key_delete(rte_tls_key key) RTE_LOG(DEBUG, EAL, "pthread_key_delete failed: %s\n", strerror(err)); free(key); + rte_errno = ENOEXEC; return -1; } free(key); @@ -63,12 +67,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_setspecific(key->thread_index, value); if (err) { RTE_LOG(DEBUG, EAL, "pthread_setspecific failed: %s\n", strerror(err)); + rte_errno = ENOEXEC; return -1; } return 0; diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index 2e2ab29177..fa9e360855 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -18,12 +18,14 @@ rte_thread_tls_key_create(rte_tls_key *key, *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } (*key)->thread_index = TlsAlloc(); if ((*key)->thread_index == TLS_OUT_OF_INDEXES) { RTE_LOG_WIN32_ERR("TlsAlloc()"); free(*key); + rte_errno = ENOEXEC; return -1; } return 0; @@ -34,11 +36,13 @@ rte_thread_tls_key_delete(rte_tls_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } if (!TlsFree(key->thread_index)) { RTE_LOG_WIN32_ERR("TlsFree()"); free(key); + rte_errno = ENOEXEC; return -1; } free(key); @@ -52,12 +56,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } /* discard const qualifier */ p = (char *) (uintptr_t) value; if (!TlsSetValue(key->thread_index, p)) { RTE_LOG_WIN32_ERR("TlsSetValue()"); + rte_errno = ENOEXEC; return -1; } return 0; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-16 13:28 ` Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman ` (2 more replies) 0 siblings, 3 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-16 13:28 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb --- v6: fix misalignment in comment fix from v5 and missing NL in RN [Thomas] v5: shorten docu comment on rte_errno and add ABI change info to release note [Thomas] v4: replace errno EOTHER with ENOEXEC as EOTHER is undefined in unix. v3: -Unify rte_errno values to a generic errno for OS compatibility [DmitryK] -Rename the TLS function to avoid redundancy[MortenB]. v2: Rename key to avoid redundancy[MortenB]. --- Tal Shnaiderman (2): eal: error number enhancement for thread TLS API eal: rename key opaque pointer and functions in TLS API doc/guides/rel_notes/release_21_05.rst | 4 ++++ drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 33 +++++++++++++++++++++------------ lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 14 ++++++++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 14 ++++++++++---- 8 files changed, 64 insertions(+), 39 deletions(-) -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v6 1/2] eal: error number enhancement for thread TLS API 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Tal Shnaiderman @ 2021-03-16 13:28 ` Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 2/2] eal: rename key opaque pointer and functions in " Tal Shnaiderman 2021-03-26 8:24 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Thomas Monjalon 2 siblings, 0 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-16 13:28 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb add error number reporting to rte_errno in all functions in the rte_thread_tls_* API. Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> --- lib/librte_eal/include/rte_thread.h | 14 +++++++++++--- lib/librte_eal/unix/rte_thread.c | 6 ++++++ lib/librte_eal/windows/rte_thread.c | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index e640ea1857..c77ad6d7c4 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -59,7 +59,9 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be: ENOMEM - Memory allocation error. + * ENOEXEC - Specific OS error. */ __rte_experimental @@ -73,7 +75,9 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental int rte_thread_tls_key_delete(rte_tls_key key); @@ -88,7 +92,9 @@ int rte_thread_tls_key_delete(rte_tls_key key); * * @return * On success, zero. - * On failure, a negative number. + * On failure, a negative number and an error number is set in rte_errno. + * rte_errno can be: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental int rte_thread_tls_value_set(rte_tls_key key, const void *value); @@ -102,6 +108,8 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * @return * On success, value data pointer (can also be NULL). * On failure, NULL and an error number is set in rte_errno. + * rte_errno can be: EINVAL - Invalid parameter passed. + * ENOEXEC - Specific OS error. */ __rte_experimental void *rte_thread_tls_value_get(rte_tls_key key); diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 86ffeebc95..b187c69a4c 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -24,6 +24,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } err = pthread_key_create(&((*key)->thread_index), destructor); @@ -31,6 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) RTE_LOG(DEBUG, EAL, "pthread_key_create failed: %s\n", strerror(err)); free(*key); + rte_errno = ENOEXEC; return -1; } return 0; @@ -43,6 +45,7 @@ rte_thread_tls_key_delete(rte_tls_key key) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_key_delete(key->thread_index); @@ -50,6 +53,7 @@ rte_thread_tls_key_delete(rte_tls_key key) RTE_LOG(DEBUG, EAL, "pthread_key_delete failed: %s\n", strerror(err)); free(key); + rte_errno = ENOEXEC; return -1; } free(key); @@ -63,12 +67,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } err = pthread_setspecific(key->thread_index, value); if (err) { RTE_LOG(DEBUG, EAL, "pthread_setspecific failed: %s\n", strerror(err)); + rte_errno = ENOEXEC; return -1; } return 0; diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index 2e2ab29177..fa9e360855 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -18,12 +18,14 @@ rte_thread_tls_key_create(rte_tls_key *key, *key = malloc(sizeof(**key)); if ((*key) == NULL) { RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); + rte_errno = ENOMEM; return -1; } (*key)->thread_index = TlsAlloc(); if ((*key)->thread_index == TLS_OUT_OF_INDEXES) { RTE_LOG_WIN32_ERR("TlsAlloc()"); free(*key); + rte_errno = ENOEXEC; return -1; } return 0; @@ -34,11 +36,13 @@ rte_thread_tls_key_delete(rte_tls_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } if (!TlsFree(key->thread_index)) { RTE_LOG_WIN32_ERR("TlsFree()"); free(key); + rte_errno = ENOEXEC; return -1; } free(key); @@ -52,12 +56,14 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); + rte_errno = EINVAL; return -1; } /* discard const qualifier */ p = (char *) (uintptr_t) value; if (!TlsSetValue(key->thread_index, p)) { RTE_LOG_WIN32_ERR("TlsSetValue()"); + rte_errno = ENOEXEC; return -1; } return 0; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v6 2/2] eal: rename key opaque pointer and functions in TLS API 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-16 13:28 ` Tal Shnaiderman 2021-03-26 8:24 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Thomas Monjalon 2 siblings, 0 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-16 13:28 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb rename the key opaque pointer from rte_tls_key to rte_thread_key to avoid confusion with transport layer security. Also rename and remove the "_tls" term from the following functions to avoid redundancy: rte_thread_tls_key_create rte_thread_tls_key_delete rte_thread_tls_value_set rte_thread_tls_value_get Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> Acked-by: Morten Brørup <mb@smartsharesystems.com> --- doc/guides/rel_notes/release_21_05.rst | 4 ++++ drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 8 ++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 8 ++++---- 8 files changed, 41 insertions(+), 36 deletions(-) diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index 21dc6d2342..4ab5404794 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -112,6 +112,10 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* eal: The experimental TLS API added in ``rte_thread.h`` has been renamed + from ``rte_thread_tls_*`` to ``rte_thread_*`` to avoid naming redundancy + and confusion with the transport layer security term. + ABI Changes ----------- diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c b/drivers/net/mlx5/linux/mlx5_flow_os.c index 732b1b2dd8..893f00b824 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.c +++ b/drivers/net/mlx5/linux/mlx5_flow_os.c @@ -7,12 +7,12 @@ #include <rte_thread.h> /* Key of thread specific flow workspace data. */ -static rte_tls_key key_workspace; +static rte_thread_key key_workspace; int mlx5_flow_os_init_workspace_once(void) { - if (rte_thread_tls_key_create(&key_workspace, flow_release_workspace)) { + if (rte_thread_key_create(&key_workspace, flow_release_workspace)) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); return -ENOMEM; } @@ -22,17 +22,17 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(key_workspace); + return rte_thread_value_get(key_workspace); } int mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) { - return rte_thread_tls_value_set(key_workspace, data); + return rte_thread_value_set(key_workspace, data); } void mlx5_flow_os_release_workspace(void) { - rte_thread_tls_key_delete(key_workspace); + rte_thread_key_delete(key_workspace); } diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c index 2cc02df322..c4d5790726 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -252,7 +252,7 @@ struct mlx5_workspace_thread { */ static struct mlx5_workspace_thread *curr; static struct mlx5_workspace_thread *first; -rte_tls_key ws_tls_index; +rte_thread_key ws_tls_index; static pthread_mutex_t lock_thread_list; static bool @@ -329,7 +329,7 @@ mlx5_flow_os_release_workspace(void) flow_release_workspace(first->mlx5_ws); free(first); } - rte_thread_tls_key_delete(ws_tls_index); + rte_thread_key_delete(ws_tls_index); pthread_mutex_destroy(&lock_thread_list); } @@ -368,7 +368,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data) int mlx5_flow_os_init_workspace_once(void) { - int err = rte_thread_tls_key_create(&ws_tls_index, NULL); + int err = rte_thread_key_create(&ws_tls_index, NULL); if (err) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); @@ -381,7 +381,7 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(ws_tls_index); + return rte_thread_value_get(ws_tls_index); } int @@ -391,7 +391,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) int old_err = rte_errno; rte_errno = 0; - if (!rte_thread_tls_value_get(ws_tls_index)) { + if (!rte_thread_value_get(ws_tls_index)) { if (rte_errno) { DRV_LOG(ERR, "Failed checking specific workspace."); rte_errno = old_err; @@ -409,7 +409,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) return -1; } } - if (rte_thread_tls_value_set(ws_tls_index, data)) { + if (rte_thread_value_set(ws_tls_index, data)) { DRV_LOG(ERR, "Failed setting specific workspace."); err = -1; } diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index c77ad6d7c4..a75476edcc 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -23,7 +23,7 @@ extern "C" { /** * TLS key type, an opaque pointer. */ -typedef struct eal_tls_key *rte_tls_key; +typedef struct eal_tls_key *rte_thread_key; /** * Set core affinity of the current thread. @@ -65,13 +65,14 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); */ __rte_experimental -int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); +int rte_thread_key_create(rte_thread_key *key, + void (*destructor)(void *)); /** * Delete a TLS data key visible to all threads in the process. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, zero. @@ -80,15 +81,15 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * ENOEXEC - Specific OS error. */ __rte_experimental -int rte_thread_tls_key_delete(rte_tls_key key); +int rte_thread_key_delete(rte_thread_key key); /** * Set value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * @param value - * The value bound to the rte_tls_key key for the calling thread. + * The value bound to the rte_thread_key key for the calling thread. * * @return * On success, zero. @@ -97,13 +98,13 @@ int rte_thread_tls_key_delete(rte_tls_key key); * ENOEXEC - Specific OS error. */ __rte_experimental -int rte_thread_tls_value_set(rte_tls_key key, const void *value); +int rte_thread_value_set(rte_thread_key key, const void *value); /** * Get value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, value data pointer (can also be NULL). @@ -112,7 +113,7 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * ENOEXEC - Specific OS error. */ __rte_experimental -void *rte_thread_tls_value_get(rte_tls_key key); +void *rte_thread_value_get(rte_thread_key key); #ifdef __cplusplus } diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def index 474cf123fa..c320077547 100644 --- a/lib/librte_eal/rte_eal_exports.def +++ b/lib/librte_eal/rte_eal_exports.def @@ -325,10 +325,10 @@ EXPORTS rte_vect_get_max_simd_bitwidth rte_vect_set_max_simd_bitwidth - rte_thread_tls_key_create - rte_thread_tls_key_delete - rte_thread_tls_value_get - rte_thread_tls_value_set + rte_thread_key_create + rte_thread_key_delete + rte_thread_value_get + rte_thread_value_set rte_mem_lock rte_mem_map diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index b187c69a4c..c72d619ec1 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -17,7 +17,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) +rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *)) { int err; @@ -39,7 +39,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { int err; @@ -61,7 +61,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { int err; @@ -81,7 +81,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index fce90a112f..c07aab176c 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -408,10 +408,10 @@ EXPERIMENTAL { rte_power_monitor; rte_power_monitor_wakeup; rte_power_pause; - rte_thread_tls_key_create; - rte_thread_tls_key_delete; - rte_thread_tls_value_get; - rte_thread_tls_value_set; + rte_thread_key_create; + rte_thread_key_delete; + rte_thread_value_get; + rte_thread_value_set; }; INTERNAL { diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index fa9e360855..667287c387 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -12,7 +12,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, +rte_thread_key_create(rte_thread_key *key, __rte_unused void (*destructor)(void *)) { *key = malloc(sizeof(**key)); @@ -32,7 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); @@ -50,7 +50,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { char *p; @@ -70,7 +70,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { void *output; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 2/2] eal: rename key opaque pointer and functions in " Tal Shnaiderman @ 2021-03-26 8:24 ` Thomas Monjalon 2 siblings, 0 replies; 29+ messages in thread From: Thomas Monjalon @ 2021-03-26 8:24 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb 16/03/2021 14:28, Tal Shnaiderman: > --- > v6: fix misalignment in comment fix from v5 and missing NL in RN [Thomas] > v5: shorten docu comment on rte_errno and add ABI change info to release note [Thomas] > v4: replace errno EOTHER with ENOEXEC as EOTHER is undefined in unix. > v3: -Unify rte_errno values to a generic errno for OS compatibility [DmitryK] > -Rename the TLS function to avoid redundancy[MortenB]. > v2: Rename key to avoid redundancy[MortenB]. > --- > > Tal Shnaiderman (2): > eal: error number enhancement for thread TLS API > eal: rename key opaque pointer and functions in TLS API Applied, thanks ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v5 2/2] eal: rename key opaque pointer and functions in TLS API 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-16 9:15 ` Tal Shnaiderman 1 sibling, 0 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-16 9:15 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb rename the key opaque pointer from rte_tls_key to rte_thread_key to avoid confusion with transport layer security. Also rename and remove the "_tls" term from the following functions to avoid redundancy: rte_thread_tls_key_create rte_thread_tls_key_delete rte_thread_tls_value_set rte_thread_tls_value_get Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> Acked-by: Morten Brørup <mb@smartsharesystems.com> --- doc/guides/rel_notes/release_21_05.rst | 3 +++ drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 8 ++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 8 ++++---- 8 files changed, 40 insertions(+), 36 deletions(-) diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index 21dc6d2342..914b176793 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -112,6 +112,9 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* eal: The experimental TLS API added in ``rte_thread.h`` has been renamed + from ``rte_thread_tls_*`` to ``rte_thread_*`` to avoid naming redundancy + and confusion with the transport layer security term. ABI Changes ----------- diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c b/drivers/net/mlx5/linux/mlx5_flow_os.c index 732b1b2dd8..893f00b824 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.c +++ b/drivers/net/mlx5/linux/mlx5_flow_os.c @@ -7,12 +7,12 @@ #include <rte_thread.h> /* Key of thread specific flow workspace data. */ -static rte_tls_key key_workspace; +static rte_thread_key key_workspace; int mlx5_flow_os_init_workspace_once(void) { - if (rte_thread_tls_key_create(&key_workspace, flow_release_workspace)) { + if (rte_thread_key_create(&key_workspace, flow_release_workspace)) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); return -ENOMEM; } @@ -22,17 +22,17 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(key_workspace); + return rte_thread_value_get(key_workspace); } int mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) { - return rte_thread_tls_value_set(key_workspace, data); + return rte_thread_value_set(key_workspace, data); } void mlx5_flow_os_release_workspace(void) { - rte_thread_tls_key_delete(key_workspace); + rte_thread_key_delete(key_workspace); } diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c index 2cc02df322..c4d5790726 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -252,7 +252,7 @@ struct mlx5_workspace_thread { */ static struct mlx5_workspace_thread *curr; static struct mlx5_workspace_thread *first; -rte_tls_key ws_tls_index; +rte_thread_key ws_tls_index; static pthread_mutex_t lock_thread_list; static bool @@ -329,7 +329,7 @@ mlx5_flow_os_release_workspace(void) flow_release_workspace(first->mlx5_ws); free(first); } - rte_thread_tls_key_delete(ws_tls_index); + rte_thread_key_delete(ws_tls_index); pthread_mutex_destroy(&lock_thread_list); } @@ -368,7 +368,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data) int mlx5_flow_os_init_workspace_once(void) { - int err = rte_thread_tls_key_create(&ws_tls_index, NULL); + int err = rte_thread_key_create(&ws_tls_index, NULL); if (err) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); @@ -381,7 +381,7 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(ws_tls_index); + return rte_thread_value_get(ws_tls_index); } int @@ -391,7 +391,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) int old_err = rte_errno; rte_errno = 0; - if (!rte_thread_tls_value_get(ws_tls_index)) { + if (!rte_thread_value_get(ws_tls_index)) { if (rte_errno) { DRV_LOG(ERR, "Failed checking specific workspace."); rte_errno = old_err; @@ -409,7 +409,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) return -1; } } - if (rte_thread_tls_value_set(ws_tls_index, data)) { + if (rte_thread_value_set(ws_tls_index, data)) { DRV_LOG(ERR, "Failed setting specific workspace."); err = -1; } diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index e8f9365953..2d1aaeedf4 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -23,7 +23,7 @@ extern "C" { /** * TLS key type, an opaque pointer. */ -typedef struct eal_tls_key *rte_tls_key; +typedef struct eal_tls_key *rte_thread_key; /** * Set core affinity of the current thread. @@ -65,13 +65,14 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); */ __rte_experimental -int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); +int rte_thread_key_create(rte_thread_key *key, + void (*destructor)(void *)); /** * Delete a TLS data key visible to all threads in the process. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, zero. @@ -80,15 +81,15 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * ENOEXEC - Specific OS error. */ __rte_experimental -int rte_thread_tls_key_delete(rte_tls_key key); +int rte_thread_key_delete(rte_thread_key key); /** * Set value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * @param value - * The value bound to the rte_tls_key key for the calling thread. + * The value bound to the rte_thread_key key for the calling thread. * * @return * On success, zero. @@ -97,13 +98,13 @@ int rte_thread_tls_key_delete(rte_tls_key key); * ENOEXEC - Specific OS error. */ __rte_experimental -int rte_thread_tls_value_set(rte_tls_key key, const void *value); +int rte_thread_value_set(rte_thread_key key, const void *value); /** * Get value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, value data pointer (can also be NULL). @@ -112,7 +113,7 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * ENOEXEC - Specific OS error. */ __rte_experimental -void *rte_thread_tls_value_get(rte_tls_key key); +void *rte_thread_value_get(rte_thread_key key); #ifdef __cplusplus } diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def index 474cf123fa..c320077547 100644 --- a/lib/librte_eal/rte_eal_exports.def +++ b/lib/librte_eal/rte_eal_exports.def @@ -325,10 +325,10 @@ EXPORTS rte_vect_get_max_simd_bitwidth rte_vect_set_max_simd_bitwidth - rte_thread_tls_key_create - rte_thread_tls_key_delete - rte_thread_tls_value_get - rte_thread_tls_value_set + rte_thread_key_create + rte_thread_key_delete + rte_thread_value_get + rte_thread_value_set rte_mem_lock rte_mem_map diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index b187c69a4c..c72d619ec1 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -17,7 +17,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) +rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *)) { int err; @@ -39,7 +39,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { int err; @@ -61,7 +61,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { int err; @@ -81,7 +81,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index fce90a112f..c07aab176c 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -408,10 +408,10 @@ EXPERIMENTAL { rte_power_monitor; rte_power_monitor_wakeup; rte_power_pause; - rte_thread_tls_key_create; - rte_thread_tls_key_delete; - rte_thread_tls_value_get; - rte_thread_tls_value_set; + rte_thread_key_create; + rte_thread_key_delete; + rte_thread_value_get; + rte_thread_value_set; }; INTERNAL { diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index fa9e360855..667287c387 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -12,7 +12,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, +rte_thread_key_create(rte_thread_key *key, __rte_unused void (*destructor)(void *)) { *key = malloc(sizeof(**key)); @@ -32,7 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); @@ -50,7 +50,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { char *p; @@ -70,7 +70,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { void *output; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v4 2/2] eal: rename key opaque pointer and functions in TLS API 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-10 12:48 ` Tal Shnaiderman 2021-03-15 23:16 ` Thomas Monjalon 1 sibling, 1 reply; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-10 12:48 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb rename the key opaque pointer from rte_tls_key to rte_thread_key to avoid confusion with transport layer security. Also rename and remove the "_tls" term from the following functions to avoid redundancy: rte_thread_tls_key_create rte_thread_tls_key_delete rte_thread_tls_value_set rte_thread_tls_value_get Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> Acked-by: Morten Brørup <mb@smartsharesystems.com> --- drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 8 ++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 8 ++++---- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c b/drivers/net/mlx5/linux/mlx5_flow_os.c index 732b1b2dd8..893f00b824 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.c +++ b/drivers/net/mlx5/linux/mlx5_flow_os.c @@ -7,12 +7,12 @@ #include <rte_thread.h> /* Key of thread specific flow workspace data. */ -static rte_tls_key key_workspace; +static rte_thread_key key_workspace; int mlx5_flow_os_init_workspace_once(void) { - if (rte_thread_tls_key_create(&key_workspace, flow_release_workspace)) { + if (rte_thread_key_create(&key_workspace, flow_release_workspace)) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); return -ENOMEM; } @@ -22,17 +22,17 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(key_workspace); + return rte_thread_value_get(key_workspace); } int mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) { - return rte_thread_tls_value_set(key_workspace, data); + return rte_thread_value_set(key_workspace, data); } void mlx5_flow_os_release_workspace(void) { - rte_thread_tls_key_delete(key_workspace); + rte_thread_key_delete(key_workspace); } diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c index 2cc02df322..c4d5790726 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -252,7 +252,7 @@ struct mlx5_workspace_thread { */ static struct mlx5_workspace_thread *curr; static struct mlx5_workspace_thread *first; -rte_tls_key ws_tls_index; +rte_thread_key ws_tls_index; static pthread_mutex_t lock_thread_list; static bool @@ -329,7 +329,7 @@ mlx5_flow_os_release_workspace(void) flow_release_workspace(first->mlx5_ws); free(first); } - rte_thread_tls_key_delete(ws_tls_index); + rte_thread_key_delete(ws_tls_index); pthread_mutex_destroy(&lock_thread_list); } @@ -368,7 +368,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data) int mlx5_flow_os_init_workspace_once(void) { - int err = rte_thread_tls_key_create(&ws_tls_index, NULL); + int err = rte_thread_key_create(&ws_tls_index, NULL); if (err) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); @@ -381,7 +381,7 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(ws_tls_index); + return rte_thread_value_get(ws_tls_index); } int @@ -391,7 +391,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) int old_err = rte_errno; rte_errno = 0; - if (!rte_thread_tls_value_get(ws_tls_index)) { + if (!rte_thread_value_get(ws_tls_index)) { if (rte_errno) { DRV_LOG(ERR, "Failed checking specific workspace."); rte_errno = old_err; @@ -409,7 +409,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) return -1; } } - if (rte_thread_tls_value_set(ws_tls_index, data)) { + if (rte_thread_value_set(ws_tls_index, data)) { DRV_LOG(ERR, "Failed setting specific workspace."); err = -1; } diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index 7a503b81c9..27da0d8787 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -23,7 +23,7 @@ extern "C" { /** * TLS key type, an opaque pointer. */ -typedef struct eal_tls_key *rte_tls_key; +typedef struct eal_tls_key *rte_thread_key; /** * Set core affinity of the current thread. @@ -65,13 +65,14 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); */ __rte_experimental -int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); +int rte_thread_key_create(rte_thread_key *key, + void (*destructor)(void *)); /** * Delete a TLS data key visible to all threads in the process. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, zero. @@ -80,15 +81,15 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * ENOEXEC - Specific OS error. */ __rte_experimental -int rte_thread_tls_key_delete(rte_tls_key key); +int rte_thread_key_delete(rte_thread_key key); /** * Set value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * @param value - * The value bound to the rte_tls_key key for the calling thread. + * The value bound to the rte_thread_key key for the calling thread. * * @return * On success, zero. @@ -97,13 +98,13 @@ int rte_thread_tls_key_delete(rte_tls_key key); * ENOEXEC - Specific OS error. */ __rte_experimental -int rte_thread_tls_value_set(rte_tls_key key, const void *value); +int rte_thread_value_set(rte_thread_key key, const void *value); /** * Get value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, value data pointer (can also be NULL). @@ -112,7 +113,7 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * ENOEXEC - Specific OS error. */ __rte_experimental -void *rte_thread_tls_value_get(rte_tls_key key); +void *rte_thread_value_get(rte_thread_key key); #ifdef __cplusplus } diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def index 474cf123fa..c320077547 100644 --- a/lib/librte_eal/rte_eal_exports.def +++ b/lib/librte_eal/rte_eal_exports.def @@ -325,10 +325,10 @@ EXPORTS rte_vect_get_max_simd_bitwidth rte_vect_set_max_simd_bitwidth - rte_thread_tls_key_create - rte_thread_tls_key_delete - rte_thread_tls_value_get - rte_thread_tls_value_set + rte_thread_key_create + rte_thread_key_delete + rte_thread_value_get + rte_thread_value_set rte_mem_lock rte_mem_map diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index b187c69a4c..c72d619ec1 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -17,7 +17,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) +rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *)) { int err; @@ -39,7 +39,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { int err; @@ -61,7 +61,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { int err; @@ -81,7 +81,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index fce90a112f..c07aab176c 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -408,10 +408,10 @@ EXPERIMENTAL { rte_power_monitor; rte_power_monitor_wakeup; rte_power_pause; - rte_thread_tls_key_create; - rte_thread_tls_key_delete; - rte_thread_tls_value_get; - rte_thread_tls_value_set; + rte_thread_key_create; + rte_thread_key_delete; + rte_thread_value_get; + rte_thread_value_set; }; INTERNAL { diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index fa9e360855..667287c387 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -12,7 +12,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, +rte_thread_key_create(rte_thread_key *key, __rte_unused void (*destructor)(void *)) { *key = malloc(sizeof(**key)); @@ -32,7 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); @@ -50,7 +50,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { char *p; @@ -70,7 +70,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { void *output; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v4 2/2] eal: rename key opaque pointer and functions in TLS API 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 " Tal Shnaiderman @ 2021-03-15 23:16 ` Thomas Monjalon 2021-03-16 9:17 ` Tal Shnaiderman 0 siblings, 1 reply; 29+ messages in thread From: Thomas Monjalon @ 2021-03-15 23:16 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb 10/03/2021 13:48, Tal Shnaiderman: > rename the key opaque pointer from rte_tls_key to > rte_thread_key to avoid confusion with transport layer security. > > Also rename and remove the "_tls" term from the following > functions to avoid redundancy: > > rte_thread_tls_key_create > rte_thread_tls_key_delete > rte_thread_tls_value_set > rte_thread_tls_value_get > > Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > Acked-by: Morten Brørup <mb@smartsharesystems.com> > --- > drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- > drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ > lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- > lib/librte_eal/rte_eal_exports.def | 8 ++++---- > lib/librte_eal/unix/rte_thread.c | 8 ++++---- > lib/librte_eal/version.map | 8 ++++---- > lib/librte_eal/windows/rte_thread.c | 8 ++++---- > 7 files changed, 37 insertions(+), 36 deletions(-) Updating an API, even experimental, requires an entry in the release notes. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v4 2/2] eal: rename key opaque pointer and functions in TLS API 2021-03-15 23:16 ` Thomas Monjalon @ 2021-03-16 9:17 ` Tal Shnaiderman 0 siblings, 0 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-16 9:17 UTC (permalink / raw) To: NBU-Contact-Thomas Monjalon Cc: dev, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb > Subject: Re: [dpdk-dev] [PATCH v4 2/2] eal: rename key opaque pointer and > functions in TLS API > > External email: Use caution opening links or attachments > > > 10/03/2021 13:48, Tal Shnaiderman: > > rename the key opaque pointer from rte_tls_key to rte_thread_key to > > avoid confusion with transport layer security. > > > > Also rename and remove the "_tls" term from the following functions to > > avoid redundancy: > > > > rte_thread_tls_key_create > > rte_thread_tls_key_delete > > rte_thread_tls_value_set > > rte_thread_tls_value_get > > > > Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > > Acked-by: Morten Brørup <mb@smartsharesystems.com> > > --- > > drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- > > drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ > > lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- > > lib/librte_eal/rte_eal_exports.def | 8 ++++---- > > lib/librte_eal/unix/rte_thread.c | 8 ++++---- > > lib/librte_eal/version.map | 8 ++++---- > > lib/librte_eal/windows/rte_thread.c | 8 ++++---- > > 7 files changed, 37 insertions(+), 36 deletions(-) > > Updating an API, even experimental, requires an entry in the release notes. > > Thanks Thomas, will add in v5. ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v3 2/2] eal: rename key opaque pointer and functions in TLS API 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-10 12:06 ` Tal Shnaiderman 2021-03-10 12:22 ` Morten Brørup 1 sibling, 1 reply; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-10 12:06 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb rename the key opaque pointer from rte_tls_key to rte_thread_key to avoid confusion with transport layer security. Also rename and remove the "_tls" term from the following functions to avoid redundancy: rte_thread_tls_key_create rte_thread_tls_key_delete rte_thread_tls_value_set rte_thread_tls_value_get Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> --- drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- lib/librte_eal/rte_eal_exports.def | 8 ++++---- lib/librte_eal/unix/rte_thread.c | 8 ++++---- lib/librte_eal/version.map | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 8 ++++---- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c b/drivers/net/mlx5/linux/mlx5_flow_os.c index 732b1b2dd8..893f00b824 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.c +++ b/drivers/net/mlx5/linux/mlx5_flow_os.c @@ -7,12 +7,12 @@ #include <rte_thread.h> /* Key of thread specific flow workspace data. */ -static rte_tls_key key_workspace; +static rte_thread_key key_workspace; int mlx5_flow_os_init_workspace_once(void) { - if (rte_thread_tls_key_create(&key_workspace, flow_release_workspace)) { + if (rte_thread_key_create(&key_workspace, flow_release_workspace)) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); return -ENOMEM; } @@ -22,17 +22,17 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(key_workspace); + return rte_thread_value_get(key_workspace); } int mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) { - return rte_thread_tls_value_set(key_workspace, data); + return rte_thread_value_set(key_workspace, data); } void mlx5_flow_os_release_workspace(void) { - rte_thread_tls_key_delete(key_workspace); + rte_thread_key_delete(key_workspace); } diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c index 2cc02df322..c4d5790726 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -252,7 +252,7 @@ struct mlx5_workspace_thread { */ static struct mlx5_workspace_thread *curr; static struct mlx5_workspace_thread *first; -rte_tls_key ws_tls_index; +rte_thread_key ws_tls_index; static pthread_mutex_t lock_thread_list; static bool @@ -329,7 +329,7 @@ mlx5_flow_os_release_workspace(void) flow_release_workspace(first->mlx5_ws); free(first); } - rte_thread_tls_key_delete(ws_tls_index); + rte_thread_key_delete(ws_tls_index); pthread_mutex_destroy(&lock_thread_list); } @@ -368,7 +368,7 @@ mlx5_add_workspace_to_list(struct mlx5_flow_workspace *data) int mlx5_flow_os_init_workspace_once(void) { - int err = rte_thread_tls_key_create(&ws_tls_index, NULL); + int err = rte_thread_key_create(&ws_tls_index, NULL); if (err) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); @@ -381,7 +381,7 @@ mlx5_flow_os_init_workspace_once(void) void * mlx5_flow_os_get_specific_workspace(void) { - return rte_thread_tls_value_get(ws_tls_index); + return rte_thread_value_get(ws_tls_index); } int @@ -391,7 +391,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) int old_err = rte_errno; rte_errno = 0; - if (!rte_thread_tls_value_get(ws_tls_index)) { + if (!rte_thread_value_get(ws_tls_index)) { if (rte_errno) { DRV_LOG(ERR, "Failed checking specific workspace."); rte_errno = old_err; @@ -409,7 +409,7 @@ mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) return -1; } } - if (rte_thread_tls_value_set(ws_tls_index, data)) { + if (rte_thread_value_set(ws_tls_index, data)) { DRV_LOG(ERR, "Failed setting specific workspace."); err = -1; } diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index 8969b5d645..5fcccbce60 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -23,7 +23,7 @@ extern "C" { /** * TLS key type, an opaque pointer. */ -typedef struct eal_tls_key *rte_tls_key; +typedef struct eal_tls_key *rte_thread_key; /** * Set core affinity of the current thread. @@ -65,13 +65,14 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); */ __rte_experimental -int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); +int rte_thread_key_create(rte_thread_key *key, + void (*destructor)(void *)); /** * Delete a TLS data key visible to all threads in the process. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, zero. @@ -80,15 +81,15 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * EOTHER - Specific OS error. */ __rte_experimental -int rte_thread_tls_key_delete(rte_tls_key key); +int rte_thread_key_delete(rte_thread_key key); /** * Set value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * @param value - * The value bound to the rte_tls_key key for the calling thread. + * The value bound to the rte_thread_key key for the calling thread. * * @return * On success, zero. @@ -97,13 +98,13 @@ int rte_thread_tls_key_delete(rte_tls_key key); * EOTHER - Specific OS error. */ __rte_experimental -int rte_thread_tls_value_set(rte_tls_key key, const void *value); +int rte_thread_value_set(rte_thread_key key, const void *value); /** * Get value bound to the TLS key on behalf of the calling thread. * * @param key - * The key allocated by rte_thread_tls_key_create(). + * The key allocated by rte_thread_key_create(). * * @return * On success, value data pointer (can also be NULL). @@ -112,7 +113,7 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * EOTHER - Specific OS error. */ __rte_experimental -void *rte_thread_tls_value_get(rte_tls_key key); +void *rte_thread_value_get(rte_thread_key key); #ifdef __cplusplus } diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def index 474cf123fa..c320077547 100644 --- a/lib/librte_eal/rte_eal_exports.def +++ b/lib/librte_eal/rte_eal_exports.def @@ -325,10 +325,10 @@ EXPORTS rte_vect_get_max_simd_bitwidth rte_vect_set_max_simd_bitwidth - rte_thread_tls_key_create - rte_thread_tls_key_delete - rte_thread_tls_value_get - rte_thread_tls_value_set + rte_thread_key_create + rte_thread_key_delete + rte_thread_value_get + rte_thread_value_set rte_mem_lock rte_mem_map diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 448dbdfcfd..cee3c131c0 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -17,7 +17,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) +rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *)) { int err; @@ -39,7 +39,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { int err; @@ -61,7 +61,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { int err; @@ -81,7 +81,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index fce90a112f..c07aab176c 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -408,10 +408,10 @@ EXPERIMENTAL { rte_power_monitor; rte_power_monitor_wakeup; rte_power_pause; - rte_thread_tls_key_create; - rte_thread_tls_key_delete; - rte_thread_tls_value_get; - rte_thread_tls_value_set; + rte_thread_key_create; + rte_thread_key_delete; + rte_thread_value_get; + rte_thread_value_set; }; INTERNAL { diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index d42f2cf62a..f5ee70e780 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -12,7 +12,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, +rte_thread_key_create(rte_thread_key *key, __rte_unused void (*destructor)(void *)) { *key = malloc(sizeof(**key)); @@ -32,7 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_key_delete(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); @@ -50,7 +50,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_value_set(rte_thread_key key, const void *value) { char *p; @@ -70,7 +70,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_value_get(rte_thread_key key) { void *output; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v3 2/2] eal: rename key opaque pointer and functions in TLS API 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 " Tal Shnaiderman @ 2021-03-10 12:22 ` Morten Brørup 0 siblings, 0 replies; 29+ messages in thread From: Morten Brørup @ 2021-03-10 12:22 UTC (permalink / raw) To: Tal Shnaiderman, dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tal Shnaiderman > Sent: Wednesday, March 10, 2021 1:07 PM > > rename the key opaque pointer from rte_tls_key to > rte_thread_key to avoid confusion with transport layer security. > > Also rename and remove the "_tls" term from the following > functions to avoid redundancy: > > rte_thread_tls_key_create > rte_thread_tls_key_delete > rte_thread_tls_value_set > rte_thread_tls_value_get > > Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > --- > drivers/net/mlx5/linux/mlx5_flow_os.c | 10 +++++----- > drivers/net/mlx5/windows/mlx5_flow_os.c | 12 ++++++------ > lib/librte_eal/include/rte_thread.h | 19 ++++++++++--------- > lib/librte_eal/rte_eal_exports.def | 8 ++++---- > lib/librte_eal/unix/rte_thread.c | 8 ++++---- > lib/librte_eal/version.map | 8 ++++---- > lib/librte_eal/windows/rte_thread.c | 8 ++++---- > 7 files changed, 37 insertions(+), 36 deletions(-) > > diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c > b/drivers/net/mlx5/linux/mlx5_flow_os.c > index 732b1b2dd8..893f00b824 100644 > --- a/drivers/net/mlx5/linux/mlx5_flow_os.c > +++ b/drivers/net/mlx5/linux/mlx5_flow_os.c > @@ -7,12 +7,12 @@ > #include <rte_thread.h> > > /* Key of thread specific flow workspace data. */ > -static rte_tls_key key_workspace; > +static rte_thread_key key_workspace; > > int > mlx5_flow_os_init_workspace_once(void) > { > - if (rte_thread_tls_key_create(&key_workspace, > flow_release_workspace)) { > + if (rte_thread_key_create(&key_workspace, > flow_release_workspace)) { > DRV_LOG(ERR, "Can't create flow workspace data thread > key."); > return -ENOMEM; > } > @@ -22,17 +22,17 @@ mlx5_flow_os_init_workspace_once(void) > void * > mlx5_flow_os_get_specific_workspace(void) > { > - return rte_thread_tls_value_get(key_workspace); > + return rte_thread_value_get(key_workspace); > } > > int > mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) > { > - return rte_thread_tls_value_set(key_workspace, data); > + return rte_thread_value_set(key_workspace, data); > } > > void > mlx5_flow_os_release_workspace(void) > { > - rte_thread_tls_key_delete(key_workspace); > + rte_thread_key_delete(key_workspace); > } > diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c > b/drivers/net/mlx5/windows/mlx5_flow_os.c > index 2cc02df322..c4d5790726 100644 > --- a/drivers/net/mlx5/windows/mlx5_flow_os.c > +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c > @@ -252,7 +252,7 @@ struct mlx5_workspace_thread { > */ > static struct mlx5_workspace_thread *curr; > static struct mlx5_workspace_thread *first; > -rte_tls_key ws_tls_index; > +rte_thread_key ws_tls_index; > static pthread_mutex_t lock_thread_list; > > static bool > @@ -329,7 +329,7 @@ mlx5_flow_os_release_workspace(void) > flow_release_workspace(first->mlx5_ws); > free(first); > } > - rte_thread_tls_key_delete(ws_tls_index); > + rte_thread_key_delete(ws_tls_index); > pthread_mutex_destroy(&lock_thread_list); > } > > @@ -368,7 +368,7 @@ mlx5_add_workspace_to_list(struct > mlx5_flow_workspace *data) > int > mlx5_flow_os_init_workspace_once(void) > { > - int err = rte_thread_tls_key_create(&ws_tls_index, NULL); > + int err = rte_thread_key_create(&ws_tls_index, NULL); > > if (err) { > DRV_LOG(ERR, "Can't create flow workspace data thread > key."); > @@ -381,7 +381,7 @@ mlx5_flow_os_init_workspace_once(void) > void * > mlx5_flow_os_get_specific_workspace(void) > { > - return rte_thread_tls_value_get(ws_tls_index); > + return rte_thread_value_get(ws_tls_index); > } > > int > @@ -391,7 +391,7 @@ mlx5_flow_os_set_specific_workspace(struct > mlx5_flow_workspace *data) > int old_err = rte_errno; > > rte_errno = 0; > - if (!rte_thread_tls_value_get(ws_tls_index)) { > + if (!rte_thread_value_get(ws_tls_index)) { > if (rte_errno) { > DRV_LOG(ERR, "Failed checking specific workspace."); > rte_errno = old_err; > @@ -409,7 +409,7 @@ mlx5_flow_os_set_specific_workspace(struct > mlx5_flow_workspace *data) > return -1; > } > } > - if (rte_thread_tls_value_set(ws_tls_index, data)) { > + if (rte_thread_value_set(ws_tls_index, data)) { > DRV_LOG(ERR, "Failed setting specific workspace."); > err = -1; > } > diff --git a/lib/librte_eal/include/rte_thread.h > b/lib/librte_eal/include/rte_thread.h > index 8969b5d645..5fcccbce60 100644 > --- a/lib/librte_eal/include/rte_thread.h > +++ b/lib/librte_eal/include/rte_thread.h > @@ -23,7 +23,7 @@ extern "C" { > /** > * TLS key type, an opaque pointer. > */ > -typedef struct eal_tls_key *rte_tls_key; > +typedef struct eal_tls_key *rte_thread_key; > > /** > * Set core affinity of the current thread. > @@ -65,13 +65,14 @@ void rte_thread_get_affinity(rte_cpuset_t > *cpusetp); > */ > > __rte_experimental > -int rte_thread_tls_key_create(rte_tls_key *key, void > (*destructor)(void *)); > +int rte_thread_key_create(rte_thread_key *key, > + void (*destructor)(void *)); > > /** > * Delete a TLS data key visible to all threads in the process. > * > * @param key > - * The key allocated by rte_thread_tls_key_create(). > + * The key allocated by rte_thread_key_create(). > * > * @return > * On success, zero. > @@ -80,15 +81,15 @@ int rte_thread_tls_key_create(rte_tls_key *key, > void (*destructor)(void *)); > * EOTHER - Specific OS error. > */ > __rte_experimental > -int rte_thread_tls_key_delete(rte_tls_key key); > +int rte_thread_key_delete(rte_thread_key key); > > /** > * Set value bound to the TLS key on behalf of the calling thread. > * > * @param key > - * The key allocated by rte_thread_tls_key_create(). > + * The key allocated by rte_thread_key_create(). > * @param value > - * The value bound to the rte_tls_key key for the calling thread. > + * The value bound to the rte_thread_key key for the calling thread. > * > * @return > * On success, zero. > @@ -97,13 +98,13 @@ int rte_thread_tls_key_delete(rte_tls_key key); > * EOTHER - Specific OS error. > */ > __rte_experimental > -int rte_thread_tls_value_set(rte_tls_key key, const void *value); > +int rte_thread_value_set(rte_thread_key key, const void *value); > > /** > * Get value bound to the TLS key on behalf of the calling thread. > * > * @param key > - * The key allocated by rte_thread_tls_key_create(). > + * The key allocated by rte_thread_key_create(). > * > * @return > * On success, value data pointer (can also be NULL). > @@ -112,7 +113,7 @@ int rte_thread_tls_value_set(rte_tls_key key, const > void *value); > * EOTHER - Specific OS error. > */ > __rte_experimental > -void *rte_thread_tls_value_get(rte_tls_key key); > +void *rte_thread_value_get(rte_thread_key key); > > #ifdef __cplusplus > } > diff --git a/lib/librte_eal/rte_eal_exports.def > b/lib/librte_eal/rte_eal_exports.def > index 474cf123fa..c320077547 100644 > --- a/lib/librte_eal/rte_eal_exports.def > +++ b/lib/librte_eal/rte_eal_exports.def > @@ -325,10 +325,10 @@ EXPORTS > rte_vect_get_max_simd_bitwidth > rte_vect_set_max_simd_bitwidth > > - rte_thread_tls_key_create > - rte_thread_tls_key_delete > - rte_thread_tls_value_get > - rte_thread_tls_value_set > + rte_thread_key_create > + rte_thread_key_delete > + rte_thread_value_get > + rte_thread_value_set > > rte_mem_lock > rte_mem_map > diff --git a/lib/librte_eal/unix/rte_thread.c > b/lib/librte_eal/unix/rte_thread.c > index 448dbdfcfd..cee3c131c0 100644 > --- a/lib/librte_eal/unix/rte_thread.c > +++ b/lib/librte_eal/unix/rte_thread.c > @@ -17,7 +17,7 @@ struct eal_tls_key { > }; > > int > -rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void > *)) > +rte_thread_key_create(rte_thread_key *key, void (*destructor)(void *)) > { > int err; > > @@ -39,7 +39,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void > (*destructor)(void *)) > } > > int > -rte_thread_tls_key_delete(rte_tls_key key) > +rte_thread_key_delete(rte_thread_key key) > { > int err; > > @@ -61,7 +61,7 @@ rte_thread_tls_key_delete(rte_tls_key key) > } > > int > -rte_thread_tls_value_set(rte_tls_key key, const void *value) > +rte_thread_value_set(rte_thread_key key, const void *value) > { > int err; > > @@ -81,7 +81,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void > *value) > } > > void * > -rte_thread_tls_value_get(rte_tls_key key) > +rte_thread_value_get(rte_thread_key key) > { > if (!key) { > RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); > diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map > index fce90a112f..c07aab176c 100644 > --- a/lib/librte_eal/version.map > +++ b/lib/librte_eal/version.map > @@ -408,10 +408,10 @@ EXPERIMENTAL { > rte_power_monitor; > rte_power_monitor_wakeup; > rte_power_pause; > - rte_thread_tls_key_create; > - rte_thread_tls_key_delete; > - rte_thread_tls_value_get; > - rte_thread_tls_value_set; > + rte_thread_key_create; > + rte_thread_key_delete; > + rte_thread_value_get; > + rte_thread_value_set; > }; > > INTERNAL { > diff --git a/lib/librte_eal/windows/rte_thread.c > b/lib/librte_eal/windows/rte_thread.c > index d42f2cf62a..f5ee70e780 100644 > --- a/lib/librte_eal/windows/rte_thread.c > +++ b/lib/librte_eal/windows/rte_thread.c > @@ -12,7 +12,7 @@ struct eal_tls_key { > }; > > int > -rte_thread_tls_key_create(rte_tls_key *key, > +rte_thread_key_create(rte_thread_key *key, > __rte_unused void (*destructor)(void *)) > { > *key = malloc(sizeof(**key)); > @@ -32,7 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, > } > > int > -rte_thread_tls_key_delete(rte_tls_key key) > +rte_thread_key_delete(rte_thread_key key) > { > if (!key) { > RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); > @@ -50,7 +50,7 @@ rte_thread_tls_key_delete(rte_tls_key key) > } > > int > -rte_thread_tls_value_set(rte_tls_key key, const void *value) > +rte_thread_value_set(rte_thread_key key, const void *value) > { > char *p; > > @@ -70,7 +70,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void > *value) > } > > void * > -rte_thread_tls_value_get(rte_tls_key key) > +rte_thread_value_get(rte_thread_key key) > { > void *output; > > -- > 2.16.1.windows.4 > Acked-by: Morten Brørup <mb@smartsharesystems.com> ^ permalink raw reply [flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] eal: rename key opaque pointer in TLS API 2021-03-02 15:26 [dpdk-dev] [PATCH v2 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman @ 2021-03-02 15:26 ` Tal Shnaiderman 2021-03-02 15:36 ` Morten Brørup 1 sibling, 1 reply; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-02 15:26 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin, mb rename the key opaque pointer from rte_tls_key to rte_thread_key to avoid confusion with transport layer security. Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> --- drivers/net/mlx5/linux/mlx5_flow_os.c | 2 +- drivers/net/mlx5/windows/mlx5_flow_os.c | 2 +- lib/librte_eal/include/rte_thread.h | 13 +++++++------ lib/librte_eal/unix/rte_thread.c | 8 ++++---- lib/librte_eal/windows/rte_thread.c | 8 ++++---- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c b/drivers/net/mlx5/linux/mlx5_flow_os.c index 732b1b2dd8..80b25ca25a 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.c +++ b/drivers/net/mlx5/linux/mlx5_flow_os.c @@ -7,7 +7,7 @@ #include <rte_thread.h> /* Key of thread specific flow workspace data. */ -static rte_tls_key key_workspace; +static rte_thread_key key_workspace; int mlx5_flow_os_init_workspace_once(void) diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c index 2cc02df322..8f4dd99fac 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -252,7 +252,7 @@ struct mlx5_workspace_thread { */ static struct mlx5_workspace_thread *curr; static struct mlx5_workspace_thread *first; -rte_tls_key ws_tls_index; +rte_thread_key ws_tls_index; static pthread_mutex_t lock_thread_list; static bool diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h index 39737d1829..e44be3d252 100644 --- a/lib/librte_eal/include/rte_thread.h +++ b/lib/librte_eal/include/rte_thread.h @@ -23,7 +23,7 @@ extern "C" { /** * TLS key type, an opaque pointer. */ -typedef struct eal_tls_key *rte_tls_key; +typedef struct eal_tls_key *rte_thread_key; /** * Set core affinity of the current thread. @@ -63,7 +63,8 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); */ __rte_experimental -int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); +int rte_thread_tls_key_create(rte_thread_key *key, + void (*destructor)(void *)); /** * Delete a TLS data key visible to all threads in the process. @@ -76,7 +77,7 @@ int rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)); * On failure, a negative number and an error number is set in rte_errno. */ __rte_experimental -int rte_thread_tls_key_delete(rte_tls_key key); +int rte_thread_tls_key_delete(rte_thread_key key); /** * Set value bound to the TLS key on behalf of the calling thread. @@ -84,14 +85,14 @@ int rte_thread_tls_key_delete(rte_tls_key key); * @param key * The key allocated by rte_thread_tls_key_create(). * @param value - * The value bound to the rte_tls_key key for the calling thread. + * The value bound to the rte_thread_key key for the calling thread. * * @return * On success, zero. * On failure, a negative number and an error number is set in rte_errno. */ __rte_experimental -int rte_thread_tls_value_set(rte_tls_key key, const void *value); +int rte_thread_tls_value_set(rte_thread_key key, const void *value); /** * Get value bound to the TLS key on behalf of the calling thread. @@ -104,7 +105,7 @@ int rte_thread_tls_value_set(rte_tls_key key, const void *value); * On failure, NULL and an error number is set in rte_errno. */ __rte_experimental -void *rte_thread_tls_value_get(rte_tls_key key); +void *rte_thread_tls_value_get(rte_thread_key key); #ifdef __cplusplus } diff --git a/lib/librte_eal/unix/rte_thread.c b/lib/librte_eal/unix/rte_thread.c index 86e42bf653..923b069f77 100644 --- a/lib/librte_eal/unix/rte_thread.c +++ b/lib/librte_eal/unix/rte_thread.c @@ -17,7 +17,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) +rte_thread_tls_key_create(rte_thread_key *key, void (*destructor)(void *)) { int err; @@ -39,7 +39,7 @@ rte_thread_tls_key_create(rte_tls_key *key, void (*destructor)(void *)) } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_tls_key_delete(rte_thread_key key) { int err; @@ -61,7 +61,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_tls_value_set(rte_thread_key key, const void *value) { int err; @@ -81,7 +81,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_tls_value_get(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c index 1c226b3e30..1e56ef6090 100644 --- a/lib/librte_eal/windows/rte_thread.c +++ b/lib/librte_eal/windows/rte_thread.c @@ -12,7 +12,7 @@ struct eal_tls_key { }; int -rte_thread_tls_key_create(rte_tls_key *key, +rte_thread_tls_key_create(rte_thread_key *key, __rte_unused void (*destructor)(void *)) { *key = malloc(sizeof(**key)); @@ -32,7 +32,7 @@ rte_thread_tls_key_create(rte_tls_key *key, } int -rte_thread_tls_key_delete(rte_tls_key key) +rte_thread_tls_key_delete(rte_thread_key key) { if (!key) { RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); @@ -50,7 +50,7 @@ rte_thread_tls_key_delete(rte_tls_key key) } int -rte_thread_tls_value_set(rte_tls_key key, const void *value) +rte_thread_tls_value_set(rte_thread_key key, const void *value) { char *p; @@ -70,7 +70,7 @@ rte_thread_tls_value_set(rte_tls_key key, const void *value) } void * -rte_thread_tls_value_get(rte_tls_key key) +rte_thread_tls_value_get(rte_thread_key key) { void *output; -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] eal: rename key opaque pointer in TLS API 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 2/2] eal: rename key opaque pointer " Tal Shnaiderman @ 2021-03-02 15:36 ` Morten Brørup 2021-03-04 11:16 ` Tal Shnaiderman 0 siblings, 1 reply; 29+ messages in thread From: Morten Brørup @ 2021-03-02 15:36 UTC (permalink / raw) To: Tal Shnaiderman, dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin > From: Tal Shnaiderman [mailto:talshn@nvidia.com] > Sent: Tuesday, March 2, 2021 4:27 PM > > rename the key opaque pointer from rte_tls_key to > rte_thread_key to avoid confusion with transport layer security. > > Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> [...] > diff --git a/lib/librte_eal/include/rte_thread.h > b/lib/librte_eal/include/rte_thread.h > index 39737d1829..e44be3d252 100644 > --- a/lib/librte_eal/include/rte_thread.h > +++ b/lib/librte_eal/include/rte_thread.h > @@ -23,7 +23,7 @@ extern "C" { > /** > * TLS key type, an opaque pointer. > */ > -typedef struct eal_tls_key *rte_tls_key; > +typedef struct eal_tls_key *rte_thread_key; Yes. > > /** > * Set core affinity of the current thread. > @@ -63,7 +63,8 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); > */ > > __rte_experimental > -int rte_thread_tls_key_create(rte_tls_key *key, void > (*destructor)(void *)); > +int rte_thread_tls_key_create(rte_thread_key *key, > + void (*destructor)(void *)); > Also get rid of the redundant name in the functions: rte_thread_tls_xyz() -> rte_thread_xyz() ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] eal: rename key opaque pointer in TLS API 2021-03-02 15:36 ` Morten Brørup @ 2021-03-04 11:16 ` Tal Shnaiderman 0 siblings, 0 replies; 29+ messages in thread From: Tal Shnaiderman @ 2021-03-04 11:16 UTC (permalink / raw) To: Morten Brørup, dev Cc: NBU-Contact-Thomas Monjalon, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym, david.marchand, anatoly.burakov, vladimir.medvedkin > Subject: RE: [PATCH v2 2/2] eal: rename key opaque pointer in TLS API > > External email: Use caution opening links or attachments > > > > From: Tal Shnaiderman [mailto:talshn@nvidia.com] > > Sent: Tuesday, March 2, 2021 4:27 PM > > > > rename the key opaque pointer from rte_tls_key to rte_thread_key to > > avoid confusion with transport layer security. > > > > Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> > > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com> > > [...] > > > diff --git a/lib/librte_eal/include/rte_thread.h > > b/lib/librte_eal/include/rte_thread.h > > index 39737d1829..e44be3d252 100644 > > --- a/lib/librte_eal/include/rte_thread.h > > +++ b/lib/librte_eal/include/rte_thread.h > > @@ -23,7 +23,7 @@ extern "C" { > > /** > > * TLS key type, an opaque pointer. > > */ > > -typedef struct eal_tls_key *rte_tls_key; > > +typedef struct eal_tls_key *rte_thread_key; > > Yes. > > > > > /** > > * Set core affinity of the current thread. > > @@ -63,7 +63,8 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp); > > */ > > > > __rte_experimental > > -int rte_thread_tls_key_create(rte_tls_key *key, void > > (*destructor)(void *)); > > +int rte_thread_tls_key_create(rte_thread_key *key, > > + void (*destructor)(void *)); > > > > Also get rid of the redundant name in the functions: > > rte_thread_tls_xyz() -> rte_thread_xyz() Right, will modify in v3, thanks. ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2021-03-26 8:27 UTC | newest] Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-03-02 15:26 [dpdk-dev] [PATCH v2 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-02 17:09 ` Dmitry Kozlyuk 2021-03-03 10:37 ` Tal Shnaiderman 2021-03-03 11:10 ` Dmitry Kozlyuk 2021-03-03 11:53 ` Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-10 19:45 ` Narcisa Ana Maria Vasile 2021-03-15 15:37 ` Tal Shnaiderman 2021-03-13 2:29 ` Dmitry Kozlyuk 2021-03-15 23:14 ` Thomas Monjalon 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 1/2] eal: error number enhancement for thread TLS API Tal Shnaiderman 2021-03-16 13:28 ` [dpdk-dev] [PATCH v6 2/2] eal: rename key opaque pointer and functions in " Tal Shnaiderman 2021-03-26 8:24 ` [dpdk-dev] [PATCH v6 0/2] EAL Thread TLS API enhancements Thomas Monjalon 2021-03-16 9:15 ` [dpdk-dev] [PATCH v5 2/2] eal: rename key opaque pointer and functions in TLS API Tal Shnaiderman 2021-03-10 12:48 ` [dpdk-dev] [PATCH v4 " Tal Shnaiderman 2021-03-15 23:16 ` Thomas Monjalon 2021-03-16 9:17 ` Tal Shnaiderman 2021-03-10 12:06 ` [dpdk-dev] [PATCH v3 " Tal Shnaiderman 2021-03-10 12:22 ` Morten Brørup 2021-03-02 15:26 ` [dpdk-dev] [PATCH v2 2/2] eal: rename key opaque pointer " Tal Shnaiderman 2021-03-02 15:36 ` Morten Brørup 2021-03-04 11:16 ` Tal Shnaiderman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).