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 36F1F43B6C; Thu, 7 Mar 2024 08:02:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71B9E42E9F; Thu, 7 Mar 2024 08:01:55 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2076.outbound.protection.outlook.com [40.107.237.76]) by mails.dpdk.org (Postfix) with ESMTP id B341B42E39; Thu, 7 Mar 2024 08:01:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GUmjGm8syZHkGb+x8dCkPwcUErOuq1VNtGa0QQN3t7KTitW6D6Uqu8M2qJ8ZF+M7qOpVkDSzm3hXoRIVMnppQU8oEwecpyn67PXBzlvGudW99Rl8zvLj3N+TNZuoMLAllwCAUusbg5L55TDUE2rtybx6oqql2Fu5awMzjqDth/AXBptIiVvpczR1iA3I7v+2lYN+A/UcCcQnrydT30/G5axrHs4Npo4HQExbrf8/AeOI1vTMp5Cjv0A0aGhbi95K6bPnjD6HMBEwTuQ56BVzWaUyE8oZ7ynSW9mrgbToSjg+fbuDoQ031fgZl5m6hHOX9CusOiYQU2kOcCC26NOXDg== 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=hPncIhh389T5CImwB8mRjza68jNeLrk+md45s5u3sL8=; b=a1FZBTfASiLOCG0QbAmjLgT14CmDaPr/FgLFM8IygDyYBWGbD7MLU1Z/Y1v87GbMloiRBySDxMmkXhs591FTsCt8mnbFnBFbv1SpD5QjQvzxq9dM2+QJ9NvWjsa24N/t8C1MNGAOru2k9GSi5ZZEs4ehAZtbCrJW4PWv6UAWeNt2y/4sl0vQTI3pW06dJUxcbndgCGVXVMa4EkS3/SbsT4Oz+vNOB95Mkyze461oDvmH0Tszt7T6pvQSQgwjpqOO9ah3tkYX6ectoI7wanu5tr6abcq1yqvDaPl3xRNhGMgyb+E6garIlZdcfXDUEHYrwy8MaCUBwWOXab/8VCwNug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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 (0) 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=hPncIhh389T5CImwB8mRjza68jNeLrk+md45s5u3sL8=; b=eX/coM1di9GdUps0bCZahYxlGBWtQ1nXt6TJjYPM67/X9WAFwFrE3hbIR/SfXbZ2DjztQUb+NLpbTbfEhUEAeowjFUY14UNTWDJ0/b8ed8YxvII+VlJ65Au++jvdRmlsNxH0qVhT8XRqm8xkjQhI/qXxLT9ZTW6Xbv6sOTYGU6RW3GqWpKSu4/vc4TIdojCAEVJf5b7wUtJvNhTxnjtXd++javoONlvNgD5HnGOQYmJ8xITVv+onPn3DUGQyph0PJ1/4oz3CDrVhd7SGc5UgpsJh1eSWsGO8WbViUhayMLp0nmqPSlFOoyKCA/eJQs2KlS+nNeemYBscf5ZhkqgwZA== Received: from MW4PR04CA0191.namprd04.prod.outlook.com (2603:10b6:303:86::16) by BY5PR12MB4067.namprd12.prod.outlook.com (2603:10b6:a03:212::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27; Thu, 7 Mar 2024 07:01:50 +0000 Received: from CO1PEPF000044FC.namprd21.prod.outlook.com (2603:10b6:303:86:cafe::d3) by MW4PR04CA0191.outlook.office365.com (2603:10b6:303:86::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26 via Frontend Transport; Thu, 7 Mar 2024 07:01:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1PEPF000044FC.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.0 via Frontend Transport; Thu, 7 Mar 2024 07:01:49 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 6 Mar 2024 23:01:34 -0800 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.1258.12; Wed, 6 Mar 2024 23:01:33 -0800 Received: from nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12 via Frontend Transport; Wed, 6 Mar 2024 23:01:32 -0800 From: Artemy Kovalyov To: CC: Thomas Monjalon , , Anatoly Burakov Subject: [PATCH v2 5/5] eal: fix memzone fbarray cleanup Date: Thu, 7 Mar 2024 07:01:13 +0000 Message-ID: <20240307070113.29580-6-artemyko@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307070113.29580-1-artemyko@nvidia.com> References: <20231212042517.164353-2-artemyko@nvidia.com> <20240307070113.29580-1-artemyko@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FC:EE_|BY5PR12MB4067:EE_ X-MS-Office365-Filtering-Correlation-Id: 375094a6-b0ec-4ea1-6386-08dc3e747630 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QC5zE8ht/IJGef7me8DFwDsVrp8JhZSW3ShMyCM6GuAGGLhbwLeUxiZgCcw6GdXai/JHICafF3mp10R01LM7TTWc2zXbTOtWPZltq/t2jm5v1tCb6mkMSQLP5TICUFd6vZvYzItcUT+294/YQhakYMLebkizlM7xC/TJwTLviO+BM0xxP8BChOCEFTCSNZ/gkagDMiJvVbd/PhsBFMscUhn0Kmt3oG+m6oDFquI4yli2aUGziFuCbOW3VrBNUOAF9Y+WEangc4bAUccOLxtXtk8EuGnqHC3miKtm+jaQO0kSL/Sa8eIU/U/uvYu/DbTnea6ByftNQn2Nm0imphJ+g+Ilos6TGRCwLHl8TD4qBzSC4Mk2mjgRTpbKbDx+l7R1bPO42tSPCcqzXa5PbdgAGub9KQ6kTxwR/L4K/dlYISNvN8RkcvGkCwrK/2qPqRSGzskdc8CKImxW5l1W5o5KpIu+3lrDXdkth1rIogRCIeIc38Fan4abbGi0gKnAdDZLoufPsiPdZuFdt46Vil+8TxWdOWa46oywpWX50t/zpsBisfnLoKbnx+fxKL708ySijxFRS4L5wH0S8dScSLXKtk9l1+TFV5clMZ5SQQRoNQheBnnTWY/AvWnxHoLrKA/w3hF8UuuwUBtGx69B34RtdCVZTN5UksFilac0Pr0Gee+YUxumm1+rwMN32PeDdfutn+lJAKpyIIivD2VIZDH2zGoUGD71W/bNHc8cP8XIrmv6myL9BbRCcLYgDfxnKRj+ X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(376005)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 07:01:49.8372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 375094a6-b0ec-4ea1-6386-08dc3e747630 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FC.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4067 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 The initialization of the Memzone file-backed array ensures its uniqueness by employing an exclusive lock. This is crucial because only one primary process can exist per specific shm_id, which is further protected by the exclusive EAL runtime configuration lock. However, during the process closure, the exclusive lock on both the fbarray and the configuration is not explicitly released. The responsibility of releasing these locks is left to the generic quit procedure. This can lead to a potential race condition when the configuration is released before the fbarray. To address this, we propose explicitly closing the memzone fbarray. This ensures proper order of operations during process closure and prevents any potential race conditions arising from the mismatched lock release timings. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Artemy Kovalyov --- lib/eal/common/eal_common_memzone.c | 12 ++++++++++++ lib/eal/common/eal_private.h | 5 +++++ lib/eal/linux/eal.c | 1 + 3 files changed, 18 insertions(+) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 1f3e701..7db8029 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -447,6 +447,18 @@ return ret; } +void +rte_eal_memzone_cleanup(void) +{ + struct rte_mem_config *mcfg; + + mcfg = rte_eal_get_configuration()->mem_config; + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + rte_fbarray_destroy(&mcfg->memzones); + } +} + /* Walk all reserved memory zones */ void rte_memzone_walk(void (*func)(const struct rte_memzone *, void *), void *arg) diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 4d2e806..944c365 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -81,6 +81,11 @@ struct rte_config { int rte_eal_memzone_init(void); /** + * Cleanup the memzone subsystem (private to eal). + */ +void rte_eal_memzone_cleanup(void); + +/** * Fill configuration with number of physical and logical processors * * This function is private to EAL. diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 9b59cec..dfcbe64 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1375,6 +1375,7 @@ static void rte_eal_init_alert(const char *msg) eal_trace_fini(); eal_mp_dev_hotplug_cleanup(); rte_eal_alarm_cleanup(); + rte_eal_memzone_cleanup(); /* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach(); rte_eal_malloc_heap_cleanup(); -- 1.8.3.1