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 21F9142548; Fri, 8 Sep 2023 15:18:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFF9C402DE; Fri, 8 Sep 2023 15:17:56 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2074.outbound.protection.outlook.com [40.107.93.74]) by mails.dpdk.org (Postfix) with ESMTP id CEEA2402DA for ; Fri, 8 Sep 2023 15:17:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JcUl148WI0kNRvvO6yHPZ/wsdTGl9vC4tjTbiGGgJ9cmvjiAXg9r63Kki2/OzPGMGp6YWOA8qplweEvD+GodxMJkGi8R9fMfPleLtL+9b6A7WlBSyMo0mbHqXCCMoiemgj/f/LGl1GMDQepJi5cGKCg032Z4x4NEj4J8/FBrbjUufoTi/zrDozmwW9ajwr1lQQcYCTH5kmh5CVIRlcdlE2vxkJ4RnJeTMoUI2kZO3FAI79ZujavbyYpQ8nxmws0HX8a1/KhhOEQ8ZG3WbvO1qPLMxVxCfTfyKtW7mafDMGxXEDNmw4DIsXO8aK4R2pCI0aZsJ3+2/RotqQwgMVH4YQ== 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=zKgf/sEDzJZxPCg/SCMy3t9FzhmSuP3jOO2Iv9FpVsY=; b=EBWvhnN9HSDMbfZ8vv8rLpToicZPqe9vYeeaIGm7/BcpxxyyT61ke0+Pfu/5bOVXs4jgi02KPnZfJmQrQoGHxH5kMHFxPdR51HEk3tQ1FiGCKNOrS2jU3C+1R2aqrosa7212lWP4MpGg+zQH30dDR3GC7Jvcel3XFkfOFNg9INrlk5Abez/nzr0QXCagge60NnF7lYtOWqT8MOOFvdWDk9YFlxov82TfkA8Xnh/Ugki/Hl/SksU5Amc2kfSBlrvxcf9WyI2uP+x7XfDtc6DUKOLT+LxKusTYablFaD8kelxLlr5ftLI0pUuvc5H8W53OdjtZ7c+ztqxFk6lgB/ncbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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 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=zKgf/sEDzJZxPCg/SCMy3t9FzhmSuP3jOO2Iv9FpVsY=; b=QBGhnlIRxvMw4O8nb1beRiR1cp2glW5A5za7PXyFykXKmj4S6fXCRNS6PDLw7BDiZr5M6AEhGJM5++m5AfeQRofuUG3JZYedKfaPEVTCGCdjJbqFKT1zsvZEQ0VJht97lzaOIm/ktW+ukL8gycNisL/6SCMLFwtNmJer2iD00aJpEoMmOrNmepI31kMok4loXfZwMU6q+F7K7jw+9sUkxEy2zzlX0z5wuDCwBM5CLQfMznf9N/LbBkYVWjO1RRBZIc9TLnlPfPxeD2DCc+IWFCpZoPKispMJfJ3huZHiFAFitsKgTT2CwZulpnLQKr6XQRQqBhfh+WxuHSYsGTpJ+w== Received: from MN2PR07CA0016.namprd07.prod.outlook.com (2603:10b6:208:1a0::26) by LV3PR12MB9331.namprd12.prod.outlook.com (2603:10b6:408:219::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Fri, 8 Sep 2023 13:17:53 +0000 Received: from BL6PEPF0001AB72.namprd02.prod.outlook.com (2603:10b6:208:1a0:cafe::db) by MN2PR07CA0016.outlook.office365.com (2603:10b6:208:1a0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31 via Frontend Transport; Fri, 8 Sep 2023 13:17:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BL6PEPF0001AB72.mail.protection.outlook.com (10.167.242.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 13:17:53 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Fri, 8 Sep 2023 06:17:45 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Fri, 8 Sep 2023 06:17:45 -0700 Received: from nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Fri, 8 Sep 2023 06:17:43 -0700 From: Artemy Kovalyov To: CC: Thomas Monjalon , Ophir Munk , Anatoly Burakov Subject: [PATCH v4 2/2] eal: annotate rte_memseg_list_walk() Date: Fri, 8 Sep 2023 16:17:36 +0300 Message-ID: <20230908131737.1714750-3-artemyko@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230908131737.1714750-1-artemyko@nvidia.com> References: <20230830103303.2428995-1-artemyko@nvidia.com> <20230908131737.1714750-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: BL6PEPF0001AB72:EE_|LV3PR12MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: adb24b5c-f283-4e80-efa0-08dbb06e023b 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: hP66Wa/sUA/yGMHsC5VgTUImwqvJ5bRIT6IUBwi+BfxGCL1nXFP7Fo1mdC580iHrvocBgQnH2Xbwlnx7J6nLUIrkzIZftE16RZCOHHq9KoizNZqTWECNcZSHKV3QnPPHz8c+n03KtwtSfSyuLJVTENjs+UG3O3T2rX4PA42W/pLzVK2PrRcRh1rdj9RU9FmKdhLNTWwNj8w8FjwmUluMCFhmGst2uNeOnN97p07dFZJu+CHO5Pv840u6iyt50EiQZNSItEuc8Mh0mtmO0RryDcBdh9wjqFzpkuP46JxiuOWg6K2mpA+LjsoWNCstMF+kGDPUcGhDFOJp6nE73ARAxinbHdY8lbbxZhW4mfvfclil9bv5/DwIHLNY7buQkfOPQfgJokxUkj9j4pD66wUi89KKCIQyyNcTt4s3VeqLCla6Ws0C07pqV4VVG0Cd4GoUvhoD3UgV5ecydYqNr96jO8V7ElZEQ1asUbTCmTxmZ+sC54BLHjIrnOFy/fHorapU1Lb0MHdC+vqhxNwX1t3q3OLjJNZX0LkrFeLOe54hh2R5Cn1URP7eMyx6tbCyiV0RVrrgDj9f3ykQqA2UUkkjjCwd3Gk2rq+9k+HeaRyHDlPSYeTPZSSj8Rn480tQsuHxuSKnAiGpJ8rEYzIgUxKcNLSLc2lMIhiwzCVs1GCg1Tlg5dfbO7qMKsTlmfFIENP1tO60sgHodpk+5m8XZQMVe5BCKaCQ3FGfCdRElJI0pMs= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(136003)(346002)(39860400002)(396003)(186009)(1800799009)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(8676002)(8936002)(4326008)(40480700001)(5660300002)(41300700001)(70586007)(54906003)(70206006)(316002)(6916009)(2906002)(40460700003)(47076005)(83380400001)(55016003)(36860700001)(7636003)(356005)(82740400003)(336012)(1076003)(6286002)(2616005)(426003)(26005)(86362001)(478600001)(36756003)(6666004)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 13:17:53.1555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: adb24b5c-f283-4e80-efa0-08dbb06e023b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB72.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9331 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 Implementing a lock annotation for rte_memseg_list_walk() to proactively identify bugs similar to memory_hotplug_lock deadlock during initialization during compile time. Bugzilla ID: 1277 Signed-off-by: Artemy Kovalyov --- lib/eal/common/eal_memalloc.h | 3 ++- lib/eal/common/eal_private.h | 3 ++- lib/eal/include/rte_lock_annotations.h | 5 +++++ lib/eal/include/rte_memory.h | 4 +++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/eal/common/eal_memalloc.h b/lib/eal/common/eal_memalloc.h index ebc3a6f..286ffb7 100644 --- a/lib/eal/common/eal_memalloc.h +++ b/lib/eal/common/eal_memalloc.h @@ -91,7 +91,8 @@ struct rte_memseg * eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset); int -eal_memalloc_init(void); +eal_memalloc_init(void) + __rte_shared_locks_required(rte_mcfg_mem_get_lock()); int eal_memalloc_cleanup(void); diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 5eadba4..ebd496b 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -115,7 +115,8 @@ struct rte_config { * @return * 0 on success, negative on error */ -int rte_eal_memory_init(void); +int rte_eal_memory_init(void) + __rte_shared_locks_required(rte_mcfg_mem_get_lock()); /** * Configure timers diff --git a/lib/eal/include/rte_lock_annotations.h b/lib/eal/include/rte_lock_annotations.h index 9fc5008..2456a69 100644 --- a/lib/eal/include/rte_lock_annotations.h +++ b/lib/eal/include/rte_lock_annotations.h @@ -40,6 +40,9 @@ #define __rte_unlock_function(...) \ __attribute__((unlock_function(__VA_ARGS__))) +#define __rte_locks_excluded(...) \ + __attribute__((locks_excluded(__VA_ARGS__))) + #define __rte_no_thread_safety_analysis \ __attribute__((no_thread_safety_analysis)) @@ -62,6 +65,8 @@ #define __rte_unlock_function(...) +#define __rte_locks_excluded(...) + #define __rte_no_thread_safety_analysis #endif /* RTE_ANNOTATE_LOCKS */ diff --git a/lib/eal/include/rte_memory.h b/lib/eal/include/rte_memory.h index 3a1c607..842362d 100644 --- a/lib/eal/include/rte_memory.h +++ b/lib/eal/include/rte_memory.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #define RTE_PGSIZE_4K (1ULL << 12) @@ -250,7 +251,8 @@ typedef int (*rte_memseg_list_walk_t)(const struct rte_memseg_list *msl, * -1 if user function reported error */ int -rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg); +rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg) + __rte_locks_excluded(rte_mcfg_mem_get_lock()); /** * Walk list of all memsegs without performing any locking. -- 1.8.3.1