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 6CCA9A0538; Wed, 5 Feb 2020 10:44:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9CF2D1C1A2; Wed, 5 Feb 2020 10:44:45 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2055.outbound.protection.outlook.com [40.107.22.55]) by dpdk.org (Postfix) with ESMTP id C62A31C1A1; Wed, 5 Feb 2020 10:44:43 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kM8yetKSqoG3SSBkNmzvZeOrRQZMklOU6EFxx51RvN4nuOdyi/PoyvtY5zrW0DRxqmOFepjXuF0N+o+IOu32fE9KtNmdO9dUtCYv4IOGNc8ch3WU4Jdj75h+jWBPICGJmTcGhmbvLNpbqmhb/jeo+X18ofiV72pNioz2RTBfeLxyrOnqwUi3AKKoPCIbwKsm7rfxqQaPoOlYEMCI3v3qUR40jXTRBhVMW4c8hu/Yz23SkjcYIeeOI+L90TFwkGz1yJmIZCZQ2ye/ctvly+BCzdi15CojHb9I3CQY+HASRpDbwbmVjoCwZwCdStEtieRspYBLtKr+EnCCsKvBRcCJ2A== 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=fbjtSGWXYQKHPOBLfzstBxOUpzEcZN57ib0zdiV2T3o=; b=Gl6y2DuwPzcVUOCTJj8BupZi68BdASnQwfrKPyJdxuuZEAYvIliYLYgcNY+yz88u/Z/mVxVXY5EQszj2ix8pEgce657+HsFeSbCcHXt9+aiktl35njR2dpRq5kRzxe8LRfbhL+TZ5gkRwalFd08fHnLiE3IXXgmIgq+0v9awxUJRwkk5rtnavgRKmDGly9CtHNB7IRt2CAd8fatndeNZpH7dFKKhdTvgSxuUS8wSLWZkE4fQ92KNFvXOJ+8qyB6JdEF5ntUICgtVw9ZnhS3Gsk9jUbLua1pRTBDekU2m3ZSwuubJCwUfiAEP9s4KLu0DHEPNY++i9btkNu4uwD62rw== 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=fbjtSGWXYQKHPOBLfzstBxOUpzEcZN57ib0zdiV2T3o=; b=WjA7FbE6YvqdfENFG0bYI/KLL+sIM0oHfag+a8ZMg2NI8Cnzw8ZhvhSBzf6Lbg/LHAfiMy58basWf+ck2ubOPGEINoq73IiJVeFrTN/qwtSynBNqLPUgiNyusSfDDf68Onhufgz6HTgq5ORHP7nedVz9slOkVxcV2Z0V6VM+SCU= Received: from VI1PR05MB6718.eurprd05.prod.outlook.com (10.186.162.137) by VI1PR05MB5998.eurprd05.prod.outlook.com (20.178.126.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29; Wed, 5 Feb 2020 09:44:41 +0000 Received: from VI1PR05MB6718.eurprd05.prod.outlook.com ([fe80::25a1:c32b:29a1:fe8f]) by VI1PR05MB6718.eurprd05.prod.outlook.com ([fe80::25a1:c32b:29a1:fe8f%3]) with mapi id 15.20.2707.020; Wed, 5 Feb 2020 09:44:41 +0000 From: Raslan Darawsheh To: Michael Baum , "dev@dpdk.org" CC: Matan Azrad , Slava Ovsiienko , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2] net/mlx5: fix memory regions release deadlock Thread-Index: AQHV22Al2kmwVEMi9kiCPs0vqUO3KqgMWl+w Date: Wed, 5 Feb 2020 09:44:41 +0000 Message-ID: References: <1580810881-177458-1-git-send-email-michaelba@mellanox.com> <1580823369-184116-1-git-send-email-michaelba@mellanox.com> In-Reply-To: <1580823369-184116-1-git-send-email-michaelba@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-originating-ip: [212.29.221.74] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: fbed0194-c2db-4517-1aff-08d7aa200623 x-ms-traffictypediagnostic: VI1PR05MB5998:|VI1PR05MB5998: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:207; x-forefront-prvs: 0304E36CA3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(346002)(39860400002)(376002)(396003)(136003)(189003)(199004)(4326008)(7696005)(86362001)(450100002)(66556008)(66476007)(66946007)(81156014)(26005)(8676002)(81166006)(76116006)(66446008)(64756008)(6506007)(53546011)(478600001)(52536014)(316002)(54906003)(33656002)(2906002)(110136005)(8936002)(9686003)(55016002)(71200400001)(5660300002)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB5998; H:VI1PR05MB6718.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: H3JI6A1JvWyU88PUBLKKNrVIRnm9t63gO3HXkVIR/HtLNPsCmc5ausK8ACrjM7WJy4bLMM/iygg6X6Ino0aFh6VLfp6XcGGnKkgM9Mh0MjqhOEbuNNPyhWrD3Ja1okPBVOjAwfnWSBgwvf4ywxzBQest9Wlu5u3oARoCb5SirLcfFhof+vnNl7HmdrB9aTW82aKeoVlN3mPSdHzaSOiahI16scNBcJv6DayKSzelQPZG8ECnE4nOTrt6uYSLriGAKOJOBEvMQgIUcXNPQvKW71mTOM0ZxlgfpwzNSQQ0JPJ8IRiJznIYwzTT57Wy0mm2puxIoxgMKCI9y58c1wbgIQ7CN1AJRqT2tjEbvBOkypumxxcF2KJXiP7sU/Beriz4P+3+3z54csVJdINu0C9L5pWAhNouPhdHRy1V6u/m2Zxv7P4GvGUzz9EBeztEjCBV x-ms-exchange-antispam-messagedata: OwuiQvBSlHuXqKS3zZbLZpNdC5W5jvnSQMjRX9QfBVnUhXUwdoT1CMHzCKXl1+60Toy3UqJlJDSmXOVaQVScSivTkJXUWDvHsnRrpw3NNgU17J9h82TdpbMOf32GvRYPUib+kD/MJh//VnOX1Q7gxg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbed0194-c2db-4517-1aff-08d7aa200623 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Feb 2020 09:44:41.3937 (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: oBzPwWP9kWVOB0f6/Ew+pmxO4QVGFaxDCoOZV7eYds4DW6cuKMua5uGXZ9fiYYAhXmFB1vTrjvqfL0x73SPyKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB5998 Subject: Re: [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" Hi, > -----Original Message----- > From: dev On Behalf Of Michael Baum > Sent: Tuesday, February 4, 2020 3:36 PM > To: dev@dpdk.org > Cc: Matan Azrad ; Slava Ovsiienko > ; stable@dpdk.org > Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix memory regions release > deadlock >=20 > 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. >=20 > 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. >=20 > 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. >=20 > Fixes: 0e3d0525b2f2 ("net/mlx5: fix memory event callback list") > Cc: stable@dpdk.org >=20 > Signed-off-by: Michael Baum > Acked-by: Viacheslav Ovsiienko > Acked-by: Matan Azrad > --- >=20 > v2: > rephrase commit masage. >=20 >=20 > drivers/net/mlx5/mlx5.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > 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() =3D=3D 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 Fixed typo in commit msg, Patch applied to next-net-mlx, Kindest regards, Raslan Darawsheh