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 C075C4607B; Tue, 14 Jan 2025 05:53:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48C6A4029F; Tue, 14 Jan 2025 05:53:54 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2062.outbound.protection.outlook.com [40.107.247.62]) by mails.dpdk.org (Postfix) with ESMTP id 4AF264025A for ; Tue, 14 Jan 2025 05:53:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fm5fwL9glNYhNagnGE3XajBsoF7RqEfmMUNGwoFvcP28wOvk7Da7uL+pR+H0VVHcUHBJ9DvY845gAkPKPI4o9FdSMnG1uQatm+FziD8Jew9D2tD1AB8bz0/9crIZSOOHHn0RE6UjcTJVQbGxBGapIaUNwv3swRr2dqyKiHcfen4TEPxwdTJ7Wj/ZKhqclYznCUKnq8TvRtG3x6ZXTpUcSuS4xcFVFCr+N8NkPAaXhSpZD1UFS+msbCjJ/Auj2RifY/SoTXybv3nt1BEQbykbVNa9JqgBRmLDIbphT6RIkqEbIUxSbxPsnQoiLUSMD86bQ+O4fWSNrh/LtDrGY9YAGw== 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=tMKNpJhl3VFaSLLrHcX+jkV2PgtQpYNh6IZhFszqlJc=; b=Gvfv2I+jc8JLm3Hn3sv5gxzR9OzG2yc15S3b7XXT+xg1XvL8dOUMGO01zG7zXOy7NDR2++gBwwROTn6xwcduqved/tD3OwziWdQ79EdqH/NPB+loYLjtr+G3nS/yHcwLL1di4WyLWZtzZiRqSK1Ok57p6ubH0BDPmAbCLUjg5fe8Ee8JHGa+bKIH9Za9LRyP4s21as7EUerNT0SbIbbiI0Ku2rGo8R+OQl/UHH1xORAoUhM2yClhGbTXvL0uVDml85brMMewKt3YYajn90sbQix2coiIVEYgymGxZxXhanmXAPNjdSy0O0VNu/QzdMtrukaLTXE3+IJ0UtNMLv+8DA== 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=tMKNpJhl3VFaSLLrHcX+jkV2PgtQpYNh6IZhFszqlJc=; b=XEHp5PzMPR7whNwDbLMm4a/dEDQwTnIYejufLnWKRtFSlVbYa9mGAfmmuh3rIIDhZdPMLEI1yWwNmUeKdQbndJnypgm7NOk3LT2P3vHLlybBKK8KBAAVadaK9W6L0JgDI1pxPUByAtWF2mDbngTL3LeF1wQlQNlHAjKxyJtNofcAnuNbe0mrkHzZD8Rp408PjKyIpLzNuLWYepUtqZyCw34RlGDILpuG71vwpfQWUCoss9Gg1L5Gf0mRy8fgO0va+iP4LokxOgg3KPGkAFc8c1WDKbCgk29P++IXxPfgZRq409lpG1uRtbV28a7yydeGOEpyrSJhZCUog8/FBpzIyA== Received: from AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) by AM7PR04MB6920.eurprd04.prod.outlook.com (2603:10a6:20b:101::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.18; Tue, 14 Jan 2025 04:53:51 +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.017; Tue, 14 Jan 2025 04:53:51 +0000 From: Gagandeep Singh To: Stephen Hemminger CC: "dev@dpdk.org" Subject: RE: [PATCH] eal: add worker threads cleanup in rte_eal_cleanup() Thread-Topic: [PATCH] eal: add worker threads cleanup in rte_eal_cleanup() Thread-Index: AQHbYyuGeo4NaUT+AUqv8ZZ7QOBMT7MQQSUAgAPk3lCAAMdNgIAAyNZA Date: Tue, 14 Jan 2025 04:53:51 +0000 Message-ID: References: <20250110064717.1372216-1-g.singh@nxp.com> <20250110091902.5139f8b2@hermes.local> <20250113084017.6fe7edc3@hermes.local> In-Reply-To: <20250113084017.6fe7edc3@hermes.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS8PR04MB8198:EE_|AM7PR04MB6920:EE_ x-ms-office365-filtering-correlation-id: eea0332f-bfc8-40c3-f834-08dd34577099 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?mk2U0oq256F88EDusFw/ifzlw4RQN6psl3g7ZZCWY+tntmp4Q7Sfi+sngNP2?= =?us-ascii?Q?2wcgejPo4yfQ7hj9LP7xijx0gH3Mhs+X0RATHECfnKS+Q4IIsZgJjNeBmhqN?= =?us-ascii?Q?LdvMahP5qjRXVkljI6Eo+WLRFE7qG6WXHTjS3JdiWLcMDSieIa+B3sQu+pTB?= =?us-ascii?Q?kXQq/kre7d4O6Yc+IdwnanLTcF4enyVeayXaSfLZY2yByIpaAmgYKRS388S6?= =?us-ascii?Q?ejwF3fEl6zHGoCx6VQaew62xGEpj7WnMo6ItVLEs0KPloJB+LARJYBzeroKi?= =?us-ascii?Q?YqfI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2onqb9IQLT2vxCzkNRXgw8FTPkrdPT?= =?us-ascii?Q?xDt1CmOQ8Q0Qg53rAnXLSnxxU+o8Y/JISTsOGBSRDdwOtcoWJzC3btYXb2Nw?= =?us-ascii?Q?Gif4nfqFQ1TpvPhXWkNEdc0FOJkS7H8XolBV0QOs3zIfBROvAoiYJqFg29RW?= =?us-ascii?Q?n1FYFwKsPzW4JjZ6pqkI7/+rifRKkWb6MWg9AZj27MFRrgBiIka+bP2puT/M?= =?us-ascii?Q?N7JFzC9ea986PMZyhNMXVFJ8X7w/oYTBoo+XvuMh/QQCEaXr+v1EKfQ5IYxM?= =?us-ascii?Q?pzIbhVCdU9OMOEv6uqqFOYx0O+SbOLIr?= 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)(366016)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Qa2sqKMdKNzy1YxdfwlQIO7iFAuAlyq/0h8ys19lriUJDXXihE00GHnWx9tR?= =?us-ascii?Q?uTuvGZVLm8/i7hCwit7CR7n2QBTfZJkmFRIOSHpYaHnrmQAXuSPd5FyXGO2G?= =?us-ascii?Q?oHPamInxj2Zm2+2CZ8pRCRWma84RUb+7nm5IiZqdIOt2JipCNcD075byyIwb?= =?us-ascii?Q?mytzabd1X0mqrboAikgDGFGQwRRThh6tYxPTq4izQ3F2v4+Ece7TTMi1B2Fv?= =?us-ascii?Q?zVsSS8epH88WtVJ4YJc5o4CnoTnPepLIe4ARPM5YJt046GMgso9SG2aWSa7u?= =?us-ascii?Q?oF3igaIPaGyR5KiXbqQOOv/71FvIjxPPWWg+CnIFHzSl73CHbJqhTYKUNqT8?= =?us-ascii?Q?VzW4nGlG2yAS2+Q5hd4tMBXpaUHotUWSX06618/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-ascii?Q?nuPorX8GdP2hw6AMTlo1/N7yevsKFyFPh6wAWK6aChY4D9cUJYg/9KxSjDTL?= =?us-ascii?Q?bWFsaeOoJcQIDq5Lrx/6IEcD+dYN/GZo1a535EF2PeM+XXOtvSOr2r+YoK2/?= =?us-ascii?Q?EqKdSa9ngvp4K3BsBPKVe2DXgh8ruc/r67k0GyaZBeoJYeZ+tdj0XiE4CleT?= =?us-ascii?Q?OYgoGBS8WuS/6cyRjNNGNzixA62Y8PpgX7AFgrpaDwvq6xZxNtrxZ+LN9S+L?= =?us-ascii?Q?Ss9viyy3VaVzd073AjhUTqqPx/aWqTWak8WnfxTEE6g73fuIV1H1+BvPwRz8?= =?us-ascii?Q?bY02PqmQJSYuxJ96bG8=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eea0332f-bfc8-40c3-f834-08dd34577099 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jan 2025 04:53:51.1935 (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: MYaTVkanwfgYYz1EGx7TQ1mU+Fa9F6QCYg4vH7ksI5H55l4Y+6IJumARbGDipCRW X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6920 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 Hi, > -----Original Message----- > From: Stephen Hemminger > Sent: Monday, January 13, 2025 10:10 PM > To: Gagandeep Singh > Cc: dev@dpdk.org > Subject: Re: [PATCH] eal: add worker threads cleanup in rte_eal_cleanup() >=20 > On Mon, 13 Jan 2025 05:13:01 +0000 > Gagandeep Singh wrote: >=20 > > Hi, > > > > > -----Original Message----- > > > From: Stephen Hemminger > > > Sent: Friday, January 10, 2025 10:49 PM > > > To: Gagandeep Singh > > > Cc: dev@dpdk.org > > > Subject: Re: [PATCH] eal: add worker threads cleanup in > > > rte_eal_cleanup() > > > > > > On Fri, 10 Jan 2025 12:17:17 +0530 > > > Gagandeep Singh wrote: > > > > > > > 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 > > > > --- > > > > > > What problem is this trying to solve? > > > > > > Canceling threads sends signals and can be problematic. > > > Many of the operations done in drivers are not signal safe. > > > > To ensure the proper cleanup of thread-specific resources, the DPAA dri= ver > initializes pthread-specific destructors using pthread_key_create(). Thes= e > destructors are executed only when a thread terminates or the key is dele= ted. > However, since threads are not terminated when the application is killed,= these > destructors are not executed, resulting in resource leaks. > > To address this issue, we propose adding thread termination code to > > rte_eal_cleanup() to ensure that threads are properly terminated, > > thereby triggering the execution of pthread-specific destructors > > > > Any alternate suggestion in case pthread_cancel is not a better > > solution? We can add pthread join timeout to avoid blocking on thread s= tuck or > May be any way to call pthread_exit? >=20 > The DPAA driver is the problem here. It should not be using pthread_key. > Other drivers don't do this. Other drivers do setup on probe and cleanup = on close. >=20 > An application doing a clean shutdown should do what existing testpmd, l3= fwd, do > - wait for worker threads to go idle > - stop all ports > - close all ports > - call eal cleanup >=20 > If DPAA driver needs pthread_key it should handling that in the close. > But it really should be using DPDK thread local storage for this. >=20 This is fine for graceful application termination, but what about non-grace= ful application termination? I have a DPAA bus cleanup patch ready, and will submit it soon, But we stil= l need destructor in case application exit without calling the rte_eal_cleanup(). I can see DPDK is giving an API rte_thread_key_create() which is defined on= ly in UNIX and windows. Why not for Linux? I know DPAA driver is using pthread_key which it should not use but instead= use rte_thread_key_create() provided by DPDK which we can replace. Having pthread destructor is still a valid case in my opinion.