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 00FEF46035; Fri, 10 Jan 2025 07:47:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C79D841148; Fri, 10 Jan 2025 07:47:36 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2044.outbound.protection.outlook.com [40.107.22.44]) by mails.dpdk.org (Postfix) with ESMTP id A2B2540648 for ; Fri, 10 Jan 2025 07:47:34 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oJz4O48s2bB7nbGYD6QUxMpzdKMs2zQgJyB/8EivY0mWSeAdW9tqurRZWmOOyqsEP5KShK9CcE+oMGBA8Ijwf0+7QJndlC6rv9e5SLOXw2nucsRvfK2259poHXbM+30FGbgcTf1/+ZsxVrl4D83j2tWXD/EDBNVk/qdDgnkTgVqn8hcWIcopUh047ehn/0rp2LTkLgyq6J5yXNLCWD244Jy8PeIBEm5GpOlQv+eUD497hWdli1vg5+9XwkxZst+Z/M9JXRZWNASye+FT6hkB60kLj8U8YBKW4P+Ggii1enhhcchDiyhFGPFkdgY8wfMkGN1Gdr8VV8SzSdFz/K4KUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=4p9+LCRAIZqLkzdQUO27VikQANTUDsMIcpUS/YMlKmI=; b=ZMqYrsHZIjMcOvvHdMddGqKDQOqMqy3kfW/uC3iYGkTNb8O2KxB2G1q8kDqd6qJGcBBjfvAoRyMae/L6D7uD9j5HJXDjYkmylJaANITxIrSug/c4e31SCiElTMbrujWvBcEkBcoC0bE4htANSFcAQhgk7bJwIHXNxfI+NV0yKnDAL8Ve2RlMeRP47FVwNqdtel/3uNCDzV8El+813lidHMT4lzFOiFqWaYTs+VnFCQXHx0JDW17Ddlyzz5gAF+KJgVCNFtoYGPaCrEiJW+LVEYR7HOTuxURLgVW66z5powvB6NNcr93DMjupaPhKXBbTq5idrDPFchBm50CkKnL0Ew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4p9+LCRAIZqLkzdQUO27VikQANTUDsMIcpUS/YMlKmI=; b=N1uFk/0t/e9Ft901WrF8h6gi3oYIRjCGtFpLTSk7E8D6YrP9Y9nxHDhPjoG39ZJB5pPq/HkHgRKHZ1fy0Qj1LFNIUNPTHlyVsfqBADc8YvC9YrbBFbvQXFY+Aj4cIwgzOik16TvMF8CB7POG9LHnaol4EsnZ6jXQ4mtsfCSzFwaRUG+v9Q8t1AN5EgdN0uR/S154gTC5kUlGS9/b9Xx2EcPVQ4xpUu8YZe+FmE/3GwDrmKKAnUBMDJ2sRn1r6XKnk2cW1h/+EXPfLhHBqziyV8VlF0rUI5pQYAbWHh6cS+regKuvrNjrLBjK2h+oejV2/0lGc4PdXZwdlWwaitzVDA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) by DB9PR04MB8106.eurprd04.prod.outlook.com (2603:10a6:10:24b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.11; Fri, 10 Jan 2025 06:47:33 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::2e32:1a4a:7d29:195]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::2e32:1a4a:7d29:195%4]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 06:47:33 +0000 From: Gagandeep Singh To: dev@dpdk.org Subject: [PATCH] eal: add worker threads cleanup in rte_eal_cleanup() Date: Fri, 10 Jan 2025 12:17:17 +0530 Message-Id: <20250110064717.1372216-1-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2P153CA0031.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::18) To AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8198:EE_|DB9PR04MB8106:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ecccdfc-e178-411d-057d-08dd3142a91b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ZdFTnPyDxFMgumSI5wvDtJ1F0M25vZpFDZy4e4puZkPhCzAPvcf2880UoSYM?= =?us-ascii?Q?QsViLBoPC9EJBs63XZ2Smj9VojMpZz36yU48RHwoie2VvkTk1aaw2rec2gu7?= =?us-ascii?Q?hAaIOoasX8x+Xwi/8MDM4q6+UBWtzi+EcX3jUJRZG8+VrAXsrDreFguzCtNJ?= =?us-ascii?Q?+tgck/Ac4NrBhKhUQZlaeYYpJ+FU8Z9nkcE+qXjLf0bImoyvczE9VtvjB7Y5?= =?us-ascii?Q?r5GA0AQFgSuu5q5hPuKmT3dH9eMfkYXyG3mhiwDOhxOQ5SZK+vZllr67by0q?= =?us-ascii?Q?OxxevJM0kvEspLaTRGo+c32eIYiuMX0cmbfOW4ZBKMGpnaB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gb/pspFSXxV+3pzq67hL7fSl7UqrbuEh/1z?= =?us-ascii?Q?pb+ZATmcwT2nOJ4EzRClgZbKm4TTvz1PgC5zhijj/NIUGHmw3X+ognwtTxZ9?= =?us-ascii?Q?PzS2PnxWLUOR3sTKaXFI5I7reXJc9Cv8ysJ3mgFsZ22OMKI68nxuS27QGCBh?= =?us-ascii?Q?NggEnTPOt2gFzYJZUeLNjW+zdyIba5H8spWdbBAcKTbOwgPCPLoM6byZn5cX?= =?us-ascii?Q?Yi12X+la0Hg=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8198.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?k5wfiAKrzOUJM495Q2BSzViB0TVwduE94/KSUTGA/etxZzKu8xD2vFqNJyJr?= =?us-ascii?Q?16z3vPIHJhkPCbgTOelHFM9/XValhXBP+rNJzEi9mHNf04A6ka9TMtazhy+O?= =?us-ascii?Q?IoHSUQINRK8NgIuS57kQSni4B0HwnJu31x5R8kwrJCUz6ZRen73hBavhPjlw?= =?us-ascii?Q?7glE3y8XvPTvFPGWMHE0QJM3D7fy6p8l/IkYLP4ANdVnPcXZn14/IqcmLrd4?= =?us-ascii?Q?bGPU+Sw0cS9HLzcsG8bcxegMIk0xwJ/XOOxluXYcodd8rVay9oNcSJw5xPPR?= =?us-ascii?Q?wQyQ2LNq6CmKDwMh9XzUA5EvKSCVioLSBA/uSt4PAoWgeEvYfFvRGUEPLbGW?= =?us-ascii?Q?OHZFJU/u1XYdBD4JCJPJ8tbFeK8SAg/bW8QfpAzhYw5af98rXOmrWWoFZX4h?= =?us-ascii?Q?9fXHWdq7OEPFQbqJkrmV4ph2EqpcIIDkp8Yk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ascii?Q?U/fSLqkat/1ugfxw2O8brjILtfbnYkHHporD0I7ljMZdbmIDKlfEIAIYgpzF?= =?us-ascii?Q?qdM1ycwq55aWtYz9ytZcAqUIH/j0MBfE9SLuV5FpM4trncEsWo75swFQMr6c?= =?us-ascii?Q?R/GC5/kDgjJeH5RY8iJBu7/pc1rykaaHMyI7nJX2UvMu7pbkTGKJLtfDiRif?= =?us-ascii?Q?w2K63LVKtYglY52vSczhI5GSCk6WKvUd9Mt3flacWWPjSBaUaZJ7aCd+HcRN?= =?us-ascii?Q?xXZku2QTKZDndIbl2gU=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ecccdfc-e178-411d-057d-08dd3142a91b X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 06:47:33.3033 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CXiiKo/LZbY8Q1G4mQeLNnHakMcyfyNBiEFxRpE/ZbYKwrIYkQFdE/HEY8ogFrgS X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8106 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch introduces a worker thread cleanup function in the EAL library, ensuring proper termination of created pthreads and invocation of registered pthread destructors. This guarantees the correct cleanup of thread-specific resources, used by drivers or applications. Signed-off-by: Gagandeep Singh --- lib/eal/linux/eal.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index a6220524a4..a828905783 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -913,6 +913,32 @@ eal_worker_thread_create(unsigned int lcore_id) return ret; } +static void +eal_worker_thread_cleanup(void) +{ + unsigned int lcore_id; + int ret = 0; + + /* Cancel all the worker pthreads */ + RTE_LCORE_FOREACH_WORKER(lcore_id) { + /* Check for non zero id */ + if (!lcore_config[lcore_id].thread_id.opaque_id) + continue; + + ret = pthread_cancel((pthread_t)lcore_config[lcore_id].thread_id.opaque_id); + if (ret != 0) { + EAL_LOG(WARNING, "Pthread cancel fails for lcore %d", + lcore_id); + } + ret = pthread_join((pthread_t)lcore_config[lcore_id].thread_id.opaque_id, NULL); + if (ret != 0) { + EAL_LOG(WARNING, "Pthread join fails for lcore %d", + lcore_id); + } + } + EAL_LOG(DEBUG, "Worker thread clean up done"); +} + /* Launch threads, called at application init(). */ int rte_eal_init(int argc, char **argv) @@ -1321,6 +1347,7 @@ rte_eal_cleanup(void) #endif rte_mp_channel_cleanup(); eal_bus_cleanup(); + eal_worker_thread_cleanup(); rte_trace_save(); eal_trace_fini(); eal_mp_dev_hotplug_cleanup(); -- 2.25.1