[dpdk-stable] patch 'eal/windows: fix return codes of pthread shim layer' has been queued to stable release 20.11.2

Xueming Li xuemingl at nvidia.com
Mon May 10 18:01:53 CEST 2021


Hi,

FYI, your patch has been queued to stable release 20.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/ba0aecb72a6ec252c3a8bcfb4ad7187a6e9f4733

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From ba0aecb72a6ec252c3a8bcfb4ad7187a6e9f4733 Mon Sep 17 00:00:00 2001
From: Tal Shnaiderman <talshn at nvidia.com>
Date: Mon, 12 Apr 2021 13:37:44 +0300
Subject: [PATCH] eal/windows: fix return codes of pthread shim layer
Cc: Luca Boccassi <bluca at debian.org>

[ upstream commit 13e06abc9d316a9e8931de996c160c0359857415 ]

The macro definitions of the following pthread functions
return incorrect values from the inner function return code.

While pthread_barrier_init(), pthread_barrier_destroy() and
pthread_cancel() return 0 in a case of success and non-zero (errno) value
otherwise the shimming functions InitializeSynchronizationBarrier,
DeleteSynchronizationBarrier and TerminateThread return FALSE (0)
in a case of failure and TRUE(1) in a case of success.

This issue was undetected as none of the functions return codes were
checked until such check was added in
commit 34cc55cce6b1 ("eal: fix race in control thread creation")
exposing the issue by failing pthread_barrier_init()
and rte_eal_init() on Windows as a result.

The fix aligned the return value of the 3 function with the expected
pthread API return values.

Fixes: e8428a9d89f1 ("eal/windows: add some basic functions and macros")

Signed-off-by: Tal Shnaiderman <talshn at nvidia.com>
---
 lib/librte_eal/common/eal_common_thread.c | 4 ++--
 lib/librte_eal/windows/include/pthread.h  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c
index 03dbcd9e86..1a52f42a2b 100644
--- a/lib/librte_eal/common/eal_common_thread.c
+++ b/lib/librte_eal/common/eal_common_thread.c
@@ -176,7 +176,7 @@ struct rte_thread_ctrl_params {
 static void ctrl_params_free(struct rte_thread_ctrl_params *params)
 {
 	if (__atomic_sub_fetch(&params->refcnt, 1, __ATOMIC_ACQ_REL) == 0) {
-		pthread_barrier_destroy(&params->configured);
+		(void)pthread_barrier_destroy(&params->configured);
 		free(params);
 	}
 }
@@ -251,7 +251,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
 	return -ret;
 
 fail_with_barrier:
-	pthread_barrier_destroy(&params->configured);
+	(void)pthread_barrier_destroy(&params->configured);
 
 fail_no_barrier:
 	free(params);
diff --git a/lib/librte_eal/windows/include/pthread.h b/lib/librte_eal/windows/include/pthread.h
index 9aeab1fa70..1939b0121c 100644
--- a/lib/librte_eal/windows/include/pthread.h
+++ b/lib/librte_eal/windows/include/pthread.h
@@ -35,12 +35,12 @@ typedef CRITICAL_SECTION pthread_mutex_t;
 typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
 
 #define pthread_barrier_init(barrier, attr, count) \
-	InitializeSynchronizationBarrier(barrier, count, -1)
+	!InitializeSynchronizationBarrier(barrier, count, -1)
 #define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
 	SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
 #define pthread_barrier_destroy(barrier) \
-	DeleteSynchronizationBarrier(barrier)
-#define pthread_cancel(thread) TerminateThread((HANDLE) thread, 0)
+	!DeleteSynchronizationBarrier(barrier)
+#define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0)
 
 /* pthread function overrides */
 #define pthread_self() \
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-05-10 23:59:30.859166400 +0800
+++ 0165-eal-windows-fix-return-codes-of-pthread-shim-layer.patch	2021-05-10 23:59:26.610000000 +0800
@@ -1 +1 @@
-From 13e06abc9d316a9e8931de996c160c0359857415 Mon Sep 17 00:00:00 2001
+From ba0aecb72a6ec252c3a8bcfb4ad7187a6e9f4733 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Luca Boccassi <bluca at debian.org>
+
+[ upstream commit 13e06abc9d316a9e8931de996c160c0359857415 ]
@@ -25 +27,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list