patch 'eal/windows: fix data race when creating threads' has been queued to stable release 19.11.13

christian.ehrhardt at canonical.com christian.ehrhardt at canonical.com
Thu Jul 7 09:53:56 CEST 2022


Hi,

FYI, your patch has been queued to stable release 19.11.13

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/09/22. 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/cpaelzer/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/cpaelzer/dpdk-stable-queue/commit/2a645b955cb1f0bac0d61e1755a24bb78e78737f

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From 2a645b955cb1f0bac0d61e1755a24bb78e78737f Mon Sep 17 00:00:00 2001
From: Tyler Retzlaff <roretzla at linux.microsoft.com>
Date: Wed, 9 Mar 2022 23:35:08 -0800
Subject: [PATCH] eal/windows: fix data race when creating threads

[ upstream commit e4e983b975df700474309605b6adb5f2c6d83e2f ]

eal_thread_loop() uses lcore_config[i].thread_id,
which is stored upon the return from CreateThread().
Per documentation, eal_thread_loop() can start
before CreateThread() returns and the ID is stored.

Create lcore worker threads suspended and then subsequently resume to
allow &lcore_config[i].thread_id be stored before eal_thread_loop
execution.

Fixes: 53ffd9f080fc ("eal/windows: add minimum viable code")

Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
---
 lib/librte_eal/windows/eal/eal_thread.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/windows/eal/eal_thread.c b/lib/librte_eal/windows/eal/eal_thread.c
index 90797edb6d..563988fe40 100644
--- a/lib/librte_eal/windows/eal/eal_thread.c
+++ b/lib/librte_eal/windows/eal/eal_thread.c
@@ -145,12 +145,17 @@ eal_thread_create(pthread_t *thread)
 	HANDLE th;
 
 	th = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)eal_thread_loop,
-						NULL, 0, (LPDWORD)thread);
+						NULL, CREATE_SUSPENDED, (LPDWORD)thread);
 	if (!th)
 		return -1;
 
 	SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
 	SetThreadPriority(th, THREAD_PRIORITY_NORMAL);
 
+	if (ResumeThread(th) == (DWORD)-1) {
+		(void)CloseHandle(th);
+		return -1;
+	}
+
 	return 0;
 }
-- 
2.37.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-07-07 09:54:11.112776857 +0200
+++ 0001-eal-windows-fix-data-race-when-creating-threads.patch	2022-07-07 09:54:10.765823382 +0200
@@ -1 +1 @@
-From e4e983b975df700474309605b6adb5f2c6d83e2f Mon Sep 17 00:00:00 2001
+From 2a645b955cb1f0bac0d61e1755a24bb78e78737f Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit e4e983b975df700474309605b6adb5f2c6d83e2f ]
+
@@ -16 +17,0 @@
-Cc: stable at dpdk.org
@@ -21 +22 @@
- lib/eal/windows/eal_thread.c | 7 ++++++-
+ lib/librte_eal/windows/eal/eal_thread.c | 7 ++++++-
@@ -24,5 +25,6 @@
-diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
-index 54fa93fa62..ff84cb42af 100644
---- a/lib/eal/windows/eal_thread.c
-+++ b/lib/eal/windows/eal_thread.c
-@@ -150,13 +150,18 @@ eal_thread_create(pthread_t *thread)
+diff --git a/lib/librte_eal/windows/eal/eal_thread.c b/lib/librte_eal/windows/eal/eal_thread.c
+index 90797edb6d..563988fe40 100644
+--- a/lib/librte_eal/windows/eal/eal_thread.c
++++ b/lib/librte_eal/windows/eal/eal_thread.c
+@@ -145,12 +145,17 @@ eal_thread_create(pthread_t *thread)
+ 	HANDLE th;
@@ -30,2 +32 @@
- 	th = CreateThread(NULL, 0,
- 		(LPTHREAD_START_ROUTINE)(ULONG_PTR)eal_thread_loop,
+ 	th = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)eal_thread_loop,
@@ -47 +47,0 @@
- 


More information about the stable mailing list