From patchwork Fri Jun 11 12:10:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12315597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7EFDC48BE5 for ; Fri, 11 Jun 2021 12:10:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 997C761004 for ; Fri, 11 Jun 2021 12:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbhFKMMj (ORCPT ); Fri, 11 Jun 2021 08:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231251AbhFKMMg (ORCPT ); Fri, 11 Jun 2021 08:12:36 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C35BC0617AF for ; Fri, 11 Jun 2021 05:10:38 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id f5so31833731eds.0 for ; Fri, 11 Jun 2021 05:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sDchXq1U7bxiKpYRoM1OPck9C6cBNIdyhJ33mP+Q4lE=; b=VJnMZFPdr6RSLzUigf6FB+dK+CTa+INedTkyhilssu2qmb/a+m+o3XfvYV24OVuaEF 6EIgtQj6fcI9CS1mRY28WzgKseR8CDLkDVPaVepV3uNpSoSsn4fr6yYa9SKe12Na5Im0 1iJjg1QFYjeK47PzzdxCMOz+rEkUXB52hQDAge0mF5CJN/hBa9qaCmJVnKoSk0U+mxs6 926q0/2gbgNkhh4LaGl43OtzY8fsai1QRogNhR8siifcinlcxfNlvtLk7Xl4hqZHAJZ4 uc8Zz727In/rDlsnL0uV9lUMaN6YMumT1DXfrtlTccft3skPNhzQeUb/hjBA3tIsoAoM ys7A== 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:mime-version:content-transfer-encoding; bh=sDchXq1U7bxiKpYRoM1OPck9C6cBNIdyhJ33mP+Q4lE=; b=rhmB16BO6lUIuc5fFPzsHtQ1vAWl3je6hAoEQrSPlWqoIjWmmFvWr/TeJrfQdDklNZ XUnfjxV8yuWkr/sEN1VygiYtX+i0DUsOJ7ZspvpHDpxz5CkuqRJ5fo4npvgrsGRcW0Fy 1IK8GwLDL+ACZYA1yrL8227hSSjMolhfMB/ClLnoojK0yBF3IvGx6vCI/VgHMyxg0ysN UQ7hTZvv+fijCdn9GDlURmf49nFHVgF7hLcKCwayznV3tOmexw9xuhykxomTybc7IFI8 9fNfshXqMrODIXce1IRBW4gZ3eyXHVQjWQfnV9b989Wwr7axr8vZSWOw/L8W7U08D6Es 9/lg== X-Gm-Message-State: AOAM530Bbgs5bWdRXvwGrJKVATivltzv3q3icYaAwB4iWJxHTokx6Ng7 FS+3MDmdAYSBvsXOVGWf4ijOLAN/AguKNQ== X-Google-Smtp-Source: ABdhPJzCRUMaTlR1T41xFfvWZIvYoLBr0j4PnsJcSXi4rrip6gXNhA1OrPpDhsgxGU0JjAQG3mnUdA== X-Received: by 2002:aa7:d558:: with SMTP id u24mr3344780edr.331.1623413436833; Fri, 11 Jun 2021 05:10:36 -0700 (PDT) Received: from jwang-Latitude-5491.fritz.box ([2001:16b8:4954:2e00:fd6f:fc71:2689:4a7a]) by smtp.gmail.com with ESMTPSA id n11sm2084116ejg.43.2021.06.11.05.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 05:10:36 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Jack Wang , Md Haris Iqbal , Gioh Kim Subject: [PATCHv2 for-next 1/5] RDMA/rtrs-srv: Set minimal max_send_wr and max_recv_wr Date: Fri, 11 Jun 2021 14:10:30 +0200 Message-Id: <20210611121034.48837-2-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611121034.48837-1-jinpu.wang@ionos.com> References: <20210611121034.48837-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang Currently rtrs when create_qp use a coarse numbers (bigger in general), which leads to hardware create more resources which only waste memory with no benefits. For max_send_wr, we don't really need alway max_qp_wr size when creating qp, reduce it to cq_size. For max_recv_wr, cq_size is enough. With the patch when sess_queue_depth=128, per session (2 paths) memory consumption reduced from 188 MB to 65MB When always_invalidate is enabled, we need send more wr, so treat it special. Fixes: 9cb837480424e ("RDMA/rtrs: server: main functionality") Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal Signed-off-by: Gioh Kim Reviewed-by: Leon Romanovsky --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 38 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 5639b29b8b02..04ec3080e9b5 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1634,7 +1634,7 @@ static int create_con(struct rtrs_srv_sess *sess, struct rtrs_sess *s = &sess->s; struct rtrs_srv_con *con; - u32 cq_size, wr_queue_size; + u32 cq_size, max_send_wr, max_recv_wr, wr_limit; int err, cq_vector; con = kzalloc(sizeof(*con), GFP_KERNEL); @@ -1655,30 +1655,42 @@ static int create_con(struct rtrs_srv_sess *sess, * All receive and all send (each requiring invalidate) * + 2 for drain and heartbeat */ - wr_queue_size = SERVICE_CON_QUEUE_DEPTH * 3 + 2; - cq_size = wr_queue_size; + max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; + max_recv_wr = SERVICE_CON_QUEUE_DEPTH + 2; + cq_size = max_send_wr + max_recv_wr; } else { - /* - * If we have all receive requests posted and - * all write requests posted and each read request - * requires an invalidate request + drain - * and qp gets into error state. - */ - cq_size = srv->queue_depth * 3 + 1; /* * In theory we might have queue_depth * 32 * outstanding requests if an unsafe global key is used * and we have queue_depth read requests each consisting * of 32 different addresses. div 3 for mlx5. */ - wr_queue_size = sess->s.dev->ib_dev->attrs.max_qp_wr / 3; + wr_limit = sess->s.dev->ib_dev->attrs.max_qp_wr / 3; + /* when always_invlaidate enalbed, we need linv+rinv+mr+imm */ + if (always_invalidate) + max_send_wr = + min_t(int, wr_limit, + srv->queue_depth * (1 + 4) + 1); + else + max_send_wr = + min_t(int, wr_limit, + srv->queue_depth * (1 + 2) + 1); + + max_recv_wr = srv->queue_depth + 1; + /* + * If we have all receive requests posted and + * all write requests posted and each read request + * requires an invalidate request + drain + * and qp gets into error state. + */ + cq_size = max_send_wr + max_recv_wr; } - atomic_set(&con->sq_wr_avail, wr_queue_size); + atomic_set(&con->sq_wr_avail, max_send_wr); cq_vector = rtrs_srv_get_next_cq_vector(sess); /* TODO: SOFTIRQ can be faster, but be careful with softirq context */ err = rtrs_cq_qp_create(&sess->s, &con->c, 1, cq_vector, cq_size, - wr_queue_size, wr_queue_size, + max_send_wr, max_recv_wr, IB_POLL_WORKQUEUE); if (err) { rtrs_err(s, "rtrs_cq_qp_create(), err: %d\n", err); From patchwork Fri Jun 11 12:10:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12315605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F625C48BD1 for ; Fri, 11 Jun 2021 12:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7964660FE6 for ; Fri, 11 Jun 2021 12:11:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230468AbhFKMNh (ORCPT ); Fri, 11 Jun 2021 08:13:37 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:33581 "EHLO mail-ed1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbhFKMNg (ORCPT ); Fri, 11 Jun 2021 08:13:36 -0400 Received: by mail-ed1-f45.google.com with SMTP id f5so31833782eds.0 for ; Fri, 11 Jun 2021 05:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uL+EN0zWidH6/P9/6QcLFHezjtyZ+PTsZ+hns4lgn3w=; b=KeMuNPrRgYKVQKs80mICPP7/D37u2GiJEUAMufD9943ekORkZq1lOQ/VH57mUGzz9w S34lP1bM34TiKktJm72uBqEmzcg9mHkRDiQwn/Bu7NO3EhVBSbOKlPZgBou4vhE+EU8f 39t5ifUaMu+2jkZSZXD9Y9N6PBLWKmoT6NVZktVtl94EDEDoJCZmMFI5//mIdGvc89te Iq7zp4GgWwtkjuhu5tcalkRTGX4IZL1bGNBgHPdAozwG+ICsory73Wo99NNnq9w/fXiV rduqumsd3sSAB62QbSOJrMkj/gP8S7OwHW+a3d30QO/H0kmVOtB+917eWw37D3K1nWxE 26mA== 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:mime-version:content-transfer-encoding; bh=uL+EN0zWidH6/P9/6QcLFHezjtyZ+PTsZ+hns4lgn3w=; b=Z38CSalh0OWf5GXg9FSIkwI2s1o+x3hhsxb0cqdSYE7mZobKqcmzFZPmb1NALLmOjm a9PIWI9xyQ6gRP68xYZE3TXN5Q4dsjh//l0BWOf7a0Kp/pjvQnBPCn3J9vX/S7aMr9Lm +g2gt6BAdt9s6ep0kslz2KxIkGwwltjk9Vdq7E4G5R8odwU3x7E72Exk/kUhDVLNEere 09KlI62bwYzVI9J5evLdv2E75ckTHgG0r7+vQ7GQNV647U9lwSHoWn9bpguV6RDoFtLh zpl/kunCWHMmiJyoB8zV/qgV9OvuG4MaLC71czqxjzGoOO1Sj4aVupHRMD9v+L1LoL08 LHuQ== X-Gm-Message-State: AOAM530kNODGQgQVVKk4RT61FRG5zD8TMM2Nn4jBt0d5s93Nvng/r3tb ng/D9E02zl80bjVlvhnex8NneFw4wim+Uw== X-Google-Smtp-Source: ABdhPJzbf/Hf5qCJBEknMMOIKIgCwCKhSfHytRhDjLyMeD7qwKSxjqt7SxzT247HsrLT6N/t27Q6KA== X-Received: by 2002:a05:6402:520b:: with SMTP id s11mr3313970edd.111.1623413437628; Fri, 11 Jun 2021 05:10:37 -0700 (PDT) Received: from jwang-Latitude-5491.fritz.box ([2001:16b8:4954:2e00:fd6f:fc71:2689:4a7a]) by smtp.gmail.com with ESMTPSA id n11sm2084116ejg.43.2021.06.11.05.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 05:10:37 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Jack Wang , Guoqing Jiang Subject: [PATCHv2 for-next 2/5] RDMA/rtrs-clt: Use minimal max_send_sge when create qp Date: Fri, 11 Jun 2021 14:10:31 +0200 Message-Id: <20210611121034.48837-3-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611121034.48837-1-jinpu.wang@ionos.com> References: <20210611121034.48837-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang We use device limit max_send_sge, which is suboptimal for memory usage. We don't need that much for User Con, 1 is enough. And for IO con, sess->max_segments + 1 is enough Signed-off-by: Jack Wang Signed-off-by: Guoqing Jiang Reviewed-by: Leon Romanovsky --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 14 ++++++++------ drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index f1fd7ae9ac53..cd53edddfe1f 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1417,7 +1417,6 @@ static void query_fast_reg_mode(struct rtrs_clt_sess *sess) sess->max_pages_per_mr = min3(sess->max_pages_per_mr, (u32)max_pages_per_mr, ib_dev->attrs.max_fast_reg_page_list_len); - sess->max_send_sge = ib_dev->attrs.max_send_sge; } static bool rtrs_clt_change_state_get_old(struct rtrs_clt_sess *sess, @@ -1573,7 +1572,7 @@ static void destroy_con(struct rtrs_clt_con *con) static int create_con_cq_qp(struct rtrs_clt_con *con) { struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); - u32 max_send_wr, max_recv_wr, cq_size; + u32 max_send_wr, max_recv_wr, cq_size, max_send_sge; int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; @@ -1587,6 +1586,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) */ max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; + max_send_sge = 1; /* We must be the first here */ if (WARN_ON(sess->s.dev)) return -EINVAL; @@ -1625,25 +1625,27 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) max_recv_wr = min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr, sess->queue_depth * 3 + 1); + max_send_sge = sess->clt->max_segments + 1; } + cq_size = max_send_wr + max_recv_wr; /* alloc iu to recv new rkey reply when server reports flags set */ if (sess->flags & RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) { - con->rsp_ius = rtrs_iu_alloc(max_recv_wr, sizeof(*rsp), + con->rsp_ius = rtrs_iu_alloc(cq_size, sizeof(*rsp), GFP_KERNEL, sess->s.dev->ib_dev, DMA_FROM_DEVICE, rtrs_clt_rdma_done); if (!con->rsp_ius) return -ENOMEM; - con->queue_size = max_recv_wr; + con->queue_size = cq_size; } cq_size = max_send_wr + max_recv_wr; cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors; if (con->c.cid >= sess->s.irq_con_num) - err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, + err = rtrs_cq_qp_create(&sess->s, &con->c, max_send_sge, cq_vector, cq_size, max_send_wr, max_recv_wr, IB_POLL_DIRECT); else - err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, + err = rtrs_cq_qp_create(&sess->s, &con->c, max_send_sge, cq_vector, cq_size, max_send_wr, max_recv_wr, IB_POLL_SOFTIRQ); /* diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index 919c9f96f25b..822a820540d4 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -141,7 +141,6 @@ struct rtrs_clt_sess { u32 chunk_size; size_t queue_depth; u32 max_pages_per_mr; - int max_send_sge; u32 flags; struct kobject kobj; u8 for_new_clt; From patchwork Fri Jun 11 12:10:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12315599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DEAEC48BE0 for ; Fri, 11 Jun 2021 12:10:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A202613E9 for ; Fri, 11 Jun 2021 12:10:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231616AbhFKMMn (ORCPT ); Fri, 11 Jun 2021 08:12:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231572AbhFKMMi (ORCPT ); Fri, 11 Jun 2021 08:12:38 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07995C061574 for ; Fri, 11 Jun 2021 05:10:40 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id w21so36774064edv.3 for ; Fri, 11 Jun 2021 05:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6DXu4OmBn/6f2pOViHrkn9BqE93+JtM5LZS2wZByLK8=; b=OLryWsAoA83HE6aJvvwlkX5vWOFN9FnvUSBz07ybGPvAbNf5k1/mblcKaeyBsUcJhc hZ4GqBL/PLgh1j7/CSvK/t42pFqtJIEvm4FjQ4scVkhrf7CkYpOn4E5JmZNVO6whcnBo z9VvxqnUH53mx8MrD/plofftRfGWN7AqBA2cP1ues1QtssUCxZE5Xt9tm4wBTtKJU1wG P3h/owTVWr7bC5q+rlv+WO5Lw0hcgXpwm8KjNQVl68ijexfWvmOFzJ9+gQ0/+JMiPKYg YP5+cb09Pp9B1L8pfBAubiQSnv2AJXOuY7YTB/yp/S0FFMAUdLOM6P5j96usV0e7QCEg b1SQ== 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:mime-version:content-transfer-encoding; bh=6DXu4OmBn/6f2pOViHrkn9BqE93+JtM5LZS2wZByLK8=; b=Yo4FtIyP94qdH9kpEcf5PZ7aWnEEjIkvuOfp0fTUDzjoVPMHp6FB6EqSgpB5YERQvd aAwdfAjqJv2eJY6B+JUHL4bfBGTnq/MX0hw9AxxYF+JsPXvaINk4aPgz/Q0Pw6N5rqF6 aJpEw1OuN4CB7QqD92fJOi479iotbssF0/ebe+406VZlkvljRm2jTAf++kfOU/7PstCZ 6mezI36txVtrh2sX3MavrVt7Q9yahlOeA1zey3h/sDJ4TtVWe9TzWk6vGCdolbTW8V9m SffhE+m68vrtDyuaeIlUJmwNBbjrstgKgVXW7BIr6/jvJBPcNAO57C/LiRFovTrrEfB+ qIfQ== X-Gm-Message-State: AOAM5302816VnOy6Wp9RAt0DNjvzHCMA3UJSx1raYDnW3aYyI2I5svvp cwr/xTGDds6CpYfbW+A6K9xvNkRCB1318Q== X-Google-Smtp-Source: ABdhPJzlJOH2u23gPdGYBOxQ8+tyQ51bdIuGPE16+EVZbw0G6PogqA/iWwcyWIE8pRJ5xFpn3ra9eQ== X-Received: by 2002:a05:6402:1592:: with SMTP id c18mr3393915edv.2.1623413438386; Fri, 11 Jun 2021 05:10:38 -0700 (PDT) Received: from jwang-Latitude-5491.fritz.box ([2001:16b8:4954:2e00:fd6f:fc71:2689:4a7a]) by smtp.gmail.com with ESMTPSA id n11sm2084116ejg.43.2021.06.11.05.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 05:10:38 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Jack Wang , Gioh Kim Subject: [PATCHv2 for-next 3/5] RDMA/rtrs: RDMA_RXE requires more number of WR Date: Fri, 11 Jun 2021 14:10:32 +0200 Message-Id: <20210611121034.48837-4-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611121034.48837-1-jinpu.wang@ionos.com> References: <20210611121034.48837-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Md Haris Iqbal When using rdma_rxe, post_one_recv() returns NOMEM error due to the full recv queue. This patch increase the number of WR for receive queue to support all devices. Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang Signed-off-by: Gioh Kim Reviewed-by: Leon Romanovsky --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index cd53edddfe1f..acf0fde410c3 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1579,10 +1579,11 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) lockdep_assert_held(&con->con_mutex); if (con->c.cid == 0) { /* - * One completion for each receive and two for each send - * (send request + registration) + * Two (request + registration) completion for send + * Two for recv if always_invalidate is set on server + * or one for recv. * + 2 for drain and heartbeat - * in case qp gets into error state + * in case qp gets into error state. */ max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 04ec3080e9b5..bb73f7762a87 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1656,7 +1656,7 @@ static int create_con(struct rtrs_srv_sess *sess, * + 2 for drain and heartbeat */ max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; - max_recv_wr = SERVICE_CON_QUEUE_DEPTH + 2; + max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; cq_size = max_send_wr + max_recv_wr; } else { /* From patchwork Fri Jun 11 12:10:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12315601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0742BC48BE6 for ; Fri, 11 Jun 2021 12:10:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D354661004 for ; Fri, 11 Jun 2021 12:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbhFKMMo (ORCPT ); Fri, 11 Jun 2021 08:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbhFKMMj (ORCPT ); Fri, 11 Jun 2021 08:12:39 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0009FC0613A2 for ; Fri, 11 Jun 2021 05:10:40 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id og14so4228900ejc.5 for ; Fri, 11 Jun 2021 05:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tXPQ5gfawfQniyV8yQcAPx6eoaR9jr7ethn/8o5VfWI=; b=XU09Ja2J6qzF7FybxT/mbN8+4xM4/P+MpCXoZVIeI2rUCe1or54plDbRVy3me9fvLf IiKbNLMUKss/9alsGZPcONT7AiHzmdecwSg/Cq21DanNNGix78RR24d19n51/M0iXWuk InVkUpmEWCxUh+E5VQSOuM7XvLFEaQgStVRwXEPbhKDj8rtMuEb19RCcRkP+D7cRKfVJ nFqJhTIzPCl/3mKzt/iaTHDXdE3VJcbaWUoQgmZrFV9pfEjTGCTlNnRNi8jHT7fdgpKK giM1jzejmQbGKYF53LPrW4Ysjp0VifmExW0rQdf3DPOmHW+xPMTbfB+nAC5fYi4Ctc6C Fulg== 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:mime-version:content-transfer-encoding; bh=tXPQ5gfawfQniyV8yQcAPx6eoaR9jr7ethn/8o5VfWI=; b=QgcmKT1fixsn8tc+PMQMRWVv5v+m4GBuHJ7eeIfrndC1QLWYkz07wnq+98KwkFuV3Q PnPJcCcZ+DgHtczcW4tzUw94orFikqgaAul9d5eNUSgGfZKBNQQV/TinUHAXG3meu6AK /m8V6O+2D48+9gsMHjP2HFm7kw3AUMz4F6THTs8YZrSCBZI+GcvCyQ4UanPD2alzSNTJ F4iwVQ60gVObOUQHWEFJ2/voGgZZS/QSZ1g/+X37tWqL7xpU25nb31Ycnl8y4NmH/7ul w96LUMl/49z+Yn0SMrF7DEuglnCm8ttYV6M3Laa09G9M5FrJygM8/fwzyJZccPWA/dr2 Oxag== X-Gm-Message-State: AOAM530pdGmKmTHLcWkEvo7OSjkH8G+3ujIB4PcvKWH806UhCj+AuEsd zAUsiQZVOPQfvNxSCOwsTojGk+ktOyHcIA== X-Google-Smtp-Source: ABdhPJyXKTWGE/pcvzmetwQz3ww3jIs+n53uDbo5MYSFYlMD3s2CS2s2C5J0hTl9hRT/hkEk1qgNKw== X-Received: by 2002:a17:906:b352:: with SMTP id cd18mr3265573ejb.222.1623413439233; Fri, 11 Jun 2021 05:10:39 -0700 (PDT) Received: from jwang-Latitude-5491.fritz.box ([2001:16b8:4954:2e00:fd6f:fc71:2689:4a7a]) by smtp.gmail.com with ESMTPSA id n11sm2084116ejg.43.2021.06.11.05.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 05:10:38 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Md Haris Iqbal , Jack Wang Subject: [PATCHv2 for-next 4/5] RDMA/rtrs: Rename some variables to avoid confusion Date: Fri, 11 Jun 2021 14:10:33 +0200 Message-Id: <20210611121034.48837-5-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611121034.48837-1-jinpu.wang@ionos.com> References: <20210611121034.48837-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Those variables are passed to create_cq, create_qp, rtrs_iu_alloc and rtrs_iu_free, so these *_size means the num of unit. And cq_size also means number of cq element. Also move the setting of cq_num to common path. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Jack Wang Reviewed-by: Leon Romanovsky --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 18 +++++++++--------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 2 +- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 10 +++++----- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 7 +++---- drivers/infiniband/ulp/rtrs/rtrs.c | 24 ++++++++++++------------ 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index acf0fde410c3..67ff5bf9bfa8 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1572,7 +1572,7 @@ static void destroy_con(struct rtrs_clt_con *con) static int create_con_cq_qp(struct rtrs_clt_con *con) { struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); - u32 max_send_wr, max_recv_wr, cq_size, max_send_sge; + u32 max_send_wr, max_recv_wr, cq_num, max_send_sge; int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; @@ -1628,26 +1628,26 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) sess->queue_depth * 3 + 1); max_send_sge = sess->clt->max_segments + 1; } - cq_size = max_send_wr + max_recv_wr; + cq_num = max_send_wr + max_recv_wr; /* alloc iu to recv new rkey reply when server reports flags set */ if (sess->flags & RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) { - con->rsp_ius = rtrs_iu_alloc(cq_size, sizeof(*rsp), + con->rsp_ius = rtrs_iu_alloc(cq_num, sizeof(*rsp), GFP_KERNEL, sess->s.dev->ib_dev, DMA_FROM_DEVICE, rtrs_clt_rdma_done); if (!con->rsp_ius) return -ENOMEM; - con->queue_size = cq_size; + con->queue_num = cq_num; } - cq_size = max_send_wr + max_recv_wr; + cq_num = max_send_wr + max_recv_wr; cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors; if (con->c.cid >= sess->s.irq_con_num) err = rtrs_cq_qp_create(&sess->s, &con->c, max_send_sge, - cq_vector, cq_size, max_send_wr, + cq_vector, cq_num, max_send_wr, max_recv_wr, IB_POLL_DIRECT); else err = rtrs_cq_qp_create(&sess->s, &con->c, max_send_sge, - cq_vector, cq_size, max_send_wr, + cq_vector, cq_num, max_send_wr, max_recv_wr, IB_POLL_SOFTIRQ); /* * In case of error we do not bother to clean previous allocations, @@ -1667,9 +1667,9 @@ static void destroy_con_cq_qp(struct rtrs_clt_con *con) lockdep_assert_held(&con->con_mutex); rtrs_cq_qp_destroy(&con->c); if (con->rsp_ius) { - rtrs_iu_free(con->rsp_ius, sess->s.dev->ib_dev, con->queue_size); + rtrs_iu_free(con->rsp_ius, sess->s.dev->ib_dev, con->queue_num); con->rsp_ius = NULL; - con->queue_size = 0; + con->queue_num = 0; } if (sess->s.dev_ref && !--sess->s.dev_ref) { rtrs_ib_dev_put(sess->s.dev); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index 822a820540d4..eed2a20ee9be 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -71,7 +71,7 @@ struct rtrs_clt_stats { struct rtrs_clt_con { struct rtrs_con c; struct rtrs_iu *rsp_ius; - u32 queue_size; + u32 queue_num; unsigned int cpu; struct mutex con_mutex; atomic_t io_cnt; diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index bd06a79fd516..76cca2058f6f 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -95,7 +95,7 @@ struct rtrs_con { struct ib_cq *cq; struct rdma_cm_id *cm_id; unsigned int cid; - u16 cq_size; + int nr_cqe; }; struct rtrs_sess { @@ -294,10 +294,10 @@ struct rtrs_msg_rdma_hdr { /* rtrs.c */ -struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t t, +struct rtrs_iu *rtrs_iu_alloc(u32 queue_num, size_t size, gfp_t t, struct ib_device *dev, enum dma_data_direction, void (*done)(struct ib_cq *cq, struct ib_wc *wc)); -void rtrs_iu_free(struct rtrs_iu *iu, struct ib_device *dev, u32 queue_size); +void rtrs_iu_free(struct rtrs_iu *iu, struct ib_device *dev, u32 queue_num); int rtrs_iu_post_recv(struct rtrs_con *con, struct rtrs_iu *iu); int rtrs_iu_post_send(struct rtrs_con *con, struct rtrs_iu *iu, size_t size, struct ib_send_wr *head); @@ -312,8 +312,8 @@ int rtrs_post_rdma_write_imm_empty(struct rtrs_con *con, struct ib_cqe *cqe, u32 imm_data, enum ib_send_flags flags, struct ib_send_wr *head); -int rtrs_cq_qp_create(struct rtrs_sess *rtrs_sess, struct rtrs_con *con, - u32 max_send_sge, int cq_vector, int cq_size, +int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, + u32 max_send_sge, int cq_vector, int nr_cqe, u32 max_send_wr, u32 max_recv_wr, enum ib_poll_context poll_ctx); void rtrs_cq_qp_destroy(struct rtrs_con *con); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index bb73f7762a87..c10dfc296259 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1634,7 +1634,7 @@ static int create_con(struct rtrs_srv_sess *sess, struct rtrs_sess *s = &sess->s; struct rtrs_srv_con *con; - u32 cq_size, max_send_wr, max_recv_wr, wr_limit; + u32 cq_num, max_send_wr, max_recv_wr, wr_limit; int err, cq_vector; con = kzalloc(sizeof(*con), GFP_KERNEL); @@ -1657,7 +1657,6 @@ static int create_con(struct rtrs_srv_sess *sess, */ max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; - cq_size = max_send_wr + max_recv_wr; } else { /* * In theory we might have queue_depth * 32 @@ -1683,13 +1682,13 @@ static int create_con(struct rtrs_srv_sess *sess, * requires an invalidate request + drain * and qp gets into error state. */ - cq_size = max_send_wr + max_recv_wr; } + cq_num = max_send_wr + max_recv_wr; atomic_set(&con->sq_wr_avail, max_send_wr); cq_vector = rtrs_srv_get_next_cq_vector(sess); /* TODO: SOFTIRQ can be faster, but be careful with softirq context */ - err = rtrs_cq_qp_create(&sess->s, &con->c, 1, cq_vector, cq_size, + err = rtrs_cq_qp_create(&sess->s, &con->c, 1, cq_vector, cq_num, max_send_wr, max_recv_wr, IB_POLL_WORKQUEUE); if (err) { diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 4e602e40f623..08e1f7d82c95 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -18,7 +18,7 @@ MODULE_DESCRIPTION("RDMA Transport Core"); MODULE_LICENSE("GPL"); -struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t gfp_mask, +struct rtrs_iu *rtrs_iu_alloc(u32 iu_num, size_t size, gfp_t gfp_mask, struct ib_device *dma_dev, enum dma_data_direction dir, void (*done)(struct ib_cq *cq, struct ib_wc *wc)) @@ -26,10 +26,10 @@ struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t gfp_mask, struct rtrs_iu *ius, *iu; int i; - ius = kcalloc(queue_size, sizeof(*ius), gfp_mask); + ius = kcalloc(iu_num, sizeof(*ius), gfp_mask); if (!ius) return NULL; - for (i = 0; i < queue_size; i++) { + for (i = 0; i < iu_num; i++) { iu = &ius[i]; iu->direction = dir; iu->buf = kzalloc(size, gfp_mask); @@ -50,7 +50,7 @@ struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t gfp_mask, } EXPORT_SYMBOL_GPL(rtrs_iu_alloc); -void rtrs_iu_free(struct rtrs_iu *ius, struct ib_device *ibdev, u32 queue_size) +void rtrs_iu_free(struct rtrs_iu *ius, struct ib_device *ibdev, u32 queue_num) { struct rtrs_iu *iu; int i; @@ -58,7 +58,7 @@ void rtrs_iu_free(struct rtrs_iu *ius, struct ib_device *ibdev, u32 queue_size) if (!ius) return; - for (i = 0; i < queue_size; i++) { + for (i = 0; i < queue_num; i++) { iu = &ius[i]; ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, iu->direction); kfree(iu->buf); @@ -212,20 +212,20 @@ static void qp_event_handler(struct ib_event *ev, void *ctx) } } -static int create_cq(struct rtrs_con *con, int cq_vector, u16 cq_size, +static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe, enum ib_poll_context poll_ctx) { struct rdma_cm_id *cm_id = con->cm_id; struct ib_cq *cq; - cq = ib_cq_pool_get(cm_id->device, cq_size, cq_vector, poll_ctx); + cq = ib_cq_pool_get(cm_id->device, nr_cqe, cq_vector, poll_ctx); if (IS_ERR(cq)) { rtrs_err(con->sess, "Creating completion queue failed, errno: %ld\n", PTR_ERR(cq)); return PTR_ERR(cq); } con->cq = cq; - con->cq_size = cq_size; + con->nr_cqe = nr_cqe; return 0; } @@ -260,20 +260,20 @@ static int create_qp(struct rtrs_con *con, struct ib_pd *pd, } int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, - u32 max_send_sge, int cq_vector, int cq_size, + u32 max_send_sge, int cq_vector, int nr_cqe, u32 max_send_wr, u32 max_recv_wr, enum ib_poll_context poll_ctx) { int err; - err = create_cq(con, cq_vector, cq_size, poll_ctx); + err = create_cq(con, cq_vector, nr_cqe, poll_ctx); if (err) return err; err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr, max_send_sge); if (err) { - ib_cq_pool_put(con->cq, con->cq_size); + ib_cq_pool_put(con->cq, con->nr_cqe); con->cq = NULL; return err; } @@ -290,7 +290,7 @@ void rtrs_cq_qp_destroy(struct rtrs_con *con) con->qp = NULL; } if (con->cq) { - ib_cq_pool_put(con->cq, con->cq_size); + ib_cq_pool_put(con->cq, con->nr_cqe); con->cq = NULL; } } From patchwork Fri Jun 11 12:10:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12315603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D241C48BD1 for ; Fri, 11 Jun 2021 12:10:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23ABD61004 for ; Fri, 11 Jun 2021 12:10:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbhFKMMp (ORCPT ); Fri, 11 Jun 2021 08:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbhFKMMk (ORCPT ); Fri, 11 Jun 2021 08:12:40 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4DA0C061574 for ; Fri, 11 Jun 2021 05:10:41 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id ci15so4195211ejc.10 for ; Fri, 11 Jun 2021 05:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LmfvrlqKSugQrOL3uDjwzUCdVnUY/gjEb2dxgjwjjNg=; b=fAnUYJgum7cGYE2JHYhFz3/HVmaY307Sh6Qi57160xT/FvgFp/OBcRiQ+v//ZHOYyS 3WWzqb+nWvdGMf+dEqKseRlOF1HagmerwyOTrSoHstKNIBzKkPT5iHdE3tn7QnLKmGgZ PqqYFq4giI+pBB40h87S8NszZ72K6+/gQ2K5J6kKQXny2P2GzHLhhP+u86LnlqiC34vi Kcs3f4saaP+LronH/XChEsOw+6k3RRoyek+QU/zHRx8ow+gK8wb6/Er8fCPHBlTvdvuo TKoTSMYDqflSueq8gksuaYfJCl6qXkaal8HlMKJiqoZFOgFW5J3aoKE2jP368gA03jqk ZTmg== 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:mime-version:content-transfer-encoding; bh=LmfvrlqKSugQrOL3uDjwzUCdVnUY/gjEb2dxgjwjjNg=; b=IeNuXdxmmqWVMNzrBKvTI6XvF+ULoL9RgPX0WTLvuimYOXx479xXubey7YtLhOyrdK 9FWO3GLMMe+xFf8xHGmmgn3hA/FGNnShKDhCkuF+YvYEv1D0dr0cM2LfHmQzbUlFYkFt RIK+ySacHUoTv1Af1t0Fmc9UzkwkOi8yX3st4uXzRHk/7MQwtoIPxM1t0bGvuK5b3n3g sXjZn2Kk6haKKp/qfDbJJZtgRXjV3IBAQ3RUrMHT8xBeUr2RSVDWUrXb94IR5Yp3gihe MwhVbZ0zgnQCqM/cKar6iJcJzj7lBetDptlYXWizQ6Fzlapia5FRp7x9lLOCH+TnfLa9 LXuQ== X-Gm-Message-State: AOAM533Xq01BO5Oawkv1eyGOq9b8zG1/7++Fa8qG9omiqI/ccg93VE0G HDWiCrut/HgxonowqNdPkfFAxbMdM9vrYg== X-Google-Smtp-Source: ABdhPJwZPMZrUj5Ej651reVSiTGgNJLB6e3l+Nfs/+yvQMpia9i+JHZ3VX75XHk6lR1+6QxfdUQ92w== X-Received: by 2002:a17:907:628a:: with SMTP id nd10mr3425060ejc.326.1623413440217; Fri, 11 Jun 2021 05:10:40 -0700 (PDT) Received: from jwang-Latitude-5491.fritz.box ([2001:16b8:4954:2e00:fd6f:fc71:2689:4a7a]) by smtp.gmail.com with ESMTPSA id n11sm2084116ejg.43.2021.06.11.05.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 05:10:39 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Leon Romanovsky , Gioh Kim Subject: [PATCHv2 for-next 5/5] RDMA/rtrs: Check device max_qp_wr limit when create QP Date: Fri, 11 Jun 2021 14:10:34 +0200 Message-Id: <20210611121034.48837-6-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611121034.48837-1-jinpu.wang@ionos.com> References: <20210611121034.48837-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Currently we only check device max_qp_wr limit for IO connection, but not for service connection. We should check for both. So save the max_qp_wr device limit in wr_limit, and use it for both IO connections and service connections. While at it, also remove an outdated comments. Suggested-by: Leon Romanovsky Signed-off-by: Jack Wang Signed-off-by: Gioh Kim Reviewed-by: Leon Romanovsky --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 29 +++++++++++++------------- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 13 ++++-------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 67ff5bf9bfa8..125e0bead262 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1572,21 +1572,12 @@ static void destroy_con(struct rtrs_clt_con *con) static int create_con_cq_qp(struct rtrs_clt_con *con) { struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); - u32 max_send_wr, max_recv_wr, cq_num, max_send_sge; + u32 max_send_wr, max_recv_wr, cq_num, max_send_sge, wr_limit; int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; lockdep_assert_held(&con->con_mutex); if (con->c.cid == 0) { - /* - * Two (request + registration) completion for send - * Two for recv if always_invalidate is set on server - * or one for recv. - * + 2 for drain and heartbeat - * in case qp gets into error state. - */ - max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; - max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; max_send_sge = 1; /* We must be the first here */ if (WARN_ON(sess->s.dev)) @@ -1606,6 +1597,17 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) } sess->s.dev_ref = 1; query_fast_reg_mode(sess); + wr_limit = sess->s.dev->ib_dev->attrs.max_qp_wr; + /* + * Two (request + registration) completion for send + * Two for recv if always_invalidate is set on server + * or one for recv. + * + 2 for drain and heartbeat + * in case qp gets into error state. + */ + max_send_wr = + min_t(int, wr_limit, SERVICE_CON_QUEUE_DEPTH * 2 + 2); + max_recv_wr = max_send_wr; } else { /* * Here we assume that session members are correctly set. @@ -1617,14 +1619,13 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) if (WARN_ON(!sess->queue_depth)) return -EINVAL; + wr_limit = sess->s.dev->ib_dev->attrs.max_qp_wr; /* Shared between connections */ sess->s.dev_ref++; - max_send_wr = - min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr, + max_send_wr = min_t(int, wr_limit, /* QD * (REQ + RSP + FR REGS or INVS) + drain */ sess->queue_depth * 3 + 1); - max_recv_wr = - min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr, + max_recv_wr = min_t(int, wr_limit, sess->queue_depth * 3 + 1); max_send_sge = sess->clt->max_segments + 1; } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index c10dfc296259..1a30fd833792 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1649,22 +1649,17 @@ static int create_con(struct rtrs_srv_sess *sess, con->c.sess = &sess->s; con->c.cid = cid; atomic_set(&con->wr_cnt, 1); + wr_limit = sess->s.dev->ib_dev->attrs.max_qp_wr; if (con->c.cid == 0) { /* * All receive and all send (each requiring invalidate) * + 2 for drain and heartbeat */ - max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; - max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; + max_send_wr = min_t(int, wr_limit, + SERVICE_CON_QUEUE_DEPTH * 2 + 2); + max_recv_wr = max_send_wr; } else { - /* - * In theory we might have queue_depth * 32 - * outstanding requests if an unsafe global key is used - * and we have queue_depth read requests each consisting - * of 32 different addresses. div 3 for mlx5. - */ - wr_limit = sess->s.dev->ib_dev->attrs.max_qp_wr / 3; /* when always_invlaidate enalbed, we need linv+rinv+mr+imm */ if (always_invalidate) max_send_wr =