From patchwork Fri Jul 2 06:18:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suanming Mou X-Patchwork-Id: 95164 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C03BA0A0C; Fri, 2 Jul 2021 08:20:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7EFD241385; Fri, 2 Jul 2021 08:18:56 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2061.outbound.protection.outlook.com [40.107.244.61]) by mails.dpdk.org (Postfix) with ESMTP id 5BEDC41346 for ; Fri, 2 Jul 2021 08:18:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dx0Z9aBdFbQB60cLw7jrlo11FXz+xtMolVxo7PDJUZNbfLVEgDogRxFGC6v7n+M1HdbrNU01stz9hB2cfXkPkEPHninVRZ/qGxwLVQwQd5gy6sBmwxImdB9SaNHm0KgnogFijW0wbRYRF54AnZqa4gOcKdTcZRwUFqdr67jyVbWuIiWi7wptWYP5Hf12KC5lH8lBUmkC3MVakP/zYUPdau0/4HxjsFsly/M6AzOE/cxi6gpeMvp7UIMiUjqOPh1o2wDFTXN3a/GBNGn7GjCYmM0E6w2tPHhEs4oA+iySaWORkpVySkiRqA2kWgfmlTmpxbR1u77yGgneicJ76KiWkg== 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=n0ZO3LzgDLilvO0Hjo8/zxkeJs1+OOB1uCF2gI2tPJM=; b=TzlW3JRHd8yl+gUhCiuGDX+A/kIGZpRxKxJX0600S1alpxAMkVpFuR9tiV1O1NUMqUZ6qqg8CSv3/HlAus0qdVLjTjzZfHyHOzgv+JBPlYr37mITa0IP+DyBpLZeILTqNzSSKadLMWjocujFRcoJb4CEfpF8VVYw8MnU/pEs0BHjR5EzqrYeK+/Eisu4L1YupVIZTkXKDb60QMlwJFaYssHZgZSpzP+TeUTmM3fOaY8f6KgaFV3o2hX7qmhkiS/ZdagWey0Skt0Y923BqGZn7pxG+/WTukc9VsMyylzq/6WNW7CShZWpIL9Y0eYpq4l8QPdFeRHIZOgVLJwt2V+IyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=n0ZO3LzgDLilvO0Hjo8/zxkeJs1+OOB1uCF2gI2tPJM=; b=oKXrbJZgEkw96SJxvMFGhxUQcpLBMYZ+lvNpfLez9waC3Rhs9I8kHbKGQHf3lDeCZ8bl49Je+9h0KAaTy0POyBAkroJTv+1GHEcxjaT5URhm6+uS25RWV0kbrAy5EXsBXPjw/1FgDp3JIMFSrNkfDAPWhalBNBYhdSiImZV7okMVAeZkPU8RtJPuJ3xGE0YaO2BzkTXjRkMAHD8EUV/jSyCH1vcxxkiynrDkfF8QPY2cA0X7DCFIeA/ojybDFZWZg5zD6fkQFtFT6wuPEJc4h/45Xr9ZG1E95fk+9xd2NIFZT/1EIQX669agr8aTwiW/TkMoC3u3tFlEkAg4HyQdrQ== Received: from MW4PR03CA0118.namprd03.prod.outlook.com (2603:10b6:303:b7::33) by BN8PR12MB3297.namprd12.prod.outlook.com (2603:10b6:408:9f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Fri, 2 Jul 2021 06:18:50 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b7:cafe::70) by MW4PR03CA0118.outlook.office365.com (2603:10b6:303:b7::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 06:18:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 06:18:49 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jul 2021 06:18:47 +0000 From: Suanming Mou To: , CC: , , Date: Fri, 2 Jul 2021 09:18:04 +0300 Message-ID: <20210702061816.10454-11-suanmingm@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210702061816.10454-1-suanmingm@nvidia.com> References: <20210527093403.1153127-1-suanmingm@nvidia.com> <20210702061816.10454-1-suanmingm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b457b40e-d64a-47a7-7bbc-08d93d2141b6 X-MS-TrafficTypeDiagnostic: BN8PR12MB3297: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:249; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5vCf0rGW/Aq8mqn1EOw3dFxEthSR7ISJj/wwg2Y1s0yUt83Bp7IvtUT6MF1vVbFv+Pkdtbz5YANZ5x9Ce0xzmgwJK0c31YskaYInZ/ZgblcWtOqwUKHTMHlzmQVf4PWxMBMdpv7ik/K4wxZrkxlrnKMDOvMpVxgF5SparGXHeLRFI54/RSX/emWTnO3NRN1zZF1LK+7oGOdO6POUzh99gnCnlMC85isGN12MLHlAUXP6V1YeR1vP8vhhsm+cD6EgJRouYRSgCRS5Pp/KrhgMuE0W5R4I/OszpHQ949x1hT1uLbT9MIeQqzsbyzNRufXQ+mqvU9MZj4YWhVPG9/6Jn6KPWTT2XoTQkJpOoCW9Xw0eAkUkVvChgtJJIS4ltkaMxumDsO2MZ6UMHnT3GrJEzDY1CBdURc4uLhU7tFBMXVP0J0JDeocP24Elx1JfHWp+cxF1PN8JbVcxiHpiDwX6iQSsgmxcIYUysl19AFCgja2zzqA2hNSUYl7/plFYUAW4y+nIrHRKP0aDf8SjZLmXlcVeUptKg+9vKztDJsODFuTSBhVOCPRvfh4qFiNq+SGkHXfQfidCXO5wEur5YESWBWKff/D3lWPLXAPNi7gDi9vRhIn35wUAsrq/PwL4nPfvmT2VpF6ApiN6V1KO5dF+bVp14sPEQhkZZznBS10qux6ezTuU2ckM+SW+1oz7BeInyE712JGGybu41mB2IDB+IA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(346002)(136003)(396003)(376002)(46966006)(36840700001)(336012)(47076005)(6286002)(426003)(82310400003)(4326008)(2906002)(70586007)(36906005)(8676002)(70206006)(36756003)(110136005)(1076003)(2616005)(316002)(82740400003)(186003)(7636003)(6666004)(478600001)(8936002)(54906003)(83380400001)(356005)(26005)(16526019)(5660300002)(7696005)(6636002)(55016002)(36860700001)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 06:18:49.4139 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b457b40e-d64a-47a7-7bbc-08d93d2141b6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3297 Subject: [dpdk-dev] [PATCH v3 10/22] net/mlx5: relax the list utility atomic operations 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 Sender: "dev" From: Matan Azrad The atomic operation in the list utility no need a barriers because the critical part are managed by RW lock. Relax them. Signed-off-by: Matan Azrad Acked-by: Suanming Mou --- drivers/net/mlx5/mlx5_utils.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5_utils.c b/drivers/net/mlx5/mlx5_utils.c index 7cdf44dcf7..29248c80ed 100644 --- a/drivers/net/mlx5/mlx5_utils.c +++ b/drivers/net/mlx5/mlx5_utils.c @@ -50,13 +50,13 @@ __list_lookup(struct mlx5_list *list, int lcore_index, void *ctx, bool reuse) if (list->cb_match(list, entry, ctx) == 0) { if (reuse) { ret = __atomic_add_fetch(&entry->ref_cnt, 1, - __ATOMIC_ACQUIRE) - 1; + __ATOMIC_RELAXED) - 1; DRV_LOG(DEBUG, "mlx5 list %s entry %p ref: %u.", list->name, (void *)entry, entry->ref_cnt); } else if (lcore_index < RTE_MAX_LCORE) { ret = __atomic_load_n(&entry->ref_cnt, - __ATOMIC_ACQUIRE); + __ATOMIC_RELAXED); } if (likely(ret != 0 || lcore_index == RTE_MAX_LCORE)) return entry; @@ -181,7 +181,7 @@ mlx5_list_register(struct mlx5_list *list, void *ctx) list->gen_cnt++; rte_rwlock_write_unlock(&list->lock); LIST_INSERT_HEAD(&list->cache[lcore_index].h, local_entry, next); - __atomic_add_fetch(&list->count, 1, __ATOMIC_ACQUIRE); + __atomic_add_fetch(&list->count, 1, __ATOMIC_RELAXED); DRV_LOG(DEBUG, "mlx5 list %s entry %p new: %u.", list->name, (void *)entry, entry->ref_cnt); return local_entry; @@ -194,7 +194,7 @@ mlx5_list_unregister(struct mlx5_list *list, struct mlx5_list_entry *gentry = entry->gentry; int lcore_idx; - if (__atomic_sub_fetch(&entry->ref_cnt, 1, __ATOMIC_ACQUIRE) != 0) + if (__atomic_sub_fetch(&entry->ref_cnt, 1, __ATOMIC_RELAXED) != 0) return 1; lcore_idx = rte_lcore_index(rte_lcore_id()); MLX5_ASSERT(lcore_idx < RTE_MAX_LCORE); @@ -207,14 +207,14 @@ mlx5_list_unregister(struct mlx5_list *list, } else { return 0; } - if (__atomic_sub_fetch(&gentry->ref_cnt, 1, __ATOMIC_ACQUIRE) != 0) + if (__atomic_sub_fetch(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) != 0) return 1; rte_rwlock_write_lock(&list->lock); if (likely(gentry->ref_cnt == 0)) { LIST_REMOVE(gentry, next); rte_rwlock_write_unlock(&list->lock); list->cb_remove(list, gentry); - __atomic_sub_fetch(&list->count, 1, __ATOMIC_ACQUIRE); + __atomic_sub_fetch(&list->count, 1, __ATOMIC_RELAXED); DRV_LOG(DEBUG, "mlx5 list %s entry %p removed.", list->name, (void *)gentry); return 0;