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 E63D6A0534; Tue, 4 Feb 2020 14:36:41 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB9BD1C121; Tue, 4 Feb 2020 14:36:40 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2042.outbound.protection.outlook.com [40.107.22.42]) by dpdk.org (Postfix) with ESMTP id 0F0DA1C0AD; Tue, 4 Feb 2020 14:36:39 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jf7prNkRU3KNDLeX/ykkO/pA5ekvO85C48a5R3JkP/fC1Uz2lAs0YEt2fIHhH0FpkVIP9cjcy3A1VBVZbu6tigpZmQbWkXIeBKzFKFl6jJP1DNinzgnm0W/uryg+7q/yan4q+0hYe8uyjWCe7eWlxftW8rfX8hLsbww2XP/quxd0i2kLwjcfdX5dmcyDLMp0c7gV+7TyjP9ht91phDuSWvpxS8V0dS5t5huD7KSziBW3RQN39h4vPpgkCP9GWPxjE3bgC2uT//fGYi0Tb060l8ksEplQwdxoJoEOKI9JjLpVRaVjo3Ma092iJpKrXRiDhBm11JM0YjNVADu6vsemFw== 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=Gnfn2b+xrZTL5YvEfbDhvgPhtKStaea7oy7+cnfUQSw=; b=Af7G5HrJ+eF989LlKsWvUKplXhJ2iU5uEZ3/1fVs8AIfckuSj7nIb24Um6bnZSWQhlRbJvOZqyJJR/43hABZydq6t6qD1DtX0n8z6Kxpod71tKqtu9akBAfcAGZBYy5hKrej2KUzU8oxXXaCNtdZ7S93tIH/KduHWeExhDZ02Ocv/FlaEmqdavmmSVnU0aTpYXF2dQGsOp8hj1C00LocM+rmWwhcrn8jXJL4fHS5apjuhDJ8LPwoJxYw/lLjOPTlTtkmwIOS1NJp7b+J3bGspepkCS2ZIBaFs5dlL02X9w+GpUqdyUeBaCc+hz8XX8/AL6OYzQf4BtQfoWd6fzREVQ== 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=Gnfn2b+xrZTL5YvEfbDhvgPhtKStaea7oy7+cnfUQSw=; b=hetMNGfIpdj4BiaZd61UoVD7nPHefc525GsU0b39LM+Tqljetb/gboEUYrrd6XPJ2quZbANX4HmOgeHYE9IxieLUiMoAKO/oxAsW8q52ycvkNKOviAE2ZqxjRPaUM4cWgb8luGpnNxrfLbXPkCV6GTySzdAvho6QXqzxhNDGIyo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=michaelba@mellanox.com; Received: from AM0PR05MB5074.eurprd05.prod.outlook.com (20.177.40.211) by AM0PR05MB5235.eurprd05.prod.outlook.com (20.178.19.150) 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 13:36:32 +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 13:36:32 +0000 From: Michael Baum To: dev@dpdk.org Cc: Matan Azrad , Viacheslav Ovsiienko , stable@dpdk.org Date: Tue, 4 Feb 2020 15:36:09 +0200 Message-Id: <1580823369-184116-1-git-send-email-michaelba@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1580810881-177458-1-git-send-email-michaelba@mellanox.com> References: <1580810881-177458-1-git-send-email-michaelba@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: PR0P264CA0017.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100::29) To AM0PR05MB5074.eurprd05.prod.outlook.com (2603:10a6:208:ca::19) MIME-Version: 1.0 Received: from mellanox.com (37.142.13.130) by PR0P264CA0017.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.21 via Frontend Transport; Tue, 4 Feb 2020 13:36:31 +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: 55a6ec44-d729-4d27-0ff1-08d7a9773ef2 X-MS-TrafficTypeDiagnostic: AM0PR05MB5235:|AM0PR05MB5235: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:207; X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(366004)(346002)(376002)(39860400002)(136003)(189003)(199004)(6916009)(8676002)(16526019)(186003)(8936002)(26005)(81156014)(81166006)(86362001)(7696005)(36756003)(6666004)(2616005)(8886007)(956004)(5660300002)(52116002)(2906002)(54906003)(316002)(66476007)(66946007)(66556008)(4326008)(450100002)(478600001)(55016002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB5235; H:AM0PR05MB5074.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: 87nkBqhzvd69E9KwN2nk5+6wQ+WybhBwGbvtwuQXZdp9LPE/u325HnNbs5O6xRrcS9F5irfMBqujUhmw0EV4DenMkxtTjFBfIeEX566TJjyhoLVtcIcudaQ6Bdsdz1+hWX1KebG6ZY8ENhU4HXqahiIuYbM/JT8lfU4NJHR/UuXrcb0eFMUvXVERr+gLoCfKnJf0RuP7FIulujUi5T5h+Qn7BSHRfQiCDvnxhN68WRvexyhymb0XfCcahOLKPoyLoWtsUtHKlKSpUCrZ0WODQdrqPXkgWwZvLeuVu7MNmSBHN/3LpG8ChJmrk1OOqxvQseebKjHeIocIwSaE73WIQ1uWGcLkY9uRaUSYlcGn/0CBzHJcWmoooW1gaAI5tEC/yXroYDvneoGwp+a5AgMYsZdheONUWLdG1RrvJ+qJ+9dacGMH5UUo9OCI0qnzwvv8 X-MS-Exchange-AntiSpam-MessageData: gnmNNP51eF5FuibdtSDaBYQAZx3sq08LvCZBnoWwUKzKC7AvMJ8julmbYKCnQu5L3f4BuBcIqEZCA5gWafWHVkFxeMszippGfZ8NfH1haWH1Ws0nER4v/0c8Hijmj2RLSlwIkqcJb9xzhnaSQ3wmVQ== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55a6ec44-d729-4d27-0ff1-08d7a9773ef2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 13:36:32.0446 (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: X1KO99/qicLpu1EYzW1p6NGdrHGfiraBl0nevPjrVQP+UghT85ut4KtJAz7Qx+LDWXYQ1DPH4arcwepvbMqIdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5235 Subject: [dpdk-dev] [PATCH v2] 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" The mpx5 PMD maintains the list of devices for those the memory operation callback routines must be invoked to keep the device MRs (MR is the entity backing the hardware DMA transactions) consistent with the mapped memory. Each device context in the list is protected with dedicated lock on per device basis, which might be taken inside the callback routine. When device is closing the PMD frees all MRs by calling mlx5_mr_release(), that might call rte_free() under the taken device lock. If this rte_free call triggers the entire memory segment freeing it, in its turn, invokes the callback routine and attempt to take the lock inside this one causes the deadlock. The patch proposes the remove the device from the callback list first and then call mlx5_mr_release() and free the remaining device MRs explicitely. Fixes: 0e3d0525b2f2 ("net/mlx5: fix memory event callback list") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Viacheslav Ovsiienko Acked-by: Matan Azrad --- v2: rephrase commit masage. 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