All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: dev@dpdk.org, anand.rawat@intel.com, stable@dpdk.org
Subject: Re: [PATCH] eal/windows: fix data race when creating threads
Date: Thu, 10 Mar 2022 19:19:32 +0300	[thread overview]
Message-ID: <20220310191932.17985164@sovereign> (raw)
In-Reply-To: <1646897708-3462-1-git-send-email-roretzla@linux.microsoft.com>

Hi Tyler,

2022-03-09 23:35 (UTC-0800), Tyler Retzlaff:
> 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>

Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

It takes some effort to correlate &lcore_config[i].thread_id
with the code in the patch and knowledge of CreateThread()
to understand the root cause.
I suggest prepending an explanation to your commit message:

	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.

> ---
>  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;
>  }
>  


  reply	other threads:[~2022-03-10 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10  7:35 [PATCH] eal/windows: fix data race when creating threads Tyler Retzlaff
2022-03-10 16:19 ` Dmitry Kozlyuk [this message]
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=20220310191932.17985164@sovereign \
    --to=dmitry.kozliuk@gmail.com \
    --cc=anand.rawat@intel.com \
    --cc=dev@dpdk.org \
    --cc=roretzla@linux.microsoft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.