[dpdk-dev] [PATCH 1/3] Add EAL threads API

Tal Shnaiderman talshn at nvidia.com
Thu Mar 18 15:48:01 CET 2021


> Subject: [dpdk-dev] [PATCH 1/3] Add EAL threads API
> 
> From: Narcisa Vasile <navasile at microsoft.com>
> 
> EAL must hide the environment specifics from apps and libraries.
> Add an EAL API for managing threads.
> 
> Signed-off-by: Narcisa Vasile <navasile at microsoft.com>
> Signed-off-by: Dmitry Malloy <dmitrym at microsoft.com>
> ---

Hi Naty, Dmitry, 

Thank you for adding those functions to the thread API.
This is a huge commit, I'd split it to separate patches, something like:

1) Move existing code to rte_thread.
2) Add empty stubs for new functions.
3) Implement OS functions for thread creation/join.
4) Implement OS functions for thread affinity.
5) Implement OS functions for thread priority.

>  lib/librte_eal/common/eal_common_thread.c     |   6 +-
>  lib/librte_eal/common/rte_thread.c            | 346 ++++++++++++
>  lib/librte_eal/include/rte_thread.h           | 323 ++++++++++-
>  lib/librte_eal/include/rte_thread_types.h     |  20 +
>  lib/librte_eal/windows/eal_lcore.c            | 167 ++++--
>  lib/librte_eal/windows/eal_windows.h          |  10 +
>  .../include/rte_windows_thread_types.h        |  19 +
>  lib/librte_eal/windows/rte_thread.c           | 507 +++++++++++++++++-
>  8 files changed, 1338 insertions(+), 60 deletions(-)  create mode 100644

<snip>

> --- a/lib/librte_eal/windows/rte_thread.c
> +++ b/lib/librte_eal/windows/rte_thread.c
> @@ -1,16 +1,503 @@
>  /* SPDX-License-Identifier: BSD-3-Clause
>   * Copyright 2021 Mellanox Technologies, Ltd
> + * Copyright(c) 2021 Microsoft Corporation
>   */
> 
>  #include <rte_common.h>
> -#include <rte_errno.h>
>  #include <rte_thread.h>
> -#include <rte_windows.h>
> +
> +#include "eal_windows.h"
> 
>  struct eal_tls_key {
>  	DWORD thread_index;
>  };
> 

I don't know if this table is needed, the approach should be to have the return value/rte_errno identical between the OSs.
And having the specific OS errno printed.

e.g. pthread_setschedparam On UNIX returns ESRCH when no thread id is found, the table below doesn't translate to it so Windows
will never return such error code, maybe use only the errnos below for all OSs? what do you think?

> +/* Translates the most common error codes related to threads */ static
> +int rte_thread_translate_win32_error(DWORD error) {
> +	switch (error) {
> +	case ERROR_SUCCESS:
> +		return 0;
> +
> +	case ERROR_INVALID_PARAMETER:
> +		return -EINVAL;
> +
> +	case ERROR_INVALID_HANDLE:
> +		return -EFAULT;
> +
> +	case ERROR_NOT_ENOUGH_MEMORY:
> +	/* FALLTHROUGH */
> +	case ERROR_NO_SYSTEM_RESOURCES:
> +		return -ENOMEM;
> +
> +	case ERROR_PRIVILEGE_NOT_HELD:
> +	/* FALLTHROUGH */
> +	case ERROR_ACCESS_DENIED:
> +		return -EACCES;
> +
> +	case ERROR_ALREADY_EXISTS:
> +		return -EEXIST;
> +
> +	case ERROR_POSSIBLE_DEADLOCK:
> +		return -EDEADLK;
> +
> +	case ERROR_INVALID_FUNCTION:
> +	/* FALLTHROUGH */
> +	case ERROR_CALL_NOT_IMPLEMENTED:
> +		return -ENOSYS;
> +
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return -EINVAL;
> +}
</snip>


More information about the dev mailing list