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 571B142D46 for ; Sun, 25 Jun 2023 08:37:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5185C40ED8; Sun, 25 Jun 2023 08:37:19 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.85]) by mails.dpdk.org (Postfix) with ESMTP id E37BD40A7F for ; Sun, 25 Jun 2023 08:37:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SuGboIk22f8ykNFltzxOcx0Ay+i9jJqWLhdOTQiLzpGTxmOXsRKNUBQ4DfBL5FSN7466t2axsWvdmUBe2iqCWOMfLNLqRm0NrzefJkynnC9O442U8369KCT9/sGkkpMUtq8DqInRa4ZLYYpk9OXA97QhjqiEZRnZXkJXUxwHasl2VTZ/uvENRppc4FI55Vx/87WLSojC7RYbVT6mbcXOTDut6m7ZkY7kxoNw9ka0y+NQ71ZgUmIsmlIK/SnXi9WZ+X5dNhkfL5BFGeU4TvkcL8thsUnVIBiPN6/kmB85LrWIhElAa6Qyjw82vmO86FaJ3e1+tLH7OkBXfy0c2vIP6A== 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=cVPtM2iRa3Y5v54+QhPbRS0UFfumBxV0aRaj+8RVml0=; b=Ekk1gQYAP9IAWWVQHalvEpk6RhtDZdE4UTBvPzXVXhI8u5YQGEstq1wLJoJdfshWe7bC8Ks1inisEU24NLIIcF+LQm2w8cvgphOr6IjjlYWG0g160WXCCKPHwASycmTeZ7/K/zLZzXfvCi2TCdCEXuZntqcmA14hOcjz9QVc8LSCF12NnY8ZPuyQJLiHX2MkRPHcSi7vs70z/u1oOolSyLAIlk5QNlfLKhRM6zv6vAmwkN/24s8Iq0jKRv7iz/3GqhTS2IdAO4kg1OJO35sp0/IcMUOzxmQOEF6SLRQRyi2ZFxdx7a4RBoNAMiVYLcIyKvknUjW7bDNkqtEKLqbCAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=intel.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=cVPtM2iRa3Y5v54+QhPbRS0UFfumBxV0aRaj+8RVml0=; b=JNGfKpGDb4kHLoZAyF8uNhVx2JSvjG5HhfQ22JWnqiCnxjrqsdUnUP6D7kjlSzEy5+FWliwz7+bl+pVRfFHPla2dZdDYF2A8gCmzkopgg5FPUAhLj1Fa4wCj6sWMEcbrHQrNTdU9hp8sAKTvGz4luWYYBIpracIpVLDt/xMysG15yqzem0Rp98EJQPYiRKmWRqsj945kpVVSsc3j76zDy2AOMQukz4sT4eBXuvjShwaQclsbwb+7EOy5UaaOlCcSnWl+5Xonb7QpLTd7Qv8mBH4sVqP654Ler7S3qN4fvn9++xZ37QJgWf6WWoueAbW1DuWUv9Z5RA/WmPuRytsl7A== Received: from DS7PR07CA0015.namprd07.prod.outlook.com (2603:10b6:5:3af::26) by DM4PR12MB7696.namprd12.prod.outlook.com (2603:10b6:8:100::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Sun, 25 Jun 2023 06:37:16 +0000 Received: from DM6NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::cb) by DS7PR07CA0015.outlook.office365.com (2603:10b6:5:3af::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.33 via Frontend Transport; Sun, 25 Jun 2023 06:37:16 +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 DM6NAM11FT053.mail.protection.outlook.com (10.13.173.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.47 via Frontend Transport; Sun, 25 Jun 2023 06:37: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; Sat, 24 Jun 2023 23:37:04 -0700 Received: from nvidia.com (10.126.230.35) 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; Sat, 24 Jun 2023 23:37:03 -0700 From: Xueming Li To: Bruce Richardson CC: dpdk stable Subject: patch 'eal: avoid calling cleanup twice' has been queued to stable release 22.11.3 Date: Sun, 25 Jun 2023 14:33:51 +0800 Message-ID: <20230625063544.11183-14-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230625063544.11183-1-xuemingl@nvidia.com> References: <20230625063544.11183-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT053:EE_|DM4PR12MB7696:EE_ X-MS-Office365-Filtering-Correlation-Id: c56b6f0a-dbd3-4c7b-de50-08db75469db1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fp5fwFXd6XJ1o4nKyZ/FmOXO1X6hModAhapT7mVH5WpDP8KLTSgC2UI8t1F+p/SNMzfvx0j+u3C7FBnv8e0fROabVlcm5GFi9jVDjYnQj0c/jEsr297mHNqOHiVBnSE+a55k/gEyrChQ5h41yMnA8mOYzTVtPKH8f+CCovi7zj9eoVCTCq5IZGytMSebwiWrDQ9qW963plHxVlpMMG3I7SFPZvWALmk6rFE27uV3p2QDTv6DMbH2MAjtR9n5+PueDAGc8kdojG6YCyilLDaNo03vdUtIVPHFOi6fJN1qc8wgt/cZJgiXJnszqXTbQxaNYj9xp540QAprSWj8sVYh4znX64kEhdYaBtXb4FAnK7KECpqc9K6rF+S/Jjt5DDtnU4mlq+vi+CbNwXehFhbnjTJfbWZJTxFaScS4QBa7F5Jvp3uDNweDJuQ8EMnd6z/bLJ4N0HH0IMhBAMqDdxPr5p8mUIJ7lECXhzPOZqoUtoiOBIILuiMAsoPiIiSaH4zkXgowtkL/LUEibjZQU2/h+dxDFVXtFr5aODpGyt44uAcX49B3Kln3UYlQpLV+n/L7pvZY6dL6x7Xv5zty8N6O596aQ6I09GscwvIZcuoNA4Mycoi+v8yZ+jF8d6Nq15Q8zdORtMVDYrwgvi7668ZMKWUujKYmUUkrqswWT5SJhpTDVof7bbryNGir5dygNzq6h9Ao+KArwoEgNlh8phGm6e754/NWusYjAQ1Jkq9DVJDF5vmdQrW/yNMRGFlIBh8O+XzGRAkxL+8baFtkCB8LtQ== 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)(346002)(39860400002)(396003)(136003)(376002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(82310400005)(40460700003)(36756003)(70206006)(356005)(5660300002)(41300700001)(316002)(86362001)(6916009)(8936002)(8676002)(40480700001)(4326008)(55016003)(7636003)(70586007)(82740400003)(966005)(47076005)(1076003)(26005)(53546011)(2906002)(16526019)(6286002)(186003)(7696005)(478600001)(426003)(83380400001)(6666004)(336012)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2023 06:37:15.5491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c56b6f0a-dbd3-4c7b-de50-08db75469db1 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: DM6NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7696 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.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/27/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/commit/?h=22.11-staging&id=94babf61c59fd4d0089e5131975fb3071c4247b6 Thanks. Xueming Li --- >From 94babf61c59fd4d0089e5131975fb3071c4247b6 Mon Sep 17 00:00:00 2001 From: Bruce Richardson Date: Thu, 1 Jun 2023 17:08:55 +0100 Subject: [PATCH] eal: avoid calling cleanup twice Cc: Xueming Li [ upstream commit a4a2ac988679b3802a574e7bb72154da177449a4 ] If an app calls rte_eal_cleanup() inside it's own code, then cleanup could be called a second time automatically when the app exits. While mostly harmless, we can avoid any potential issues by guaranteeing that cleanup only gets called once, in the same way that eal_init only ever gets called once. Note: This patch only touches Linux and FreeBSD. Windows EAL does not have run-once guard on the init function, so omitting it in the cleanup function. Fixes: aec9c13c5257 ("eal: add function to release internal resources") Signed-off-by: Bruce Richardson --- lib/eal/common/eal_common_debug.c | 4 +++- lib/eal/freebsd/eal.c | 10 ++++++++++ lib/eal/linux/eal.c | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_debug.c b/lib/eal/common/eal_common_debug.c index dcb554af1e..9cac9c6390 100644 --- a/lib/eal/common/eal_common_debug.c +++ b/lib/eal/common/eal_common_debug.c @@ -4,10 +4,12 @@ #include #include +#include #include #include #include +#include void __rte_panic(const char *funcname, const char *format, ...) @@ -39,7 +41,7 @@ rte_exit(int exit_code, const char *format, ...) rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); va_end(ap); - if (rte_eal_cleanup() != 0) + if (rte_eal_cleanup() != 0 && rte_errno != EALREADY) RTE_LOG(CRIT, EAL, "EAL could not release all resources\n"); exit(exit_code); diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 390e4257ff..122daf6c1f 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -889,6 +889,16 @@ rte_eal_init(int argc, char **argv) int rte_eal_cleanup(void) { + static uint32_t run_once; + uint32_t has_run = 0; + + if (!__atomic_compare_exchange_n(&run_once, &has_run, 1, 0, + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { + RTE_LOG(WARNING, EAL, "Already called cleanup\n"); + rte_errno = EALREADY; + return -1; + } + struct internal_config *internal_conf = eal_get_internal_configuration(); rte_service_finalize(); diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index c76f026023..7b0eafd565 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1354,6 +1354,16 @@ mark_freeable(const struct rte_memseg_list *msl, const struct rte_memseg *ms, int rte_eal_cleanup(void) { + static uint32_t run_once; + uint32_t has_run = 0; + + if (!__atomic_compare_exchange_n(&run_once, &has_run, 1, 0, + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { + RTE_LOG(WARNING, EAL, "Already called cleanup\n"); + rte_errno = EALREADY; + return -1; + } + /* if we're in a primary process, we need to mark hugepages as freeable * so that finalization can release them back to the system. */ -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-25 14:31:58.929963600 +0800 +++ 0013-eal-avoid-calling-cleanup-twice.patch 2023-06-25 14:31:58.295773900 +0800 @@ -1 +1 @@ -From a4a2ac988679b3802a574e7bb72154da177449a4 Mon Sep 17 00:00:00 2001 +From 94babf61c59fd4d0089e5131975fb3071c4247b6 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit a4a2ac988679b3802a574e7bb72154da177449a4 ] @@ -17 +19,0 @@ -Cc: stable@dpdk.org @@ -53 +55 @@ -index 7daf22e314..78ffb45c59 100644 +index 390e4257ff..122daf6c1f 100644 @@ -56 +58 @@ -@@ -902,6 +902,16 @@ rte_eal_init(int argc, char **argv) +@@ -889,6 +889,16 @@ rte_eal_init(int argc, char **argv) @@ -74 +76 @@ -index ae323cd492..90e05fe4de 100644 +index c76f026023..7b0eafd565 100644 @@ -77 +79 @@ -@@ -1365,6 +1365,16 @@ mark_freeable(const struct rte_memseg_list *msl, const struct rte_memseg *ms, +@@ -1354,6 +1354,16 @@ mark_freeable(const struct rte_memseg_list *msl, const struct rte_memseg *ms,