patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: dmitry.kozliuk@gmail.com,
	Tyler Retzlaff <roretzla@linux.microsoft.com>,
	anand.rawat@intel.com, stable@dpdk.org
Subject: [PATCH] eal/windows: fix data race when creating threads
Date: Wed,  9 Mar 2022 23:35:08 -0800	[thread overview]
Message-ID: <1646897708-3462-1-git-send-email-roretzla@linux.microsoft.com> (raw)

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")
Cc: anand.rawat@intel.com
Cc: stable@dpdk.org

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/windows/eal_thread.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
index 54fa93f..ff84cb4 100644
--- a/lib/eal/windows/eal_thread.c
+++ b/lib/eal/windows/eal_thread.c
@@ -150,13 +150,18 @@
 
 	th = CreateThread(NULL, 0,
 		(LPTHREAD_START_ROUTINE)(ULONG_PTR)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;
 }
 
-- 
1.8.3.1


             reply	other threads:[~2022-03-10  7:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10  7:35 Tyler Retzlaff [this message]
2022-03-10 16:19 ` Dmitry Kozlyuk
2022-03-30 17:04   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1646897708-3462-1-git-send-email-roretzla@linux.microsoft.com \
    --to=roretzla@linux.microsoft.com \
    --cc=anand.rawat@intel.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).