From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 460CEA00BE for ; Thu, 10 Mar 2022 17:19:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3698841144; Thu, 10 Mar 2022 17:19:37 +0100 (CET) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mails.dpdk.org (Postfix) with ESMTP id C68774113E; Thu, 10 Mar 2022 17:19:34 +0100 (CET) Received: by mail-lf1-f46.google.com with SMTP id bu29so10424672lfb.0; Thu, 10 Mar 2022 08:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FIv7ELBuHFGDHd/kbrgB7HVmjQQSeQw2s7BwMdpyQVc=; b=fBunirtF6ZNQE5zaoENR15zEky/b/8oZ9uEiTqA3nLkqhG0xYNlNy+kHtvcwa8VLYI jfPg059VYr9ipKDl12j+DDB8bOU5V66wK6s5iW2LZyaI9uIRejqukZN+5zVCEzmF1fYQ j/8HhXH1F8Tc+CpEnap0UPbRH2l89r4p2KLI6X9CtJ7V2S763DQkh48K456+J5xfWAHg JC/JhQDx499gs5dEtUMK/0iXwslMSlamLewUmHp0fmana8z1UGrnvkd2Y3+3Zy8QJS73 f0egMp4O23AdhVlRcNX7jv5CVPoRHPeaxTYH2AHi4kH0aj1utvj3JX9Yt0uPp8iFXvVf Wvvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FIv7ELBuHFGDHd/kbrgB7HVmjQQSeQw2s7BwMdpyQVc=; b=Yh3eZIxzvBbNlf59U0uC12+wq4IoFG+oVoI4ncmYnmCUuR6DnOTRmQZB/xtV4fGLx2 4+IAOyDv9b8fxqlz50F2cYyxgg51VRwYaHk8qbKFfF+/5oqdrgZiR78rpPN3p0uSNPY5 l4Hjam9pgTNBLWgLpoZZRyW72xpzWnWUuq0y4M3nqkIxYC9SiBx7leRiYiyjO3ti+U99 Bqd7hguHhrDvsex3osl2568CduNNEn8dDFZKghHBN/jOT5dqdmH6FDRWX3UP77hfKzvW mfSwVb8hhT21/VeQN1cDBriXUa1E+2M1RZiE+fKkfuBbT29Got8Ik8TUyyRVfvxWV54c WVMA== X-Gm-Message-State: AOAM533tRPW+iK6/4abNfFvQgBoiS42f8pG0+HC8zl9Henoda5CZOrVN UqDLPQEuI8bEGxEgfVWAVrM= X-Google-Smtp-Source: ABdhPJyHNrFgFfZg2CARekGETrf6zq7GpG40Ib7gL0ZjS89jWWJGp1Q4ZxoqG2ut+vB34tapzRi0Fg== X-Received: by 2002:a19:d619:0:b0:43a:1224:bf8c with SMTP id n25-20020a19d619000000b0043a1224bf8cmr3454468lfg.276.1646929174121; Thu, 10 Mar 2022 08:19:34 -0800 (PST) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id m25-20020a195219000000b0044846bbda49sm1046692lfb.121.2022.03.10.08.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 08:19:33 -0800 (PST) Date: Thu, 10 Mar 2022 19:19:32 +0300 From: Dmitry Kozlyuk To: Tyler Retzlaff Cc: dev@dpdk.org, anand.rawat@intel.com, stable@dpdk.org Subject: Re: [PATCH] eal/windows: fix data race when creating threads Message-ID: <20220310191932.17985164@sovereign> In-Reply-To: <1646897708-3462-1-git-send-email-roretzla@linux.microsoft.com> References: <1646897708-3462-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 Acked-by: Dmitry Kozlyuk 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; > } >