[PATCH v18 2/8] eal: add thread attributes

Ananyev, Konstantin konstantin.ananyev at intel.com
Fri Feb 4 20:21:10 CET 2022


> Implement thread attributes for:
> * thread affinity
> * thread priority
> Implement functions for managing thread attributes.
> 
> Priority is represented through an enum that allows for two levels:
> 	- RTE_THREAD_PRIORITY_NORMAL
> 	- RTE_THREAD_PRIORITY_REALTIME_CRITICAL
> 
> Affinity is described by the rte_cpuset_t type.
> 
> An rte_thread_attr_t object can be set to the default values
> by calling rte_thread_attr_init().
> 
> Signed-off-by: Narcisa Vasile <navasile at microsoft.com>
> ---
>  lib/eal/common/rte_thread.c  | 46 ++++++++++++++++++
>  lib/eal/include/rte_thread.h | 91 ++++++++++++++++++++++++++++++++++++
>  lib/eal/version.map          |  4 ++
>  lib/eal/windows/rte_thread.c | 44 +++++++++++++++++
>  4 files changed, 185 insertions(+)
> 
> diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c
> index 92a7451b0a..27ad1c7eb0 100644
> --- a/lib/eal/common/rte_thread.c
> +++ b/lib/eal/common/rte_thread.c
> @@ -9,6 +9,7 @@
>  #include <string.h>
> 
>  #include <rte_common.h>
> +#include <rte_debug.h>
>  #include <rte_errno.h>
>  #include <rte_log.h>
>  #include <rte_thread.h>
> @@ -33,6 +34,51 @@ rte_thread_equal(rte_thread_t t1, rte_thread_t t2)
>  	return pthread_equal((pthread_t)t1.opaque_id, (pthread_t)t2.opaque_id);
>  }
> 
> +int
> +rte_thread_attr_init(rte_thread_attr_t *attr)
> +{
> +	RTE_VERIFY(attr != NULL);

As a generic one, here and everywhere:
Please don't use RTE_VERIFY() for checking input function parameters.
We don't want to panic in case of just invalid parameter from user.

> +
> +	CPU_ZERO(&attr->cpuset);
> +	attr->priority = RTE_THREAD_PRIORITY_NORMAL;
> +
> +	return 0;
> +}
> +


More information about the dev mailing list