From patchwork Mon Apr 4 08:58:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 12800022 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1430AC433EF for ; Mon, 4 Apr 2022 08:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245535AbiDDJAU (ORCPT ); Mon, 4 Apr 2022 05:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235945AbiDDJAU (ORCPT ); Mon, 4 Apr 2022 05:00:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFCB83BA5D for ; Mon, 4 Apr 2022 01:58:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 660F8B808C5 for ; Mon, 4 Apr 2022 08:58:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE424C34110; Mon, 4 Apr 2022 08:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649062702; bh=ZUKpPdjqMZfECHyOAIq0TofKSenKowcBPazC6skOMY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ugTjo1vH02Q6BK3Mkss9WOUsABy4c0VV9H9y/g/pQ5pokowuYAHyqLYefKYEnRXaW RXJFXanN1NJ+eJmAlGgKs2BTr4O6O66fMTmNLmIU0CIGhYoGMcJDjptKF7cM5r7Sn9 A+gWGftMJTkK3E4ih46+0f8JSgk3qWZSPPMTnBDP1tOMsD/0ADuxnYIteFm9op5wRo sstt370l82WM8A8YfYuwnuUeLeCbRpQqmMgr9yMZ0/gqyW1Mw4pOJxjvP2G7i0tYPC 6gnV4FHqqgNf3AyQhxgkG9Ij/K8T1AKoCkFhSY/YP2Stqhqu1hjd2CgXHJl+OTm0M3 npPG3TvtTXl0w== From: Leon Romanovsky To: Jason Gunthorpe Cc: Aharon Landau , linux-rdma@vger.kernel.org, Maor Gottlieb , Mark Zhang , Shay Drory Subject: [PATCH rdma-rc v1 1/3] RDMA/mlx5: Don't remove cache MRs when a delay is needed Date: Mon, 4 Apr 2022 11:58:03 +0300 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Aharon Landau Don't remove MRs from the cache if need to delay the removal. Fixes: b9358bdbc713 ("RDMA/mlx5: Fix locking in MR cache work queue") Signed-off-by: Aharon Landau Reviewed-by: Shay Drory Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/mr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 956f8e875daa..45b0680377ec 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -574,8 +574,10 @@ static void __cache_work_func(struct mlx5_cache_ent *ent) spin_lock_irq(&ent->lock); if (ent->disabled) goto out; - if (need_delay) + if (need_delay) { queue_delayed_work(cache->wq, &ent->dwork, 300 * HZ); + goto out; + } remove_cache_mr_locked(ent); queue_adjust_cache_locked(ent); } From patchwork Mon Apr 4 08:58:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 12800020 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CADCC433FE for ; Mon, 4 Apr 2022 08:58:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245350AbiDDJAL (ORCPT ); Mon, 4 Apr 2022 05:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235945AbiDDJAK (ORCPT ); Mon, 4 Apr 2022 05:00:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C233BA4D for ; Mon, 4 Apr 2022 01:58:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 580A1611E0 for ; Mon, 4 Apr 2022 08:58:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4415CC340EE; Mon, 4 Apr 2022 08:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649062694; bh=NfT6Qn535A1/iKirs09BQOj287UZljjGAEfRtW3B3Mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gk1BmQwNYoX55ylEYs/ma5UpVbJ1nrC1keCyY7L+xIMAx5Km6ALCUcBymgtkJem55 6AP//FrooXGVv5ySb7AQZL5Im1ACOf59c2u4qYqGrr9OKpj+qO2TMeaiH958DCYLxv 7GcEJPPlRfTXZq24ujCuUSJHz7PnBo0vtHBx1lhHdGTE8qAddTRTpCNfUIqa1lPivv L68jA35uhc8D3I1VtB7WyuhX7R1qF2cOArWwglLyGnTWMmTUwtWh6fqDSU4qrFUZrK EzwtqLTNY+Gco6X4uP5MD9TtXbTigtFI6IENRbNorGZea1p6OVNAL1aov1+14gJJgP nO+wm6chhFULA== From: Leon Romanovsky To: Jason Gunthorpe Cc: Aharon Landau , linux-rdma@vger.kernel.org, Maor Gottlieb , Mark Zhang , Shay Drory Subject: [PATCH rdma-rc v1 2/3] RDMA/mlx5: Add a missing update of cache->last_add Date: Mon, 4 Apr 2022 11:58:04 +0300 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Aharon Landau Update cache->last_add when returning an MR to the cache so that the cache work won't remove it. Fixes: b9358bdbc713 ("RDMA/mlx5: Fix locking in MR cache work queue") Signed-off-by: Aharon Landau Reviewed-by: Shay Drory Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 45b0680377ec..32ef67e9a6a7 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -627,6 +627,7 @@ static void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) { struct mlx5_cache_ent *ent = mr->cache_ent; + WRITE_ONCE(dev->cache.last_add, jiffies); spin_lock_irq(&ent->lock); list_add_tail(&mr->list, &ent->head); ent->available_mrs++; From patchwork Mon Apr 4 08:58:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 12800021 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A740C433EF for ; Mon, 4 Apr 2022 08:58:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343612AbiDDJAQ (ORCPT ); Mon, 4 Apr 2022 05:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245362AbiDDJAO (ORCPT ); Mon, 4 Apr 2022 05:00:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B4C3BA5D for ; Mon, 4 Apr 2022 01:58:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F2CD6140C for ; Mon, 4 Apr 2022 08:58:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FD57C34110; Mon, 4 Apr 2022 08:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649062698; bh=Y6gLhe52+PxEjLMtlOIxTBfTt73M1h9sp3Hw+NQYlJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FgE42Dv2Ovzql7993l3jVCccqJUJmb8yCkLUHqGvzdSTAbbF7WbuEAr0u7fe8QlRy bou1Htl8lU+kotvbYuEOpny9En+yN58wm3n8KzblYWb/8K6tvgyPnwQmcwVoblZweR WrePEJ1sowf/B9Cv6FKp2pCFqPISVEY7Y4ZfnPfh1g8xHGtkT3U1a8wfC99va3XSQ6 RZ0v5vnSs3oo/0QyXUZRh33E4JwFFdIwTOrx4KTMOKTqrSylWuoXEUhVtnde6oBFRc pZYyTs+JiQz5WQDlJ+JN+YAMpvcE4TKcjryZaM6ftvN7dSzhm6KfSEgcmOgV+ZKGIg LyYIO1P3AVjrw== From: Leon Romanovsky To: Jason Gunthorpe Cc: Mark Zhang , Aharon Landau , linux-rdma@vger.kernel.org, Maor Gottlieb , Shay Drory Subject: [PATCH rdma-rc v1 3/3] IB/cm: Cancel mad on the DREQ event when the state is MRA_REP_RCVD Date: Mon, 4 Apr 2022 11:58:05 +0300 Message-Id: <75261c00c1d82128b1d981af9ff46e994186e621.1649062436.git.leonro@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Mark Zhang On the passive side when the disconnectReq event comes, if the current state is MRA_REP_RCVD, it needs to cancel the MAD before enter the DREQ_RCVD and TIMEWAIT state, otherwise the destroy_id may block until this mad will reach timeout. Fixes: a977049dacde ("[PATCH] IB: Add the kernel CM implementation") Signed-off-by: Mark Zhang Reviewed-by: Maor Gottlieb Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/cm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 35f0d5e7533d..1c107d6d03b9 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -2824,6 +2824,7 @@ static int cm_dreq_handler(struct cm_work *work) switch (cm_id_priv->id.state) { case IB_CM_REP_SENT: case IB_CM_DREQ_SENT: + case IB_CM_MRA_REP_RCVD: ib_cancel_mad(cm_id_priv->msg); break; case IB_CM_ESTABLISHED: @@ -2831,8 +2832,6 @@ static int cm_dreq_handler(struct cm_work *work) cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD) ib_cancel_mad(cm_id_priv->msg); break; - case IB_CM_MRA_REP_RCVD: - break; case IB_CM_TIMEWAIT: atomic_long_inc(&work->port->counters[CM_RECV_DUPLICATES] [CM_DREQ_COUNTER]);