[dpdk-dev] [PATCH v6 01/10] eal: add thread id and simple thread functions

Dmitry Kozlyuk dmitry.kozliuk at gmail.com
Thu Apr 29 02:50:29 CEST 2021


2021-04-02 18:38 (UTC-0700), Narcisa Ana Maria Vasile:
> From: Narcisa Vasile <navasile at microsoft.com>
> 
> Add the thread identifier type.
> Add functions for comparing thread ids and obtaining the thread id
> for the current thread.
> 
> Signed-off-by: Narcisa Vasile <navasile at microsoft.com>
> ---

(For the whole series.)
Please summarize and distribute relevant parts of the cover letter to commit
messages. Remember that cover letter doesn't get to commit log. This series
has subtle details that a good commit message should describe.

> diff --git a/lib/librte_eal/include/rte_thread_types.h b/lib/librte_eal/include/rte_thread_types.h
> new file mode 100644
> index 000000000..19fb85e38
> --- /dev/null
> +++ b/lib/librte_eal/include/rte_thread_types.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2021 Microsoft Corporation
> + */
> +
> +#ifndef _RTE_THREAD_TYPES_H_
> +#define _RTE_THREAD_TYPES_H_
> +
> +#include <pthread.h>
> +
> +typedef pthread_t                       rte_thread_t;
> +
> +#endif /* _RTE_THREAD_TYPES_H_ */
> diff --git a/lib/librte_eal/windows/include/rte_windows_thread_types.h b/lib/librte_eal/windows/include/rte_windows_thread_types.h
> new file mode 100644
> index 000000000..ebd3d9e8f
> --- /dev/null
> +++ b/lib/librte_eal/windows/include/rte_windows_thread_types.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2021 Microsoft Corporation
> + */
> +
> +#ifndef _RTE_THREAD_TYPES_H_
> +#define _RTE_THREAD_TYPES_H_
> +
> +#include <rte_windows.h>
> +
> +typedef DWORD                       rte_thread_t;
> +
> +#endif /* _RTE_THREAD_TYPES_H_ */

pthread_t type in pthreads-win32 and winpthread is not 32 bit.
DPDK will have different ABI depending on a threading backend used.
Apps must know it at build time then. How do they discover it?
This is worth a warning in commit log and docs.

> diff --git a/lib/librte_eal/windows/rte_thread.c b/lib/librte_eal/windows/rte_thread.c
> index 667287c38..940d9c653 100644
> --- a/lib/librte_eal/windows/rte_thread.c
> +++ b/lib/librte_eal/windows/rte_thread.c
> @@ -1,5 +1,6 @@
>  /* SPDX-License-Identifier: BSD-3-Clause
>   * Copyright 2021 Mellanox Technologies, Ltd
> + * Copyright(c) 2021 Microsoft Corporation
>   */
>  
>  #include <rte_common.h>
> @@ -11,6 +12,18 @@ struct eal_tls_key {
>  	DWORD thread_index;
>  };
>  
> +rte_thread_t
> +rte_thread_self(void)
> +{
> +	return GetCurrentThreadId();
> +}
> +
> +int
> +rte_thread_equal(rte_thread_t t1, rte_thread_t t2)
> +{
> +	return t1 == t2 ? 1 : 0;
> +}
> +

"a == b" returns (int)0 or (int)1 in C.



More information about the dev mailing list