From patchwork Fri Apr 27 04:36:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Zambre X-Patchwork-Id: 10367419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE8E56038F for ; Fri, 27 Apr 2018 04:36:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF67528797 for ; Fri, 27 Apr 2018 04:36:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C43B9292E4; Fri, 27 Apr 2018 04:36:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F4B228797 for ; Fri, 27 Apr 2018 04:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751291AbeD0Egb (ORCPT ); Fri, 27 Apr 2018 00:36:31 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:39992 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbeD0Ega (ORCPT ); Fri, 27 Apr 2018 00:36:30 -0400 Received: by mail-io0-f195.google.com with SMTP id t123-v6so1056930iof.7 for ; Thu, 26 Apr 2018 21:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uci-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tB+kszVg9aipUm5BZSDShdgAao/4R0PIsUvO50m9Kzs=; b=iLjMDMLpeFxvMMBNVpU+18ghutjTKuPd0FJbr/AJizpLptTPQAuy6tsBDcZKCXZl4t 03RetTsJCDTbIYwGvTlo/jCFzdb3D+XVRqmBC7kQIACbYR+JZT5VveSlAfl+/KFTIRLu c7GO2qkF2Xyn8qbxGEteNt8s6aXT1G+e1h+U+KrnMBIrhiG5rsCDRriBAkMtwoTtKrUE 2giEH3MzhgYuizOebpYu4Y5N/BGpsCgNCa1qdjt6GNdnwpi4zC6NLcXTXRwp9thu//K+ sGMN1Fn5NUZIsESfQ4iuLrplvQWRkDBQUNLWEdHrX0sZ10XqZg4qxQfst/hzkTbqKNmm wFzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tB+kszVg9aipUm5BZSDShdgAao/4R0PIsUvO50m9Kzs=; b=YbIqoCpCOZgyXk9mk7Tgt7ACd2O9fyXJFI+Ni5HSFluUTSwcIpRI1Wx+EWng/ubHL4 C4bJrf2VIt2wV6IawXD+NC7CQd/CgIen60WnLVA50XtsOpNKILqz1jF4i0RbxTHJDES/ GVpLrssZid6kGuOcyje9ttyfE+a89FPMiozYYGN+SNwp3eRx4NJsmYFinPHnoQ59m2ec QFJf7dsFspqqy0gTdXiu54RKnX91vhXGORb/3b3uSYASwI8JdqRpaYjfp4F6KiUQ7MzY 574K8WitZ31VeIf83PvhtA0mKIKLF1TnFxTs3FN06fOq7r6xY8VrVKthC86CZ1Pcw9Un onVA== X-Gm-Message-State: ALQs6tAjXAvD68nrLLOuZuee6s0mqPRYrPMioTAnsiHBWWsmV1k+m/j6 e5FlVVKl3WausBzxC/V/PxlKYg== X-Google-Smtp-Source: AB8JxZoUTgYGIn7XE1DMQTUYGkRyp+5Acu7tmFopyeGc/q12CnzTgYCSIwpwGD0ULe9WVG7RcYBxSQ== X-Received: by 2002:a6b:844c:: with SMTP id g73-v6mr706296iod.251.1524803789850; Thu, 26 Apr 2018 21:36:29 -0700 (PDT) Received: from jlselogin2.ftm.alcf.anl.gov (jlselogin2.pub.jlse.anl.gov. [140.221.96.131]) by smtp.gmail.com with ESMTPSA id 32-v6sm247321ios.26.2018.04.26.21.36.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 21:36:29 -0700 (PDT) From: Rohit Zambre To: dledford@redhat.com, jgg@mellanox.com Cc: linux-rdma@vger.kernel.org, balaji@anl.gov, amowli@uci.edu, Rohit Zambre Subject: [PATCH rdma-core 2/2] mlx5: Disable locking on a QP if it is assigned to a thread domain Date: Fri, 27 Apr 2018 04:36:15 +0000 Message-Id: <1524803775-24118-3-git-send-email-rzambre@uci.edu> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1524803775-24118-1-git-send-email-rzambre@uci.edu> References: <1524803775-24118-1-git-send-email-rzambre@uci.edu> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP By creating a QP within a thread domain the application is guaranteeing that the QP will not be accessed concurrently from multiple user threads. Hence, a lock is not needed for QP that is assigned to a thread domain. This patch disables locking on the QP if a thread domain is passed during QP-creation. Signed-off-by: Rohit Zambre --- providers/mlx5/verbs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 9fd765e..f7132e4 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -1607,6 +1607,7 @@ static struct ibv_qp *create_qp(struct ibv_context *context, struct mlx5_create_qp_ex_resp resp_ex; struct mlx5_qp *qp; int ret; + int thread_safe; struct mlx5_context *ctx = to_mctx(context); struct ibv_qp *ibqp; int32_t usr_idx = 0; @@ -1751,8 +1752,14 @@ static struct ibv_qp *create_qp(struct ibv_context *context, mlx5_init_qp_indices(qp); - if (mlx5_spinlock_init(&qp->sq.lock, !mlx5_single_threaded) || - mlx5_spinlock_init(&qp->rq.lock, !mlx5_single_threaded)) + mparent_domain = to_mparent_domain(attr->pd); + if (mparent_domain && mparent_domain->mtd) + thread_safe = 1; + else + thread_safe = mlx5_single_threaded; + + if (mlx5_spinlock_init(&qp->sq.lock, !thread_safe) || + mlx5_spinlock_init(&qp->rq.lock, !thread_safe)) goto err_free_qp_buf; qp->db = mlx5_alloc_dbrec(ctx); @@ -1789,7 +1796,6 @@ static struct ibv_qp *create_qp(struct ibv_context *context, cmd.uidx = usr_idx; } - mparent_domain = to_mparent_domain(attr->pd); if (mparent_domain && mparent_domain->mtd) bf = mparent_domain->mtd->bf;