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 CC27E428F8 for ; Sun, 9 Apr 2023 17:30:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C624A42B8E; Sun, 9 Apr 2023 17:30:19 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2075.outbound.protection.outlook.com [40.107.93.75]) by mails.dpdk.org (Postfix) with ESMTP id B34D7406B8 for ; Sun, 9 Apr 2023 17:30:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i1dLE1tGYQFp8p9ebQssKWad0BPy3rGtMZ9T6iFipVlGOs20IyqzbK4aesiyR51J4MYeTeICU5kHp30xVnWbKmy5tVoyPGRC1zYJ0QBcNRGG7imMSKtSGstQi3OlFpmV4zjEM9JAgi+COmpi3RPgkWh65MH4S3fk3X65srDlma+ci+XP83RdfCsEDIvww23cYD27fgGZzLLXE378JPjbu0oHA+GhhhBiR7+3uqvg+YiOVVwCzspzfa1IBLybobA/w0eeBltJX43+RyqDZqDs1TzbUFA7uqttXETdxHfUBz4tkGeVcjtXAxJZo0GL1NWi1hfyWh275dGtvG+B/uLSTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S3cmMWYlXWi88hYrGzGifDxihql4TYEC+RC2VgCRWco=; b=KEHmDgxWFIIttAdoboASnrz/MG42LRQa00GrPyvpHHSbPEg7I4DzXqaWqc+De0sKtj4f7pTekwSYRdeNtmYVVy5y4SkMeF6amfxxg9RhREZJVlGtXcgJgdD1xJ9cQZt5ol2LVcgUSP+qcgS/cbZ+wedzGfkU98ymUV/2UzX4hElF0rNw1e+LWkJV8RdfyOSAtPks60LqJitXb27DnDsBhuxdDRygGleYqtOvNDTqSGfnoQhbYjc4AQpB6AlykwicviQZs6XlZrAP4OAZGzNjoToi79/T+cmld4nB/lz8xSc/OZOaFv7D9lFvD2w0h+tkEPY7W9Hqy7POrS8/YDjfqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux.microsoft.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S3cmMWYlXWi88hYrGzGifDxihql4TYEC+RC2VgCRWco=; b=HWunwurWIfPne3IiPAQ+y/LZMOjvOgWN3/SSwS82HfxuBwCRr7F9TcfxCQmI7Y4qEzcD2eXFqjUFLDVfK/mhZvTbFug2lhNEEiW6LtgcMKfW/k5jXJL/ymLYBi03yK+R5wk30565JheNny/ghhjE81leRP4u/4IggT3b0a9B4cMjQ9h1QJElbnisEFHmLI1dk0Oi+LNyCpdMLb4FlQwxg0ZgV36nbp3yEDsktp2QMfRTA2Oo391l/lNJBp4NPvttYV/C4UZN86vnn9QmqLMhNySuQeAPBQCfpniHzfvjlH0oKZytXJiTNdlO3xgf6My6ZO8ZEcnOnFMFXzHqhpoUJQ== Received: from DM6PR08CA0017.namprd08.prod.outlook.com (2603:10b6:5:80::30) by DS0PR12MB7632.namprd12.prod.outlook.com (2603:10b6:8:11f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.34; Sun, 9 Apr 2023 15:30:16 +0000 Received: from DM6NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:5:80:cafe::c0) by DM6PR08CA0017.outlook.office365.com (2603:10b6:5:80::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Sun, 9 Apr 2023 15:30:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT088.mail.protection.outlook.com (10.13.172.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.25 via Frontend Transport; Sun, 9 Apr 2023 15:30:15 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 9 Apr 2023 08:30:05 -0700 Received: from nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 9 Apr 2023 08:30:04 -0700 From: Xueming Li To: Tyler Retzlaff CC: David Marchand , dpdk stable Subject: patch 'eal/windows: fix thread creation' has been queued to stable release 22.11.2 Date: Sun, 9 Apr 2023 23:24:01 +0800 Message-ID: <20230409152529.5308-54-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230409152529.5308-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230409152529.5308-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT088:EE_|DS0PR12MB7632:EE_ X-MS-Office365-Filtering-Correlation-Id: b0b23201-4b48-40bb-9f96-08db390f5195 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xm5qObe2D3SIVg2n1FiO66U67FQI6qrTm3pnbUseBxhyw7bvqp4rid0LIt2kqeo8NPPqfLkVx9v+afo6ZoNUbdCGcYpIH26tYvaNBBYZA/L4ocToHq41vhnDwRlZZ34hSraalWT+XdOhoRod7X6Vr3VgPG/LMi0IDX//o0TcW7hK0N0d/BFz701Um/b2Stt9OH/YdNomIpt8NxqwLfSJbflXwjqMIiQOnW3IeAke/JIlcEYvefKlznrTlUmlkKdZQm2LPRBwZ95/nabRD6WowynOXagzNlcpsNiB9PUlQSU0aga3QZaLIw/T8TwKEtfDYSTCz+rGXG0F6pjve20OqS9pf9CGV2Iju1zuIAhc2xhQtInqUVdbL3CqkzhRMNYMeXExpr4LZu/eIFxh9BwA9w3/PP8wjcSwlk4KmuUx06b38V90Dj7yMDU68lGNHELdczuajsymoAr4p2RQUD6alg89Gfr4vWAZDcdlZNI0YDPdJFAtgjYX1nstLXLkrg7x1RFC+0wRWYyc+p1nVsThxqId6MgzUP7TZqvuJNoh27ybAa05HQgYTbkL2pcWhzXc6oo+JjqG33HR+6aGcBZS0pnrds+Ez1zxCFCh8/SS+khie1DManK9hv4mtrMhsmCxlRYAwDD6G1AqwAGvuKMteogf7elLXBvR0j6C0XolCOSK79a1Qb9n+q7ge6NThSGnXzPJcwW8awAyxbXGJgjpmBjr3RW0ZkzCfBOOxTcJm89EeM6LU5a5WLLt7b35fZklLPhtsVqw6+ASTXsiTSKwL/V9tMLWjaHR3Cgf9UVFB2Lb+q+NCiAX+MDumrPH8eOZ9NE9AUWtoc67uz97LeQ6vg== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199021)(40470700004)(46966006)(36840700001)(54906003)(316002)(478600001)(83380400001)(2616005)(336012)(26005)(1076003)(47076005)(55016003)(186003)(6666004)(53546011)(36756003)(40480700001)(426003)(356005)(16526019)(86362001)(36860700001)(6286002)(82740400003)(82310400005)(7636003)(40460700003)(7696005)(966005)(8936002)(70206006)(70586007)(41300700001)(6916009)(4326008)(8676002)(2906002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2023 15:30:15.7547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0b23201-4b48-40bb-9f96-08db390f5195 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7632 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, FYI, your patch has been queued to stable release 22.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 04/11/23. 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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging/commit/bf878ca704dedd6242d194522065dd97a9da5140 Thanks. Xueming Li --- >From bf878ca704dedd6242d194522065dd97a9da5140 Mon Sep 17 00:00:00 2001 From: Tyler Retzlaff Date: Thu, 2 Mar 2023 10:44:42 -0800 Subject: [PATCH] eal/windows: fix thread creation Cc: Xueming Li [ upstream commit 4ca43a8898181e52ea5789ea36d8681dc05931d5 ] In rte_thread_create setting affinity after CreateThread may fail. Such a failure is reported but strands the newly created thread in a suspended state. Resolve the above issue by notifying the newly created thread that it should terminate as soon as it is resumed, while still continuing to free the ctx. Fixes: ce6e911d20f6 ("eal: add thread lifetime API") Signed-off-by: Tyler Retzlaff Reviewed-by: David Marchand --- lib/eal/windows/rte_thread.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c index 1c1e9d01e3..3538633816 100644 --- a/lib/eal/windows/rte_thread.c +++ b/lib/eal/windows/rte_thread.c @@ -17,6 +17,7 @@ struct eal_tls_key { struct thread_routine_ctx { rte_thread_func thread_func; + bool thread_init_failed; void *routine_args; }; @@ -165,9 +166,13 @@ static DWORD thread_func_wrapper(void *arg) { struct thread_routine_ctx ctx = *(struct thread_routine_ctx *)arg; + const bool thread_exit = __atomic_load_n(&ctx.thread_init_failed, __ATOMIC_ACQUIRE); free(arg); + if (thread_exit) + return 0; + return (DWORD)ctx.thread_func(ctx.routine_args); } @@ -181,6 +186,7 @@ rte_thread_create(rte_thread_t *thread_id, HANDLE thread_handle = NULL; GROUP_AFFINITY thread_affinity; struct thread_routine_ctx *ctx; + bool thread_exit = false; ctx = calloc(1, sizeof(*ctx)); if (ctx == NULL) { @@ -190,6 +196,7 @@ rte_thread_create(rte_thread_t *thread_id, } ctx->routine_args = args; ctx->thread_func = thread_func; + ctx->thread_init_failed = false; thread_handle = CreateThread(NULL, 0, thread_func_wrapper, ctx, CREATE_SUSPENDED, &tid); @@ -207,23 +214,29 @@ rte_thread_create(rte_thread_t *thread_id, ); if (ret != 0) { RTE_LOG(DEBUG, EAL, "Unable to convert cpuset to thread affinity\n"); - goto cleanup; + thread_exit = true; + goto resume_thread; } if (!SetThreadGroupAffinity(thread_handle, &thread_affinity, NULL)) { ret = thread_log_last_error("SetThreadGroupAffinity()"); - goto cleanup; + thread_exit = true; + goto resume_thread; } } ret = rte_thread_set_priority(*thread_id, thread_attr->priority); if (ret != 0) { RTE_LOG(DEBUG, EAL, "Unable to set thread priority\n"); - goto cleanup; + thread_exit = true; + goto resume_thread; } } +resume_thread: + __atomic_store_n(&ctx->thread_init_failed, thread_exit, __ATOMIC_RELEASE); + if (ResumeThread(thread_handle) == (DWORD)-1) { ret = thread_log_last_error("ResumeThread()"); goto cleanup; -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-04-09 21:45:40.153091800 +0800 +++ 0053-eal-windows-fix-thread-creation.patch 2023-04-09 21:45:38.659042200 +0800 @@ -1 +1 @@ -From 4ca43a8898181e52ea5789ea36d8681dc05931d5 Mon Sep 17 00:00:00 2001 +From bf878ca704dedd6242d194522065dd97a9da5140 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 4ca43a8898181e52ea5789ea36d8681dc05931d5 ] @@ -15 +17,0 @@ -Cc: stable@dpdk.org @@ -24 +26 @@ -index 8556a84f13..e528ac9991 100644 +index 1c1e9d01e3..3538633816 100644 @@ -27 +29 @@ -@@ -19,6 +19,7 @@ struct eal_tls_key { +@@ -17,6 +17,7 @@ struct eal_tls_key { @@ -35 +37 @@ -@@ -167,9 +168,13 @@ static DWORD +@@ -165,9 +166,13 @@ static DWORD @@ -49 +51 @@ -@@ -183,6 +188,7 @@ rte_thread_create(rte_thread_t *thread_id, +@@ -181,6 +186,7 @@ rte_thread_create(rte_thread_t *thread_id, @@ -57 +59 @@ -@@ -192,6 +198,7 @@ rte_thread_create(rte_thread_t *thread_id, +@@ -190,6 +196,7 @@ rte_thread_create(rte_thread_t *thread_id, @@ -65 +67 @@ -@@ -209,23 +216,29 @@ rte_thread_create(rte_thread_t *thread_id, +@@ -207,23 +214,29 @@ rte_thread_create(rte_thread_t *thread_id,