From patchwork Wed Jun 22 20:26:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113271 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B374A034C; Wed, 22 Jun 2022 22:26:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6D0C42820; Wed, 22 Jun 2022 22:26:28 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 478AA40DDD for ; Wed, 22 Jun 2022 22:26:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 6A25B20C6379; Wed, 22 Jun 2022 13:26:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6A25B20C6379 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655929583; bh=oRnxeCOWdKAFeOzRM9kS/UiAi6NAsR8AzsZjE0eB8+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RmfGHlZwKcfAMhvj4ryKXHEh9swYIRnfKNo0DTh216+/8O/1pA7qiQJDO+hwc3SMF p4Mr0d8liZQDkJB5IgjKfdMbo8MHb89xP9GSNBLfyO8n6OGbg+9Avy9ixmBoZoaKT8 dNPxPGhdcgOWKnTOx8qj3WR5PRjnueFnRTnTN0zk= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff , Narcisa Vasile Subject: [PATCH v3 1/6] eal: add thread attributes Date: Wed, 22 Jun 2022 13:26:16 -0700 Message-Id: <1655929581-12366-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Signed-off-by: Tyler Retzlaff --- lib/eal/common/meson.build | 1 + lib/eal/common/rte_thread.c | 60 ++++++++++++++++++++++++++++ lib/eal/include/rte_thread.h | 93 ++++++++++++++++++++++++++++++++++++++++++++ lib/eal/version.map | 4 ++ 4 files changed, 158 insertions(+) create mode 100644 lib/eal/common/rte_thread.c diff --git a/lib/eal/common/meson.build b/lib/eal/common/meson.build index 917758c..1e77dba 100644 --- a/lib/eal/common/meson.build +++ b/lib/eal/common/meson.build @@ -36,6 +36,7 @@ sources += files( 'rte_random.c', 'rte_reciprocal.c', 'rte_service.c', + 'rte_thread.c', 'rte_version.c', ) if is_linux or is_windows diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c new file mode 100644 index 0000000..d204cc5 --- /dev/null +++ b/lib/eal/common/rte_thread.c @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2022 Microsoft Corporation + */ + +#include +#include + +int +rte_thread_attr_init(rte_thread_attr_t *attr) +{ + if (attr == NULL) + return EINVAL; + + CPU_ZERO(&attr->cpuset); + attr->priority = RTE_THREAD_PRIORITY_NORMAL; + + return 0; +} + +int +rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, + rte_cpuset_t *cpuset) +{ + if (thread_attr == NULL) + return EINVAL; + + if (cpuset == NULL) + return EINVAL; + + thread_attr->cpuset = *cpuset; + + return 0; +} + +int +rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, + rte_cpuset_t *cpuset) +{ + if (thread_attr == NULL) + return EINVAL; + + if (cpuset == NULL) + return EINVAL; + + *cpuset = thread_attr->cpuset; + + return 0; +} + +int +rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, + enum rte_thread_priority priority) +{ + if (thread_attr == NULL) + return EINVAL; + + thread_attr->priority = priority; + + return 0; +} diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 9e261bf..062308d 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -40,6 +40,18 @@ enum rte_thread_priority { /**< highest thread priority allowed */ }; +#ifdef RTE_HAS_CPUSET + +/** + * Representation for thread attributes. + */ +typedef struct { + enum rte_thread_priority priority; /**< thread priority */ + rte_cpuset_t cpuset; /**< thread affinity */ +} rte_thread_attr_t; + +#endif /* RTE_HAS_CPUSET */ + /** * TLS key type, an opaque pointer. */ @@ -63,6 +75,87 @@ enum rte_thread_priority { * @warning * @b EXPERIMENTAL: this API may change without prior notice. * + * Initialize the attributes of a thread. + * These attributes can be passed to the rte_thread_create() function + * that will create a new thread and set its attributes according to attr. + * + * @param attr + * Thread attributes to initialize. + * + * @return + * On success, return 0. + * On failure, return a positive errno-style error number. + */ +__rte_experimental +int rte_thread_attr_init(rte_thread_attr_t *attr); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Set the CPU affinity value in the thread attributes pointed to + * by 'thread_attr'. + * + * @param thread_attr + * Points to the thread attributes in which affinity will be updated. + * + * @param cpuset + * Points to the value of the affinity to be set. + * + * @return + * On success, return 0. + * On failure, return a positive errno-style error number. + */ +__rte_experimental +int rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, + rte_cpuset_t *cpuset); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get the value of CPU affinity that is set in the thread attributes pointed + * to by 'thread_attr'. + * + * @param thread_attr + * Points to the thread attributes from which affinity will be retrieved. + * + * @param cpuset + * Pointer to the memory that will store the affinity. + * + * @return + * On success, return 0. + * On failure, return a positive errno-style error number. + */ +__rte_experimental +int rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, + rte_cpuset_t *cpuset); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Set the thread priority value in the thread attributes pointed to + * by 'thread_attr'. + * + * @param thread_attr + * Points to the thread attributes in which priority will be updated. + * + * @param priority + * Points to the value of the priority to be set. + * + * @return + * On success, return 0. + * On failure, return a positive errno-style error number. + */ +__rte_experimental +int rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, + enum rte_thread_priority priority); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * * Set the affinity of thread 'thread_id' to the cpu set * specified by 'cpuset'. * diff --git a/lib/eal/version.map b/lib/eal/version.map index 5e6d851..ba03528 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -423,6 +423,10 @@ EXPERIMENTAL { # added in 22.07 rte_drand; + rte_thread_attr_get_affinity; + rte_thread_attr_init; + rte_thread_attr_set_affinity; + rte_thread_attr_set_priority; rte_thread_get_affinity_by_id; rte_thread_get_priority; rte_thread_self; From patchwork Wed Jun 22 20:26:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113272 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B3850A034C; Wed, 22 Jun 2022 22:26:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAA244282D; Wed, 22 Jun 2022 22:26:29 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 47E9D427EE for ; Wed, 22 Jun 2022 22:26:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 7634E20C637C; Wed, 22 Jun 2022 13:26:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7634E20C637C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655929583; bh=y4S3hQdFy/4xquK75Wcmktm1n1XoYdk3BI25ln+CRFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lduASZVJA018z1kt6zql75cZm9ZjUjeB5p/0QF6YEt2cAJfNaWL1DjefPdXvKuxwE n7wDo2Q+3d/ew6MtPaB7QXnjs0ink8/nBh8QOaMJ4tPBJj0wYncfazOnitvGnIrh+q MIVUOPbGYQtCyPYARFdRx2CwN2gBI/wq+79dSY3s= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff , Narcisa Vasile Subject: [PATCH v3 2/6] eal: add thread lifetime management Date: Wed, 22 Jun 2022 13:26:17 -0700 Message-Id: <1655929581-12366-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The *rte_thread_create()* function can optionally receive an rte_thread_attr_t object that will cause the thread to be created with the affinity and priority described by the attributes object. If no rte_thread_attr_t is passed (parameter is NULL), the default affinity and priority are used. On Windows, the function executed by a thread when the thread starts is represeneted by a function pointer of type DWORD (*func) (void*). On other platforms, the function pointer is a void* (*func) (void*). Performing a cast between these two types of function pointers to uniformize the API on all platforms may result in undefined behavior. TO fix this issue, a wrapper that respects the signature required by CreateThread() has been created on Windows. Signed-off-by: Narcisa Vasile Signed-off-by: Tyler Retzlaff --- lib/eal/include/rte_thread.h | 75 ++++++++++++++ lib/eal/unix/rte_thread.c | 135 +++++++++++++++++++++++++ lib/eal/version.map | 3 + lib/eal/windows/include/sched.h | 2 +- lib/eal/windows/rte_thread.c | 213 ++++++++++++++++++++++++++++++++-------- 5 files changed, 387 insertions(+), 41 deletions(-) diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 062308d..9e80270 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -31,6 +31,18 @@ } rte_thread_t; /** + * Thread function + * + * Function pointer to thread start routine. + * + * @param arg + * Argument passed to rte_thread_create(). + * @return + * Thread function exit value. + */ +typedef uint32_t (*rte_thread_func) (void *); + +/** * Thread priority values. */ enum rte_thread_priority { @@ -61,6 +73,69 @@ enum rte_thread_priority { * @warning * @b EXPERIMENTAL: this API may change without prior notice. * + * Create a new thread that will invoke the 'thread_func' routine. + * + * @param thread_id + * A pointer that will store the id of the newly created thread. + * + * @param thread_attr + * Attributes that are used at the creation of the new thread. + * + * @param thread_func + * The routine that the new thread will invoke when starting execution. + * + * @param arg + * Argument to be passed to the 'thread_func' routine. + * + * @return + * On success, return 0. + * On failure, return a positive errno-style error number. + */ +__rte_experimental +int rte_thread_create(rte_thread_t *thread_id, + const rte_thread_attr_t *thread_attr, + rte_thread_func thread_func, void *arg); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Waits for the thread identified by 'thread_id' to terminate + * + * @param thread_id + * The identifier of the thread. + * + * @param value_ptr + * Stores the exit status of the thread. + * + * @return + * On success, return 0. + * On failure, return a positive errno-style error number. + */ +__rte_experimental +int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Indicate that the return value of the thread is not needed and + * all thread resources should be release when the thread terminates. + * + * @param thread_id + * The id of the thread to be detached. + * + * @return + * On success, return 0. + * On failure, return a positive errno-style error number. + */ +__rte_experimental +int rte_thread_detach(rte_thread_t thread_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * * Get the id of the calling thread. * * @return diff --git a/lib/eal/unix/rte_thread.c b/lib/eal/unix/rte_thread.c index 9126595..d4c1a7f 100644 --- a/lib/eal/unix/rte_thread.c +++ b/lib/eal/unix/rte_thread.c @@ -16,6 +16,11 @@ struct eal_tls_key { pthread_key_t thread_index; }; +struct thread_routine_ctx { + rte_thread_func thread_func; + void *routine_args; +}; + static int thread_map_priority_to_os_value(enum rte_thread_priority eal_pri, int *os_pri, int *pol) @@ -75,6 +80,136 @@ struct eal_tls_key { return 0; } +static void * +thread_func_wrapper(void *arg) +{ + struct thread_routine_ctx ctx = *(struct thread_routine_ctx *)arg; + + free(arg); + + return (void *)(uintptr_t)ctx.thread_func(ctx.routine_args); +} + +int +rte_thread_create(rte_thread_t *thread_id, + const rte_thread_attr_t *thread_attr, + rte_thread_func thread_func, void *args) +{ + int ret = 0; + pthread_attr_t attr; + pthread_attr_t *attrp = NULL; + struct thread_routine_ctx *ctx; + struct sched_param param = { + .sched_priority = 0, + }; + int policy = SCHED_OTHER; + + ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + RTE_LOG(DEBUG, EAL, "Insufficient memory for thread context allocations\n"); + ret = ENOMEM; + goto cleanup; + } + ctx->routine_args = args; + ctx->thread_func = thread_func; + + if (thread_attr != NULL) { + ret = pthread_attr_init(&attr); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "pthread_attr_init failed\n"); + goto cleanup; + } + + attrp = &attr; + + /* + * Set the inherit scheduler parameter to explicit, + * otherwise the priority attribute is ignored. + */ + ret = pthread_attr_setinheritsched(attrp, + PTHREAD_EXPLICIT_SCHED); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "pthread_attr_setinheritsched failed\n"); + goto cleanup; + } + + + if (thread_attr->priority == + RTE_THREAD_PRIORITY_REALTIME_CRITICAL) { + ret = ENOTSUP; + goto cleanup; + } + ret = thread_map_priority_to_os_value(thread_attr->priority, + ¶m.sched_priority, &policy); + if (ret != 0) + goto cleanup; + + ret = pthread_attr_setschedpolicy(attrp, policy); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "pthread_attr_setschedpolicy failed\n"); + goto cleanup; + } + + ret = pthread_attr_setschedparam(attrp, ¶m); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "pthread_attr_setschedparam failed\n"); + goto cleanup; + } + } + + ret = pthread_create((pthread_t *)&thread_id->opaque_id, attrp, + thread_func_wrapper, ctx); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "pthread_create failed\n"); + goto cleanup; + } + + if (thread_attr != NULL && CPU_COUNT(&thread_attr->cpuset) > 0) { + ret = rte_thread_set_affinity_by_id(*thread_id, + &thread_attr->cpuset); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "rte_thread_set_affinity_by_id failed\n"); + goto cleanup; + } + } + + ctx = NULL; +cleanup: + free(ctx); + if (attrp != NULL) + pthread_attr_destroy(&attr); + + return ret; +} + +int +rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr) +{ + int ret = 0; + void *res = (void *)(uintptr_t)0; + void **pres = NULL; + + if (value_ptr != NULL) + pres = &res; + + ret = pthread_join((pthread_t)thread_id.opaque_id, pres); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "pthread_join failed\n"); + return ret; + } + + if (value_ptr != NULL) + *value_ptr = (uint32_t)(uintptr_t)res; + + return 0; +} + +int +rte_thread_detach(rte_thread_t thread_id) +{ + return pthread_detach((pthread_t)thread_id.opaque_id); +} + rte_thread_t rte_thread_self(void) { diff --git a/lib/eal/version.map b/lib/eal/version.map index ba03528..0b26652 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -427,8 +427,11 @@ EXPERIMENTAL { rte_thread_attr_init; rte_thread_attr_set_affinity; rte_thread_attr_set_priority; + rte_thread_create; + rte_thread_detach; rte_thread_get_affinity_by_id; rte_thread_get_priority; + rte_thread_join; rte_thread_self; rte_thread_set_affinity_by_id; rte_thread_set_priority; diff --git a/lib/eal/windows/include/sched.h b/lib/eal/windows/include/sched.h index bc31cc8..912fed1 100644 --- a/lib/eal/windows/include/sched.h +++ b/lib/eal/windows/include/sched.h @@ -44,7 +44,7 @@ (1LL << _WHICH_BIT(b))) != 0LL) static inline int -count_cpu(rte_cpuset_t *s) +count_cpu(const rte_cpuset_t *s) { unsigned int _i; int count = 0; diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c index 0771525..ad71be4 100644 --- a/lib/eal/windows/rte_thread.c +++ b/lib/eal/windows/rte_thread.c @@ -13,6 +13,11 @@ struct eal_tls_key { DWORD thread_index; }; +struct thread_routine_ctx { + rte_thread_func thread_func; + void *routine_args; +}; + /* Translates the most common error codes related to threads */ static int thread_translate_win32_error(DWORD error) @@ -114,6 +119,174 @@ struct eal_tls_key { return 0; } +static int +convert_cpuset_to_affinity(const rte_cpuset_t *cpuset, + PGROUP_AFFINITY affinity) +{ + int ret = 0; + PGROUP_AFFINITY cpu_affinity = NULL; + unsigned int cpu_idx; + + memset(affinity, 0, sizeof(GROUP_AFFINITY)); + affinity->Group = (USHORT)-1; + + /* Check that all cpus of the set belong to the same processor group and + * accumulate thread affinity to be applied. + */ + for (cpu_idx = 0; cpu_idx < CPU_SETSIZE; cpu_idx++) { + if (!CPU_ISSET(cpu_idx, cpuset)) + continue; + + cpu_affinity = eal_get_cpu_affinity(cpu_idx); + + if (affinity->Group == (USHORT)-1) { + affinity->Group = cpu_affinity->Group; + } else if (affinity->Group != cpu_affinity->Group) { + RTE_LOG(DEBUG, EAL, "All processors must belong to the same processor group\n"); + ret = ENOTSUP; + goto cleanup; + } + + affinity->Mask |= cpu_affinity->Mask; + } + + if (affinity->Mask == 0) { + ret = EINVAL; + goto cleanup; + } + +cleanup: + return ret; +} + +static DWORD +thread_func_wrapper(void *arg) +{ + struct thread_routine_ctx ctx = *(struct thread_routine_ctx *)arg; + + free(arg); + + return (DWORD)ctx.thread_func(ctx.routine_args); +} + +int +rte_thread_create(rte_thread_t *thread_id, + const rte_thread_attr_t *thread_attr, + rte_thread_func thread_func, void *args) +{ + int ret = 0; + DWORD tid; + HANDLE thread_handle = NULL; + GROUP_AFFINITY thread_affinity; + struct thread_routine_ctx *ctx; + + ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + RTE_LOG(DEBUG, EAL, "Insufficient memory for thread context allocations\n"); + ret = ENOMEM; + goto cleanup; + } + ctx->routine_args = args; + ctx->thread_func = thread_func; + + thread_handle = CreateThread(NULL, 0, thread_func_wrapper, ctx, + CREATE_SUSPENDED, &tid); + if (thread_handle == NULL) { + ret = thread_log_last_error("CreateThread()"); + goto cleanup; + } + thread_id->opaque_id = tid; + + if (thread_attr != NULL) { + if (CPU_COUNT(&thread_attr->cpuset) > 0) { + ret = convert_cpuset_to_affinity( + &thread_attr->cpuset, + &thread_affinity + ); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "Unable to convert cpuset to thread affinity\n"); + goto cleanup; + } + + if (!SetThreadGroupAffinity(thread_handle, + &thread_affinity, NULL)) { + ret = thread_log_last_error("SetThreadGroupAffinity()"); + goto cleanup; + } + } + ret = rte_thread_set_priority(*thread_id, + thread_attr->priority); + if (ret != 0) { + RTE_LOG(DEBUG, EAL, "Unable to set thread priority\n"); + goto cleanup; + } + } + + if (ResumeThread(thread_handle) == (DWORD)-1) { + ret = thread_log_last_error("ResumeThread()"); + goto cleanup; + } + + ctx = NULL; +cleanup: + free(ctx); + if (thread_handle != NULL) { + CloseHandle(thread_handle); + thread_handle = NULL; + } + + return ret; +} + +int +rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr) +{ + HANDLE thread_handle; + DWORD result; + DWORD exit_code = 0; + BOOL err; + int ret = 0; + + thread_handle = OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION, + FALSE, thread_id.opaque_id); + if (thread_handle == NULL) { + ret = thread_log_last_error("OpenThread()"); + goto cleanup; + } + + result = WaitForSingleObject(thread_handle, INFINITE); + if (result != WAIT_OBJECT_0) { + ret = thread_log_last_error("WaitForSingleObject()"); + goto cleanup; + } + + if (value_ptr != NULL) { + err = GetExitCodeThread(thread_handle, &exit_code); + if (err == 0) { + ret = thread_log_last_error("GetExitCodeThread()"); + goto cleanup; + } + *value_ptr = exit_code; + } + +cleanup: + if (thread_handle != NULL) { + CloseHandle(thread_handle); + thread_handle = NULL; + } + + return ret; +} + +int +rte_thread_detach(rte_thread_t thread_id) +{ + /* No resources that need to be released. */ + RTE_SET_USED(thread_id); + + return 0; +} + rte_thread_t rte_thread_self(void) { @@ -278,46 +451,6 @@ struct eal_tls_key { return output; } -static int -convert_cpuset_to_affinity(const rte_cpuset_t *cpuset, - PGROUP_AFFINITY affinity) -{ - int ret = 0; - PGROUP_AFFINITY cpu_affinity = NULL; - unsigned int cpu_idx; - - memset(affinity, 0, sizeof(GROUP_AFFINITY)); - affinity->Group = (USHORT)-1; - - /* Check that all cpus of the set belong to the same processor group and - * accumulate thread affinity to be applied. - */ - for (cpu_idx = 0; cpu_idx < CPU_SETSIZE; cpu_idx++) { - if (!CPU_ISSET(cpu_idx, cpuset)) - continue; - - cpu_affinity = eal_get_cpu_affinity(cpu_idx); - - if (affinity->Group == (USHORT)-1) { - affinity->Group = cpu_affinity->Group; - } else if (affinity->Group != cpu_affinity->Group) { - RTE_LOG(DEBUG, EAL, "All processors must belong to the same processor group\n"); - ret = ENOTSUP; - goto cleanup; - } - - affinity->Mask |= cpu_affinity->Mask; - } - - if (affinity->Mask == 0) { - ret = EINVAL; - goto cleanup; - } - -cleanup: - return ret; -} - int rte_thread_set_affinity_by_id(rte_thread_t thread_id, const rte_cpuset_t *cpuset) From patchwork Wed Jun 22 20:26:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113269 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8C28A034C; Wed, 22 Jun 2022 22:26:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3B5B427F3; Wed, 22 Jun 2022 22:26:26 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 3ED7B40A87 for ; Wed, 22 Jun 2022 22:26:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8282B20C637F; Wed, 22 Jun 2022 13:26:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8282B20C637F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655929583; bh=8myuN1mf66XnLTzxELZzPOty2SnTBPPlYDBZdCJdx2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjnLjcu2i5aJMmnwWr8LlEdVi007dxVQad3vAuUWgfhehj2NpyobXS6N4oU6VG7jd CZqUTvVBgfF7S/mN+j82pdAIfSlRdkveJ2HCs/Qp7iani9X1zS+l1lnHIIS83NqLRI a0QUnR/YXD0PfZKHnii60v5YPcHGHIrpg0i7mwv0= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff , Narcisa Vasile Subject: [PATCH v3 3/6] eal: add basic rte thread ID equal API Date: Wed, 22 Jun 2022 13:26:18 -0700 Message-Id: <1655929581-12366-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add rte_thread_equal() that tests if two rte_thread_id are equal. Signed-off-by: Narcisa Vasile Signed-off-by: Tyler Retzlaff Acked-by: Chengwen Feng Acked-by: Konstantin Ananyev --- lib/eal/include/rte_thread.h | 19 +++++++++++++++++++ lib/eal/unix/rte_thread.c | 6 ++++++ lib/eal/version.map | 1 + lib/eal/windows/rte_thread.c | 6 ++++++ 4 files changed, 32 insertions(+) diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 9e80270..ca6d9a2 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -144,6 +144,25 @@ int rte_thread_create(rte_thread_t *thread_id, __rte_experimental rte_thread_t rte_thread_self(void); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Check if 2 thread ids are equal. + * + * @param t1 + * First thread id. + * + * @param t2 + * Second thread id. + * + * @return + * If the ids are equal, return nonzero. + * Otherwise, return 0. + */ +__rte_experimental +int rte_thread_equal(rte_thread_t t1, rte_thread_t t2); + #ifdef RTE_HAS_CPUSET /** diff --git a/lib/eal/unix/rte_thread.c b/lib/eal/unix/rte_thread.c index d4c1a7f..37ebfcf 100644 --- a/lib/eal/unix/rte_thread.c +++ b/lib/eal/unix/rte_thread.c @@ -210,6 +210,12 @@ struct thread_routine_ctx { return pthread_detach((pthread_t)thread_id.opaque_id); } +int +rte_thread_equal(rte_thread_t t1, rte_thread_t t2) +{ + return pthread_equal((pthread_t)t1.opaque_id, (pthread_t)t2.opaque_id); +} + rte_thread_t rte_thread_self(void) { diff --git a/lib/eal/version.map b/lib/eal/version.map index 0b26652..9096075 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -429,6 +429,7 @@ EXPERIMENTAL { rte_thread_attr_set_priority; rte_thread_create; rte_thread_detach; + rte_thread_equal; rte_thread_get_affinity_by_id; rte_thread_get_priority; rte_thread_join; diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c index ad71be4..1bc648e 100644 --- a/lib/eal/windows/rte_thread.c +++ b/lib/eal/windows/rte_thread.c @@ -287,6 +287,12 @@ struct thread_routine_ctx { return 0; } +int +rte_thread_equal(rte_thread_t t1, rte_thread_t t2) +{ + return t1.opaque_id == t2.opaque_id; +} + rte_thread_t rte_thread_self(void) { From patchwork Wed Jun 22 20:26:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113270 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 985D6A034C; Wed, 22 Jun 2022 22:26:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C597D4280C; Wed, 22 Jun 2022 22:26:27 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 434DD40DDB for ; Wed, 22 Jun 2022 22:26:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8E77920C63B8; Wed, 22 Jun 2022 13:26:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8E77920C63B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655929583; bh=PZpfXfqBrNpCcrV1uvUHJEFZcfcJRmUS3feN+g5euCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmTm867e1tYWXxodMj7rInC8XwHMFjIEyWT4M1n5tvzNt2Uz3kZdrjKUaD8J+ngw9 C/0tY4mNQeDTMw/FChgs8Q3a5L6F8xJcUKSNmGikmyS56bbtxatFcNgJNJqJTSqBVu ELJxU7XL12ZgdgpXaB6ovJbto/PX1S/BHMTZoI3E= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff , Narcisa Vasile Subject: [PATCH v3 4/6] test/threads: add tests for thread lifetime API Date: Wed, 22 Jun 2022 13:26:19 -0700 Message-Id: <1655929581-12366-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org test basic functionality and demonstrate use of following thread lifetime api. * rte_thread_create * rte_thread_detach * rte_thread_join Signed-off-by: Narcisa Vasile Signed-off-by: Tyler Retzlaff --- app/test/test_threads.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/app/test/test_threads.c b/app/test/test_threads.c index b9d8b4e..1077373 100644 --- a/app/test/test_threads.c +++ b/app/test/test_threads.c @@ -14,7 +14,7 @@ static uint32_t thread_id_ready; -static void * +static uint32_t thread_main(void *arg) { *(rte_thread_t *)arg = rte_thread_self(); @@ -23,7 +23,55 @@ while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 1) ; - return NULL; + return 0; +} + +static int +test_thread_create_join(void) +{ + rte_thread_t thread_id; + rte_thread_t thread_main_id; + + thread_id_ready = 0; + RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, &thread_main_id) == 0, + "Failed to create thread."); + + while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) + ; + + RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0, + "Unexpected thread id."); + + __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE); + + RTE_TEST_ASSERT(rte_thread_join(thread_id, NULL) == 0, + "Failed to join thread."); + + return 0; +} + +static int +test_thread_create_detach(void) +{ + rte_thread_t thread_id; + rte_thread_t thread_main_id; + + thread_id_ready = 0; + RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, + &thread_main_id) == 0, "Failed to create thread."); + + while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) + ; + + RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0, + "Unexpected thread id."); + + __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE); + + RTE_TEST_ASSERT(rte_thread_detach(thread_id) == 0, + "Failed to detach thread."); + + return 0; } static int @@ -123,6 +171,8 @@ .setup = NULL, .teardown = NULL, .unit_test_cases = { + TEST_CASE(test_thread_create_join), + TEST_CASE(test_thread_create_detach), TEST_CASE(test_thread_affinity), TEST_CASE(test_thread_priority), TEST_CASES_END() From patchwork Wed Jun 22 20:26:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113274 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CAAEFA034C; Wed, 22 Jun 2022 22:26:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9F1A42B70; Wed, 22 Jun 2022 22:26:31 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E3A7A40A87 for ; Wed, 22 Jun 2022 22:26:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 9B06120C63BA; Wed, 22 Jun 2022 13:26:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9B06120C63BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655929583; bh=zeHqsHFqZMlHno0wQqyQ0Rw0Havhv99bdHBA8u0g8bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+hpdmXGKUCUUYs27U3h/eumVLmAIq3uDZ2+qF4kTFkGbEgF/WQIfey+Oo4Gys9GF tbAnNdUq50eWaypfkL/3+qms1DuNAgl8H2L1wxxUKCFuBcnQCI6QvWwlTte0ep7ndF 2DcwPIML0cxO8XJ6a/fqIpH2DFWqmfGtmxtfgOkk= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff , Narcisa Vasile Subject: [PATCH v3 5/6] test/threads: add tests for thread attributes API Date: Wed, 22 Jun 2022 13:26:20 -0700 Message-Id: <1655929581-12366-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org test basic functionality and demonstrate use of following thread attributes api. additionally, test attributes are processed when supplied to rte_thread_create(). * rte_thread_attr_init * rte_thread_attr_set_affinity * rte_thread_attr_get_affinity * rte_thread_attr_set_priority Signed-off-by: Narcisa Vasile Signed-off-by: Tyler Retzlaff --- app/test/test_threads.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/app/test/test_threads.c b/app/test/test_threads.c index 1077373..3c22cec 100644 --- a/app/test/test_threads.c +++ b/app/test/test_threads.c @@ -17,7 +17,9 @@ static uint32_t thread_main(void *arg) { - *(rte_thread_t *)arg = rte_thread_self(); + if (arg != NULL) + *(rte_thread_t *)arg = rte_thread_self(); + __atomic_store_n(&thread_id_ready, 1, __ATOMIC_RELEASE); while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 1) @@ -166,6 +168,73 @@ return 0; } +static int +test_thread_attributes_affinity(void) +{ + rte_thread_t thread_id; + rte_thread_attr_t attr; + rte_cpuset_t cpuset0; + rte_cpuset_t cpuset1; + + RTE_TEST_ASSERT(rte_thread_attr_init(&attr) == 0, + "Failed to initialize thread attributes"); + + CPU_ZERO(&cpuset0); + RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset0) == 0, + "Failed to get thread affinity"); + RTE_TEST_ASSERT(rte_thread_attr_set_affinity(&attr, &cpuset0) == 0, + "Failed to set thread attributes affinity"); + RTE_TEST_ASSERT(rte_thread_attr_get_affinity(&attr, &cpuset1) == 0, + "Failed to get thread attributes affinity"); + RTE_TEST_ASSERT(memcmp(&cpuset0, &cpuset1, sizeof(rte_cpuset_t)) == 0, + "Affinity should be stable"); + + thread_id_ready = 0; + RTE_TEST_ASSERT(rte_thread_create(&thread_id, &attr, thread_main, NULL) == 0, + "Failed to create attributes affinity thread."); + + while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) + ; + + RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset1) == 0, + "Failed to get attributes thread affinity"); + RTE_TEST_ASSERT(memcmp(&cpuset0, &cpuset1, sizeof(rte_cpuset_t)) == 0, + "Failed to apply affinity attributes"); + + __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE); + + return 0; +} + +static int +test_thread_attributes_priority(void) +{ + rte_thread_t thread_id; + rte_thread_attr_t attr; + enum rte_thread_priority priority; + + RTE_TEST_ASSERT(rte_thread_attr_init(&attr) == 0, + "Failed to initialize thread attributes"); + RTE_TEST_ASSERT(rte_thread_attr_set_priority(&attr, RTE_THREAD_PRIORITY_NORMAL) == 0, + "Failed to set thread attributes priority"); + + thread_id_ready = 0; + RTE_TEST_ASSERT(rte_thread_create(&thread_id, &attr, thread_main, NULL) == 0, + "Failed to create attributes priority thread."); + + while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) + ; + + RTE_TEST_ASSERT(rte_thread_get_priority(thread_id, &priority) == 0, + "Failed to get thread priority"); + RTE_TEST_ASSERT(priority == RTE_THREAD_PRIORITY_NORMAL, + "Failed to apply priority attributes"); + + __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE); + + return 0; +} + static struct unit_test_suite threads_test_suite = { .suite_name = "threads autotest", .setup = NULL, @@ -175,6 +244,8 @@ TEST_CASE(test_thread_create_detach), TEST_CASE(test_thread_affinity), TEST_CASE(test_thread_priority), + TEST_CASE(test_thread_attributes_affinity), + TEST_CASE(test_thread_attributes_priority), TEST_CASES_END() } }; From patchwork Wed Jun 22 20:26:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113273 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA7C1A034C; Wed, 22 Jun 2022 22:26:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C30D242905; Wed, 22 Jun 2022 22:26:30 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E042F40A84 for ; Wed, 22 Jun 2022 22:26:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id A731D20C63BE; Wed, 22 Jun 2022 13:26:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A731D20C63BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655929583; bh=UXwiV7Ewp9JLKV7Fz+03ft2Qs+ZUroNz6eWlfc/SY+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jLKIjylDrv6YyP+GpnPry8xhRYCB82IDU2G1gVWp0wOJDxWO4F2pZygcjOxJqeGts Z22ZoXIVGRUbNk734+UEsFQ1rcGdKpVsdM9MYXK3L4cZlDJX4d/+lxzwf3JcOwCuUD k5qGKjiaZ0mx0bUH1/bqNIuferJv7//z1LxNf6/M= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff Subject: [PATCH v3 6/6] test/threads: remove unit test use of pthread Date: Wed, 22 Jun 2022 13:26:21 -0700 Message-Id: <1655929581-12366-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1655929581-12366-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org now that rte_thread provides thread lifetime functions stop using pthread in unit tests. Signed-off-by: Tyler Retzlaff --- app/test/test_threads.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/test/test_threads.c b/app/test/test_threads.c index 3c22cec..e0f18e4 100644 --- a/app/test/test_threads.c +++ b/app/test/test_threads.c @@ -3,7 +3,6 @@ */ #include -#include #include #include @@ -79,12 +78,11 @@ static int test_thread_priority(void) { - pthread_t id; rte_thread_t thread_id; enum rte_thread_priority priority; thread_id_ready = 0; - RTE_TEST_ASSERT(pthread_create(&id, NULL, thread_main, &thread_id) == 0, + RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, NULL) == 0, "Failed to create thread"); while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) @@ -131,13 +129,12 @@ static int test_thread_affinity(void) { - pthread_t id; rte_thread_t thread_id; rte_cpuset_t cpuset0; rte_cpuset_t cpuset1; thread_id_ready = 0; - RTE_TEST_ASSERT(pthread_create(&id, NULL, thread_main, &thread_id) == 0, + RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, NULL) == 0, "Failed to create thread"); while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)