From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 69B07A0531; Tue, 4 Feb 2020 11:08:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A5C921C00D; Tue, 4 Feb 2020 11:08:43 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60058.outbound.protection.outlook.com [40.107.6.58]) by dpdk.org (Postfix) with ESMTP id C6CDA1C00D; Tue, 4 Feb 2020 11:08:41 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OjXBo1FwY0zIyzNEASAdvktCNWTAm/ambzWJ9pmTd3O75vidQ7UP3qXAVkop12mwmDk7z+X+ApGvYiXqodfxdv208T4JGsSmod7TsstquwOg7cce4UiNQbNKAGrVf8owsvEAbPe62XFzIZP1mrZ7EIsfHEjOVRwUFXExWhTYjNQ6TaHKTKs7fL4+T9tBg+QPIQ/H0ZrZmbapdCpjgCzo0hGb/WCi+GpsuBLtVpmPKQ7mbmDub2tk1wG7VIAMzvwNANFsxO3rm25gAlg4pe8Bs80yJGlxqBGxahQBXM6u1pUHMFRiN9gPvsXMReNsnX6PmeSqJNb0knuo4H2W/lV5fg== 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-SenderADCheck; bh=cgtSYU70mJzqUTY0LvX/5RNoO8f+UZwrfmdUwpX22Z0=; b=c1YfVqXm0VgBAr8URMVyFqMakyYwFmne4wLS7x0jlo+Z03mbDeThfsZmItz9i3uhkP56owPDyXI9fIS0xzrhC9BqfI/wxyo77c7N2pfjn/Hos4HTeNUuY7DTBHo5meX7/f6YYpFm0FqmmkApLdWQagFq5ZiuXCRQeUjIgp6t3ekOiHIEaSoy4D7hIePlfGB782sqH96JWoT5DA2Ulyg6pbl8h50a/Iy4rRYQHSufL39SMk9qv5OSv0wlv3mjFk7iw4Ef67gtsEJJzyXfi2S2Amr7FvM0r0wXCJXT10XXPj2YTSCSAGoIkOU0UT6/ozJVmpxN8CRGZ58i1Lzq9pofEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cgtSYU70mJzqUTY0LvX/5RNoO8f+UZwrfmdUwpX22Z0=; b=MEaYkN9xUkctGjMtR5Y6yPcev+W5q0S7i7dnJJblEhsLidO8Gw0r5vJqeICofgNxt4v/Wkq9vR526NbbHct5iJ26Swd7xdKKP1KbO282hjWL3IrJv1uB4duqYEqyTE5i9jfUrx89/bXpMoJIei4RNduCmcK8ri9oBn+ELLJtOSw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=michaelba@mellanox.com; Received: from AM0PR05MB5074.eurprd05.prod.outlook.com (20.177.40.211) by AM0PR05MB4354.eurprd05.prod.outlook.com (52.134.90.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.27; Tue, 4 Feb 2020 10:08:40 +0000 Received: from AM0PR05MB5074.eurprd05.prod.outlook.com ([fe80::b0db:6112:47ec:8e0d]) by AM0PR05MB5074.eurprd05.prod.outlook.com ([fe80::b0db:6112:47ec:8e0d%6]) with mapi id 15.20.2686.031; Tue, 4 Feb 2020 10:08:40 +0000 From: Michael Baum To: dev@dpdk.org Cc: Matan Azrad , Viacheslav Ovsiienko , stable@dpdk.org Date: Tue, 4 Feb 2020 12:08:01 +0200 Message-Id: <1580810881-177458-1-git-send-email-michaelba@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Content-Type: text/plain X-ClientProxiedBy: PR3P189CA0050.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:53::25) To AM0PR05MB5074.eurprd05.prod.outlook.com (2603:10a6:208:ca::19) MIME-Version: 1.0 Received: from mellanox.com (37.142.13.130) by PR3P189CA0050.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:53::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29 via Frontend Transport; Tue, 4 Feb 2020 10:08:39 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 78523a11-af00-4314-f7da-08d7a95a3565 X-MS-TrafficTypeDiagnostic: AM0PR05MB4354:|AM0PR05MB4354: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:449; X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(396003)(376002)(346002)(39860400002)(366004)(199004)(189003)(8886007)(55016002)(66556008)(66476007)(4326008)(66946007)(450100002)(6666004)(316002)(81166006)(54906003)(956004)(2906002)(2616005)(86362001)(8936002)(478600001)(8676002)(81156014)(5660300002)(36756003)(52116002)(6916009)(7696005)(26005)(186003)(16526019); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4354; H:AM0PR05MB5074.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m1gDp8J4myPIJqIUzJ6M6L71PGRGs/SFM4i2/y45R6p8vJMvl53FJLgfV3ZQ2iwnoVFlqywzLFRg5MvuMBOB8MGa9iUXsVY5fxC///7o82ZTcYqKPHnSk9MX5Kwc7fLWEV/xMUf4xKGJjOncYI9hWUej9zFDqgH5OLkoUb8teCI82qXu2Qg83W1Yo/PQ/MFWcJG3hppE4gnVy0Va9Ms7pDd45QLWigTO4QoQsFdKF8Agh/7dktnYxhQYX/GlChX50H15zAK6p0UfEJmz89+MCLZLf0rmA9LHJ+Oa0TvcaFaalv737APZnU1T9p0mjD/MEx1Vtua4zg2/wRoVvaS4+xPtTzTmgVihaGWyIZ5KDv+9UbBe7ShB7sGrQEiCvJ1BCDxzgyHnb3mmWYmGponyqPKL+bfZwRgYtpyOS+B9b20qPBpOrDewab8tQnMyFQ0g X-MS-Exchange-AntiSpam-MessageData: JQUTlm6bQJ9uzpjHlw211Gi8bd84/8ofCn0LYTDzHgoe1OxUpjNkqBcyzRw9jeIMlngkYD99IRsPi2mPaywIwLtjNZAX7c3q5+iIDjw/rX+/pkPKFdNnQu1Erhf7LzC7ZeNTqWylplsQmEfLmBtr9Q== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78523a11-af00-4314-f7da-08d7a95a3565 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 10:08:40.6688 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i32xGk2YbUZLpBqP/MbN98qyvLNnGpUx77qZaQfIsYZl8u9tV6c2kb1HRQWkk64nokVPyeFVOI5YTcjcG+xBxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4354 Subject: [dpdk-dev] [PATCH] net/mlx5: fix memory regions release deadlock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When we create memory callback list, we add cb function managing memory regions. This function uses lock. This callback iterates over shared device list and takes a lock of each shared device to avoid parallel accessing to the MR list of the shared device. When PND releases memory regions while the list is exist, the callback function maps the MRs using the lock. In shared device closing, when all its MRs are freed, the same lock is taken. The MRs freeing calls rte_free what may trigger the memory callback. The MR freeing, wrongly, took the lock before the shared device removal from the callback list what causes the deadlock. In order to solve it, first we remove the share device from the list and then release memory regions. Fixes: 0e3d0525b2f2 ("net/mlx5: fix memory event callback list") Cc: viacheslavo@mellanox.com Cc: stable@dpdk.org Signed-off-by: Michael Baum --- drivers/net/mlx5/mlx5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index f80e403..759491f 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -679,12 +679,12 @@ struct mlx5_flow_id_pool * MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY); if (--sh->refcnt) goto exit; - /* Release created Memory Regions. */ - mlx5_mr_release(sh); /* Remove from memory callback device list. */ rte_rwlock_write_lock(&mlx5_shared_data->mem_event_rwlock); LIST_REMOVE(sh, mem_event_cb); rte_rwlock_write_unlock(&mlx5_shared_data->mem_event_rwlock); + /* Release created Memory Regions. */ + mlx5_mr_release(sh); /* Remove context from the global device list. */ LIST_REMOVE(sh, next); /* -- 1.8.3.1