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 1EB79A0032; Tue, 16 Nov 2021 15:49:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4D3B411F3; Tue, 16 Nov 2021 15:49:42 +0100 (CET) Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2108.outbound.protection.outlook.com [40.107.113.108]) by mails.dpdk.org (Postfix) with ESMTP id 2BBD74115F; Tue, 16 Nov 2021 15:49:41 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dy8IhMk61IBQoKRv4PCjasXcx87N8Z9DTMtMiNI4tCFcTL5fJLNDlGIzY2ySZFkzCVAdGmF40oak+dXQbIm5KebXsG0lXYSL092yF91+wKMQX5K9fvboqXskEOsyZG2YATOuD0d7bQa3d/jW++XwHs4/Jg7EENqTEThtAY1PNqxABeWl+iPd1JsZKJYOZXE1WKtd1hbQY54+3w3heLgUgUltmPitxcvhgeroV6DudBwNga0BSE2/cx/OBVh2dGi7TA7RV4CZRxao5lwSFiQuk/q3QCJJD26zPlvsuimV76kneGUS4/HdohpdPc/0ua5itsKt2QM8e4fqBEUwkQwmZw== 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=3ouEqI75JWe169fO/CtV/QRYMww0l9HBQJxiam9lQWM=; b=GbQuvlHLZV+/cCueEU8ZCWXpFHD4Tt4qf/WB8m3N7TkzkTnm7WyGjwz5YE0q8+9DxH4l9tgtPRpk5QNzOq/Pu7J+vmZP3i+KSv5BRb0qukBznYzMa5B0aNua3B6f/lUhR3Pz8OKM99B0lEEwryVb7GFz0f1Twv2XtcMnaWMhPX2gg/EmzB+KjowqavHMoGs2I66c5if0AHUeuvSvv/zgbmhNl0R87AUXXIqjflegL6YARqnjyI26T5viov3j3EUew8VMwZvrhOEJ/T2tx0xKTZH2OKYOGw1bZssWDaHNAsUIn9ZrTyELN9SqOHrrTmqdmh10UoE6m9z5wmhWQ838Bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=connect.ust.hk; dmarc=pass action=none header.from=connect.ust.hk; dkim=pass header.d=connect.ust.hk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=connect.ust.hk; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3ouEqI75JWe169fO/CtV/QRYMww0l9HBQJxiam9lQWM=; b=A5CoVK4VWciRqhtMMx6b7LTaJNYgA+w3LTQxwC2TQpbXfUa57LwLarC1nOb3/52WvMZvETBO5njsd0NisX3QmTSgFgtUeymK3zRNfe4fjjDQVwLDQmLUP3fRGGDdC7ZiP6kOLIy6yG+WdfWFrmhkevpJ+Qz2LelwRw2eR//V1u0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=connect.ust.hk; Received: from TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:b7::8) by TYBP286MB0256.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:802c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.17; Tue, 16 Nov 2021 14:49:36 +0000 Received: from TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM ([fe80::c0af:a534:cead:3a04]) by TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM ([fe80::c0af:a534:cead:3a04%7]) with mapi id 15.20.4690.027; Tue, 16 Nov 2021 14:49:36 +0000 From: Chengfeng Ye To: matan@nvidia.com, viacheslavo@nvidia.com, tzahio@nvidia.com, ferruh.yigit@intel.com, rasland@nvidia.com Cc: dev@dpdk.org, Chengfeng Ye , stable@dpdk.org Subject: [PATCH v6] net/mlx5: fix mutex unlock in txpp cleanup Date: Tue, 16 Nov 2021 06:49:23 -0800 Message-Id: <20211116144923.7342-1-cyeaa@connect.ust.hk> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: HK2PR06CA0012.apcprd06.prod.outlook.com (2603:1096:202:2e::24) To TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:b7::8) MIME-Version: 1.0 Received: from ubuntu.localdomain (175.159.124.155) by HK2PR06CA0012.apcprd06.prod.outlook.com (2603:1096:202:2e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Tue, 16 Nov 2021 14:49:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b417923a-ad16-472d-2372-08d9a9104f1c X-MS-TrafficTypeDiagnostic: TYBP286MB0256: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:224; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EDJ20oh/dxPfNudL3QgSUwKD7GZ6Qu/v8mFVAm0nDqmZ/TouSz3/kVlnTmfhThq8TsIojF0bmB3/hjUr5h50hucuz4h5vDR/XZbyVwoRHqf+kpp982hEPTSkDdSwKPN7OEtFvI26RNt5X/ZrRmDYY9yAncyTbRAvUhewCDR9sMR7cyHbwIMQj2l4slDyHrNGhRtxSp+XBaLVL1sl0a5kizicYnAVYV0WZa/D7d9K46P3tMZNq2cY3NIb12mSOwwEgwCdHm7rLJDhkYxH5H4C8BzOWf7PMLg6iXukq1/Hvbo7nKm/++J0z56w8ajj9CCZpwRlGXyWXglXH6K7TiAx5NU2P/3sXsHUV714DHDAf6k13TCr89n1pW/jiUDK6iq2M9FP9S9vMjlFbhoCgQTGoIaJqYiC9RRR1TuZHx3aI0Zh6D7fuongPydOn6LCpszWHj4GM7B3mI95MCpSLPe9k40jgqThxaEPGfI75DMBa39OI69cgJGavuh0nOdSUXDmq637Gygr+cxWX3PQidxyAdm6fdOwU2kqxji13cbFo+9SuSS4Rr67b9rabyxrPhRATXRC3I1ppelDfKMZcE1yZPjpPerYaS2+T2AK9sELlK1xlXdrvVu5H8SV7zDR93A6uegtAriyte0t5sqsC5+hjY5G8LkXTdXu79PK97Qmp/QDKfWMzvbG0Xd7nnKW7tEzq9pVPRAyNbKhEZAWKSLsxg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(86362001)(5660300002)(786003)(83380400001)(2906002)(316002)(66556008)(186003)(52116002)(66476007)(36756003)(66946007)(26005)(6506007)(956004)(1076003)(6666004)(2616005)(6486002)(4326008)(8936002)(8676002)(38100700002)(38350700002)(508600001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Zxdw0p9oSJJqqhxompRaOFqqpgCSr596FPNwG0LzKILRvUvhtHL6Ry5CKm3p?= =?us-ascii?Q?34Tr9sk3/u7bX+qec6DT5q/5f1zs3LtHEBd1M54VHCxGcJ+s/mTPFMrkxB+H?= =?us-ascii?Q?ylfBBg2/6HCZf8YZbvQ1TTjyoqHoQNREgkXr53lIq+T+VDF9dq7lTqSxm9es?= =?us-ascii?Q?CGa9XcxajbI4RvykymwtcQzhzcHeuI/ksFxExNuELRSn/CM7GRJ3ReLZcYor?= =?us-ascii?Q?9T2gwSqbEitzoVdC2a6YHShvcrqmFAbr5mnOdRySXO59OIW1zSMqX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BFHw6pzqTZIV6wcV/j4GGMIQscFrsw+E4y3wGfGX6gH1REiB?= =?us-ascii?Q?8A5DfnZX3OwV3xL3MvW8QNM+691httvInTYYMQWePlATt2Ehpu/J2CbWnPAX?= =?us-ascii?Q?xfsAf7axesCOBNoySqtZYxjNvUy+7y+3onbe8DN3DePXEUPmHkLIaz/IidLy?= =?us-ascii?Q?9/aM/jVq4C1qIaSmefZHjvTAuVk9aCW6fogsAimb5V4KmpT8w+l//0fGI9Vx?= =?us-ascii?Q?2M8m0DpgWkKZZXl9tduBml4z45PHNX/oTAl3FqzfynM1U3yBGO1X3OgeNeqR?= =?us-ascii?Q?E8TLV82HksOleOMlF79deeaBXC/7o9d8XWTSrTvIYQfSAR4ppVl573KABhV1?= =?us-ascii?Q?oE5SCIXKuK8QRRkk50nF+VgyoPTcxNFeo0TKcHU78hh+bfCELRkJMlpLxp3m?= =?us-ascii?Q?uPvYGLJAKmt+k+gu9dfDOTNMQDkw5+NaJnr5NxMMouVPhKKneVBe1i2osKC3?= =?us-ascii?Q?JFN3lrIocd+oHOHwc4DIUnU=3D?= X-OriginatorOrg: connect.ust.hk X-MS-Exchange-CrossTenant-Network-Message-Id: b417923a-ad16-472d-2372-08d9a9104f1c X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 14:49:36.5293 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6c1d4152-39d0-44ca-88d9-b8d6ddca0708 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SY2JGmuqVqPD9KE9U2KzXKMQbFuQQf0yYFZmbhtrj7lWSvkdb4bDGnVF9nK0VXpgzvc6jFfHKlPwNUJFuoR9QA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYBP286MB0256 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 The lock sh->txpp.mutex was not correctly released on one path of cleanup function return, potentially causing the deadlock. Fixes: d133f4cdb7 ("net/mlx5: create clock queue for packet pacing") Cc: stable@dpdk.org Signed-off-by: Chengfeng Ye --- drivers/net/mlx5/mlx5_txpp.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c index 4f6da9f2d1..75c08c55e2 100644 --- a/drivers/net/mlx5/mlx5_txpp.c +++ b/drivers/net/mlx5/mlx5_txpp.c @@ -896,7 +896,6 @@ mlx5_txpp_start(struct rte_eth_dev *dev) struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_dev_ctx_shared *sh = priv->sh; int err = 0; - int ret; if (!priv->config.tx_pp) { /* Packet pacing is not requested for the device. */ @@ -909,14 +908,14 @@ mlx5_txpp_start(struct rte_eth_dev *dev) return 0; } if (priv->config.tx_pp > 0) { - ret = rte_mbuf_dynflag_lookup - (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL); - if (ret < 0) + err = rte_mbuf_dynflag_lookup + (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL); + /* No flag registered means no service needed. */ + if (err < 0) return 0; + err = 0; } - ret = pthread_mutex_lock(&sh->txpp.mutex); - MLX5_ASSERT(!ret); - RTE_SET_USED(ret); + claim_zero(pthread_mutex_lock(&sh->txpp.mutex)); if (sh->txpp.refcnt) { priv->txpp_en = 1; ++sh->txpp.refcnt; @@ -930,9 +929,7 @@ mlx5_txpp_start(struct rte_eth_dev *dev) rte_errno = -err; } } - ret = pthread_mutex_unlock(&sh->txpp.mutex); - MLX5_ASSERT(!ret); - RTE_SET_USED(ret); + claim_zero(pthread_mutex_unlock(&sh->txpp.mutex)); return err; } @@ -950,24 +947,21 @@ mlx5_txpp_stop(struct rte_eth_dev *dev) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_dev_ctx_shared *sh = priv->sh; - int ret; if (!priv->txpp_en) { /* Packet pacing is already disabled for the device. */ return; } priv->txpp_en = 0; - ret = pthread_mutex_lock(&sh->txpp.mutex); - MLX5_ASSERT(!ret); - RTE_SET_USED(ret); + claim_zero(pthread_mutex_lock(&sh->txpp.mutex)); MLX5_ASSERT(sh->txpp.refcnt); - if (!sh->txpp.refcnt || --sh->txpp.refcnt) + if (!sh->txpp.refcnt || --sh->txpp.refcnt) { + claim_zero(pthread_mutex_unlock(&sh->txpp.mutex)); return; + } /* No references any more, do actual destroy. */ mlx5_txpp_destroy(sh); - ret = pthread_mutex_unlock(&sh->txpp.mutex); - MLX5_ASSERT(!ret); - RTE_SET_USED(ret); + claim_zero(pthread_mutex_unlock(&sh->txpp.mutex)); } /* -- 2.17.1