From patchwork Mon Jun 27 16:56:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113478 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 6E4C0A054F; Mon, 27 Jun 2022 18:56:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F356E42B77; Mon, 27 Jun 2022 18:56:14 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 116D2410EF for ; Mon, 27 Jun 2022 18:56:09 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1086A20CD16C; Mon, 27 Jun 2022 09:56:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1086A20CD16C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1656348968; bh=gaFtCBjuQmgBEfWpl9iAEKOURVp0BrzojvEd2FRFQzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QKqSSvDAM58BC/WcjhHaAuOKzMWC3t0KBixhfenW+9NWKdGedc76qYz9Di5HEqKmj xLT7TdyRQsJAgfcTVOLfMRBFSN+Ltz/GTHfaQA9+y1mmLNdebxnSYbOHxrHBUiQzjD sioJ0Vq8ZJpiUSIue9x1D6xwT8ywjRyidooZPjww= 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 v4 1/6] eal: add thread attributes Date: Mon, 27 Jun 2022 09:56:01 -0700 Message-Id: <1656348966-10194-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656348966-10194-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1656348966-10194-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 c2a2ceb..6d8f89a 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -419,6 +419,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 Mon Jun 27 16:56:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113477 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 20D7BA054F; Mon, 27 Jun 2022 18:56:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 822A842B73; Mon, 27 Jun 2022 18:56:13 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E0E5C40A8B for ; Mon, 27 Jun 2022 18:56:08 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1C97020CD16D; Mon, 27 Jun 2022 09:56:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1C97020CD16D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1656348968; bh=64Ociz/jIMZB6s1BGeWpzG9gMymMWkAnhzm6WFTfPME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMdAGBhzi3VmhXgcMBhxAqpFaDuWgz86nJTUEnGGYbXsf79f9gphJQpIWuBNza5Ro paxJ/+WjyVNI9LjpGQpt0pxqJHwYUgtkMHehvwyfDTC737UQSxT8Izvb8zgn61XsdT xrvrM91TyZxsW62kVJcgU8W2OJDmasn6S8N6EPpc= 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 v4 2/6] eal: add thread lifetime management Date: Mon, 27 Jun 2022 09:56:02 -0700 Message-Id: <1656348966-10194-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656348966-10194-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1656348966-10194-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 | 5 + lib/eal/windows/include/sched.h | 2 +- lib/eal/windows/rte_thread.c | 213 ++++++++++++++++++++++++++++++++-------- 5 files changed, 389 insertions(+), 41 deletions(-) diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 062308d..3c8ff50 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 *arg); + +/** * 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 6d8f89a..b404343 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -428,6 +428,11 @@ EXPERIMENTAL { rte_thread_self; rte_thread_set_affinity_by_id; rte_thread_set_priority; + + # added in 22.11 + rte_thread_create; + rte_thread_detach; + rte_thread_join; }; INTERNAL { 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 Mon Jun 27 16:56:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113476 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 C9EC5A054F; Mon, 27 Jun 2022 18:56:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD34A4282F; Mon, 27 Jun 2022 18:56:11 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DC7C340A7A for ; Mon, 27 Jun 2022 18:56:08 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 28BBA20CD16E; Mon, 27 Jun 2022 09:56:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 28BBA20CD16E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1656348968; bh=X2QPhIUcWWqZHaZR1Bo8X3tFpbBX/B7nnq1b4dwY2Xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OPNcb7BCQGmH4e5+IeG08orF0EOTvlfZf+jwa7PrU416wjkOykO+r7MgiTI9pg4/q oONLyvLRjWU+QzorFZSPf+3IuWbvTvsAJ6eOEtvsvHuMsf54llUNkYWIWzR31EP+Px Yas/gJ7oKNCbS96EIDNh5nNxNQg7zOos9vrV+9UA= 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 v4 3/6] eal: add basic rte thread ID equal API Date: Mon, 27 Jun 2022 09:56:03 -0700 Message-Id: <1656348966-10194-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656348966-10194-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1656348966-10194-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 --- 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 3c8ff50..8359c1c 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 b404343..b5dc7f1 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -432,6 +432,7 @@ EXPERIMENTAL { # added in 22.11 rte_thread_create; rte_thread_detach; + rte_thread_equal; 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 Mon Jun 27 16:56:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113475 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 00622A054F; Mon, 27 Jun 2022 18:56:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC98641148; Mon, 27 Jun 2022 18:56:10 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D804D40691 for ; Mon, 27 Jun 2022 18:56:08 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 34B6220CD16F; Mon, 27 Jun 2022 09:56:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 34B6220CD16F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1656348968; bh=PZpfXfqBrNpCcrV1uvUHJEFZcfcJRmUS3feN+g5euCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RL3AJxs48tNH4IE4pONbmQeDJKPhSGSDVhlCjiAOUvctP0AQkFuLPgBInd9MpRgqQ 2UPPJmwaqoxagudOL/mhY/e6w6cWpR+6BAq1t7XtA9GWQqvODpKXsnF6GARwqHS70e SnD2SAlTG0HpvBnziCoKekSeQT90nDXw+ENhLg00= 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 v4 4/6] test/threads: add tests for thread lifetime API Date: Mon, 27 Jun 2022 09:56:04 -0700 Message-Id: <1656348966-10194-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656348966-10194-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1656348966-10194-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 Mon Jun 27 16:56:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113480 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 8B143A054F; Mon, 27 Jun 2022 18:56:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5132542B81; Mon, 27 Jun 2022 18:56:17 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9702740685 for ; Mon, 27 Jun 2022 18:56:09 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4214E20CD170; Mon, 27 Jun 2022 09:56:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4214E20CD170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1656348968; bh=zeHqsHFqZMlHno0wQqyQ0Rw0Havhv99bdHBA8u0g8bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j7iVyZGukM5zVlj3rGygSE3ePBEP8R84vh9XWfqGF81FKVpwFQm7ku+mjOfi1BmmQ NLPjXb0q7fw90qlL5FkiwauUneCHR1W2+J22yzzIJAhajdHI8exbq0+rEjP6RQk6NU XJCT1D8ba8JTUo/+oV+AHmH+Md24g5l9T+wwuQiU= 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 v4 5/6] test/threads: add tests for thread attributes API Date: Mon, 27 Jun 2022 09:56:05 -0700 Message-Id: <1656348966-10194-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656348966-10194-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1656348966-10194-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 Mon Jun 27 16:56:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 113479 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 53BACA054F; Mon, 27 Jun 2022 18:56:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1541B42B7A; Mon, 27 Jun 2022 18:56:16 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9C95040691 for ; Mon, 27 Jun 2022 18:56:09 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4E20720CD171; Mon, 27 Jun 2022 09:56:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4E20720CD171 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1656348968; bh=UXwiV7Ewp9JLKV7Fz+03ft2Qs+ZUroNz6eWlfc/SY+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfMBH89j7Jrwpy2FSn/3yaOv+ztZb/RpHWwE0tNpuY1YIr28C4eE0OMAmwLIWa6zw IQ5Qt1GdNHgHWB4blF9UKpO7csP635L3SufAi9r3oaUqDuQ7Ljf/deSBCAsnds59iv uWUfS39YAlq1pv4cF/1FC0Temwv64wyc57N8Nw6M= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff Subject: [PATCH v4 6/6] test/threads: remove unit test use of pthread Date: Mon, 27 Jun 2022 09:56:06 -0700 Message-Id: <1656348966-10194-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656348966-10194-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1656348966-10194-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)