From patchwork Wed Dec 9 16:45:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961899 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.7 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,URIBL_BLOCKED, 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 684C1C4361B for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24D4423C41 for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729645AbgLIQq2 (ORCPT ); Wed, 9 Dec 2020 11:46:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729635AbgLIQq2 (ORCPT ); Wed, 9 Dec 2020 11:46:28 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8330C0613D6 for ; Wed, 9 Dec 2020 08:45:47 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id b2so2297107edm.3 for ; Wed, 09 Dec 2020 08:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qpPnc2m5XVQy3plvidZQlq66m0N1fBZky9SIH8zFy/w=; b=QVQZBQCYWkccBchSdNl7bwgKhAKNKGqYaekt8HSjKb695Uy1AOLNcGHpWgUjnkMtid rkzaAE2xje2a3FKLJdIFyMbId1/Ksumssfy6S/jQapaPNL6w86XqQrV67HuJo3vXO2+e v64eUMP2/g40xYp06lf0IBZrlxH9yRVL/Tj/KbYjyNxIeQsWQ6zpNdL6P5TsRojPSAwp AUUoE9yHF0j2XSnbWfWbd1zXOyq+pcnctckAHtjIiYi3DuP0/5RDwOHLkHIP2dy6QQ+W TD+/x/VnDBodzyn7q61xpr1ckdT88koGE3q/XaGqJDl8b0P/Q3a4jDq+pvFB7Q//w7XD P2cQ== 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=qpPnc2m5XVQy3plvidZQlq66m0N1fBZky9SIH8zFy/w=; b=MybAvI1Wlcqjoh2sO9fkB3h8aQwohkiTh4B2qHJGJtkwZtgUp1h1a/muVyiRT8VtY1 90czqQiZBscb3TFfa3/C79rSDMy4Ix69iezSwS7Dh5zDJ2Mwh0yH0aelZk0yXCWeCeec 8ucn4ZwEK1FvHyva9U8dkYXL0ULS69DRhOOFVJ5jxgAD3a/GzAzWEdKplP6/21WFE4ku 41oiXSBiDRlGxR0RYSMh2VQMl3shbhVZdRyClQfo352f5fmnGzXNkKr8CHe3bZHBNKWp KjOmd5CFlU8WRGg1qrCF5bIp4+m/pKOsdE7RbW2TMY4fdp7S+P47U5/jVV3TWxnYa2YY QKbA== X-Gm-Message-State: AOAM532C55skc/irfhtnO5WbHZ9SgbCWdDoiS+/HxNY7LiMMP8Vx1ypN c4s8J8nL5Mq/j7unbHuwEkS8OOUB4coQ+w== X-Google-Smtp-Source: ABdhPJx4McoCI8WB5bWkF4lzbkFeniHShfPLIy/+6wroEm9J1r+GerL+u3Q5SnyVOVf600TXaul0oA== X-Received: by 2002:a50:e84d:: with SMTP id k13mr2773137edn.154.1607532346235; Wed, 09 Dec 2020 08:45:46 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:45 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Md Haris Iqbal Subject: [PATCH for-next 01/18] RDMA/rtrs: Extend ibtrs_cq_qp_create Date: Wed, 9 Dec 2020 17:45:25 +0100 Message-Id: <20201209164542.61387-2-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org rtrs does not have same limit for both max_send_wr and max_recv_wr, To allow client and server set different values, export in a separate parameter for rtrs_cq_qp_create. Also fix the type accordingly, u32 should be used instead of u16. Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++-- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 5 +++-- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 +++-- drivers/infiniband/ulp/rtrs/rtrs.c | 14 ++++++++------ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 67f86c405a26..719254fc83a1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1511,7 +1511,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); - u16 wr_queue_size; + u32 wr_queue_size; int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; @@ -1573,7 +1573,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors; err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, cq_vector, wr_queue_size, wr_queue_size, - IB_POLL_SOFTIRQ); + wr_queue_size, IB_POLL_SOFTIRQ); /* * In case of error we do not bother to clean previous allocations, * since destroy_con_cq_qp() must be called. diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index 3f2918671dbe..d5621e6fad1b 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -303,8 +303,9 @@ int rtrs_post_rdma_write_imm_empty(struct rtrs_con *con, struct ib_cqe *cqe, 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, u16 cq_size, - u16 wr_queue_size, enum ib_poll_context poll_ctx); + u32 max_send_sge, int cq_vector, int cq_size, + u32 max_send_wr, u32 max_recv_wr, + enum ib_poll_context poll_ctx); void rtrs_cq_qp_destroy(struct rtrs_con *con); void rtrs_init_hb(struct rtrs_sess *sess, struct ib_cqe *cqe, diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index c42fd470c4eb..ed4628f032bb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1586,7 +1586,7 @@ static int create_con(struct rtrs_srv_sess *sess, struct rtrs_sess *s = &sess->s; struct rtrs_srv_con *con; - u16 cq_size, wr_queue_size; + u32 cq_size, wr_queue_size; int err, cq_vector; con = kzalloc(sizeof(*con), GFP_KERNEL); @@ -1630,7 +1630,8 @@ static int create_con(struct rtrs_srv_sess *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, IB_POLL_WORKQUEUE); + wr_queue_size, wr_queue_size, + IB_POLL_WORKQUEUE); if (err) { rtrs_err(s, "rtrs_cq_qp_create(), err: %d\n", err); goto free_con; diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 2e3a849e0a77..df52427f1710 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -231,14 +231,14 @@ static int create_cq(struct rtrs_con *con, int cq_vector, u16 cq_size, } static int create_qp(struct rtrs_con *con, struct ib_pd *pd, - u16 wr_queue_size, u32 max_sge) + u32 max_send_wr, u32 max_recv_wr, u32 max_sge) { struct ib_qp_init_attr init_attr = {NULL}; struct rdma_cm_id *cm_id = con->cm_id; int ret; - init_attr.cap.max_send_wr = wr_queue_size; - init_attr.cap.max_recv_wr = wr_queue_size; + init_attr.cap.max_send_wr = max_send_wr; + init_attr.cap.max_recv_wr = max_recv_wr; init_attr.cap.max_recv_sge = 1; init_attr.event_handler = qp_event_handler; init_attr.qp_context = con; @@ -260,8 +260,9 @@ 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, u16 cq_size, - u16 wr_queue_size, enum ib_poll_context poll_ctx) + u32 max_send_sge, int cq_vector, int cq_size, + u32 max_send_wr, u32 max_recv_wr, + enum ib_poll_context poll_ctx) { int err; @@ -269,7 +270,8 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, if (err) return err; - err = create_qp(con, sess->dev->ib_pd, wr_queue_size, max_send_sge); + err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr, + max_send_sge); if (err) { ib_free_cq(con->cq); con->cq = NULL; From patchwork Wed Dec 9 16:45:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961903 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.7 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,URIBL_BLOCKED, 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 8677AC19425 for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 410D723C43 for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729753AbgLIQq3 (ORCPT ); Wed, 9 Dec 2020 11:46:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729711AbgLIQq3 (ORCPT ); Wed, 9 Dec 2020 11:46:29 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3A03C061793 for ; Wed, 9 Dec 2020 08:45:48 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id b2so2297170edm.3 for ; Wed, 09 Dec 2020 08:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7PQati/YK+0ufphUXyId/+gTePb410nGvKEpPs46D9c=; b=bnEV37hvP2Tmgk/uYrl0579uNbn8Xi6mV17v1w59jgU6Te3okmB4GRgDs3bUdRT10H HAmFrXsithrv5FyADXZpc1S4OSApGgaEwcW1vxoqfpLSjH5JvyOpg/lkUyH9VyKN7dNy 9lkkxGlKAQqtdcv4r2QeGkwCy5MML7qCWDpOZzWRuOdBk7XEKFsDX9dM0PDpgMBaMOte C3r99nqmGklySsDDTAePqRaJhmNEtDz+Wt2oymABiTLdjDZJY34pUW68qs6JBD2DBEbE OISlYys6doelxtw81K6hTpL6tNILL/LySYMUKtuLYM85pq4kdZ1aZCVWucNJS7ADpHHt TLkA== 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=7PQati/YK+0ufphUXyId/+gTePb410nGvKEpPs46D9c=; b=A11M3kYNLZNGoVrbu3ewhS6IqNN9CA8f1X1PK5JodkG5mm1H1DSd/m6IMhVH7Buxkc dhA/VPSPrYdBHSSPot8u/lPzzBml+mcjj2e4eBOiBzvzfhX+/dPYgm37BbPB5lL9J4NA aM0zD6GEAJuC8yKP924Rj+bKLW4ailvpC2qlAPGruhYgdfQYPCTXsCVTTQVlqgbTVLGb DDW+JNULAksFat6BrDKkN26yp+qybUUkEM+nlCsAo8DglzpXTBSMM1s0uQzPMs5Kcd1X R8J9I6pPg4xdonDgoFtZx/PJs93R9Wg2YWRujOZjq9z5nq8BKVjhjpX3jERRL4HPFD+K tCMw== X-Gm-Message-State: AOAM531O542Is5Hlw+QND7XqNzRbi425/2puETRhSRms6XLgMdLUSvkG Jjs7XJTJFUXWyvdSbEtnybkZFnIsXSMBqQ== X-Google-Smtp-Source: ABdhPJyyTGodkpww/1ahqMgeDBzXuFzlCKIWDSiYZwaccSGP19lRgYgG72/vamEBLMApRb4AHnREeA== X-Received: by 2002:a05:6402:2041:: with SMTP id bc1mr2782616edb.369.1607532347367; Wed, 09 Dec 2020 08:45:47 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:46 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCH for-next 02/18] RMDA/rtrs-srv: Occasionally flush ongoing session closing Date: Wed, 9 Dec 2020 17:45:26 +0100 Message-Id: <20201209164542.61387-3-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org If there are many establishments/teardowns, we need to make sure we do not consume too much system memory. Thus let on going session closing to finish before accepting new connection. Inspired by commit 777dc82395de ("nvmet-rdma: occasionally flush ongoing controller teardown") Signed-off-by: Jack Wang Reviewed-by: Guoqing Jiang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index ed4628f032bb..0a2202c28b54 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1791,6 +1791,10 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, err = -ENOMEM; goto reject_w_err; } + if (!cid) { + /* Let inflight session teardown complete */ + flush_workqueue(rtrs_wq); + } mutex_lock(&srv->paths_mutex); sess = __find_sess(srv, &msg->sess_uuid); if (sess) { From patchwork Wed Dec 9 16:45:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961905 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.7 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,URIBL_BLOCKED, 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 9F1D1C1B0D9 for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CA6D22BE9 for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730287AbgLIQqa (ORCPT ); Wed, 9 Dec 2020 11:46:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729635AbgLIQqa (ORCPT ); Wed, 9 Dec 2020 11:46:30 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01EB5C061794 for ; Wed, 9 Dec 2020 08:45:50 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id f23so3080299ejk.2 for ; Wed, 09 Dec 2020 08:45:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i+WulD6e33SdYGyVi0ara7vlGG7jOds3Zvo+vLhCU0c=; b=Kqw2U4ne8YDvsq4+ie0RihtatdFU9j0Odz6iOgr/JKQbNKhZ73sQw9eI9PKKVmvFpm RD/E8m1vIBx/N/QhVSxj6yfgg5f6/QF+jcmdMq0u7shd37SKx9yWiVFYwYu4WHynEt0r dHQbhCAzcVrN0fN5vKlYvac+2BIFtcgpz/ER6x5UASNAbzj3LOqGK+zg3Fwra/BZcdtt DJ8eyQ8TnJFVvR6NL64TJCbJWPwnzM+mzH/YvMuGcTITy3UaloRL1JJH7ch//W9iBCzG cxeCsiZHaCT5gdwkGme2Zbnmde8m+WKZKBnONpnlyWHeoUv045I/iFDi2Pz48+VxxATt O9YQ== 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=i+WulD6e33SdYGyVi0ara7vlGG7jOds3Zvo+vLhCU0c=; b=r/KG/aNVq4mwvMN32+zFBQ7big2MohRg7xm2ehicJuMeVKSWGL9OzRCKdcqJSHfKSN Q53M7ln6L59LGJRt3qGFO3jfUuPKFH49GG9+aiEGrRMh/FZvqprmZzq/bC6NDgNvCyx+ OPsvYfZi9+62ep2gvY65OKF0GqAPzTYGBamljdnPQddnuQ65pRygpTuvEU4TQNFNRwKn T470jQG18eL/nXxMV2jOnP77wquVaFW1BvPPP8zwJVK9ciAoCWglF7D5FYZjeUJdlNDm 93G42fw40Nr3JbKRNiKvPAuQLjSx86kfWxlR/HCdd0M+W89+nbHXMHqYb30Rjfdvra5F jvzw== X-Gm-Message-State: AOAM530DyVGP0p9BLJo50AHDKL01Y0NqFPxUo6CrWrQN7be5o8CrmYbX pKIlOu0wr47iwpLBzraTQJZPgn95GoYpJA== X-Google-Smtp-Source: ABdhPJwOI6aeUFDtIAvq18tGidUm6jF3ELAaGKlRUlvKHncp+31kKPiiBdkwks3QfQAkPBrNXZW1cQ== X-Received: by 2002:a17:906:d10f:: with SMTP id b15mr2721003ejz.268.1607532348458; Wed, 09 Dec 2020 08:45:48 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:47 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Lutz Pogrell Subject: [PATCH for-next 03/18] RDMA/rtrs-srv: Release lock before call into close_sess Date: Wed, 9 Dec 2020 17:45:27 +0100 Message-Id: <20201209164542.61387-4-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org In this error case, we don't need hold mutex to call close_sess. Signed-off-by: Jack Wang Tested-by: Lutz Pogrell --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 0a2202c28b54..ef58fe021580 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1867,8 +1867,8 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, return rtrs_rdma_do_reject(cm_id, -ECONNRESET); close_and_return_err: - close_sess(sess); mutex_unlock(&srv->paths_mutex); + close_sess(sess); return err; } From patchwork Wed Dec 9 16:45:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961901 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.7 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,URIBL_BLOCKED, 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 C12ACC4167B for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FD1223C41 for ; Wed, 9 Dec 2020 16:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730386AbgLIQqc (ORCPT ); Wed, 9 Dec 2020 11:46:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729635AbgLIQqb (ORCPT ); Wed, 9 Dec 2020 11:46:31 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4103DC06179C for ; Wed, 9 Dec 2020 08:45:51 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id jx16so3049095ejb.10 for ; Wed, 09 Dec 2020 08:45:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JknM2yxNHMOxu0rXy2XeTPqfIzGYyAoGhyRH8bfhhfU=; b=Et3rKt+v8wo4CAM2IKXW2yYEaI7WcN0ADv7kqeFNFgPSgFEr4uQoH0xaGqrnjhis4R TsFgs0CcdTzmcGED77HIaaJ9LnGWq+lmc7IwxGWjlfNhtuCQIQ8BrGfcGhVbBg4dxjDP FkHS+Rb9JCYoezFhbxkxNWCLE5vIxmv/0bl/YnT0w5Y1TJsfk98WhZ8oBxKlZ7YyTmJo Y75Gfqe19NVczuHpV/HBc3VlAKWH7h8Z0L0d6MCb+uP+U1Can/KdTyxUgdg3SCZzPhc+ xpMMnrrdgCc6M8cMueZODXNOUN3e9SuIcjUuaZhGJdusl7V6jRZ1JosBBzzLFY+1xXhD cvzQ== 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=JknM2yxNHMOxu0rXy2XeTPqfIzGYyAoGhyRH8bfhhfU=; b=JyDvb+6UJrjRmK5BABc+b8NztyeLUwC6KFAMVa/oduRqokuf2I/9kVo6DmmvozhK1W osJWIOVXsJGcbd77SsJ4kGPcINng0NjPt3p6hBkpllyGqcV0wAEWTbRAnjV6qnGd5Ri2 Gp8fCgQ6fuQGnDPOHGs862tLUa4JF9dvwCFcecco/YH+2cSfkfLMG3CfleSDrNc+VBE9 QrzkZTgx3JVrx5PpH+32Eg5ve9LOCofy5OG9ur9tNM4cr5WDdtC8b/23Syezp4g1CH2/ o6hl7oATX0ocsf4dAkeONHvO3yu8pDzlVffx2n9U5OIMOhDMpPid6JH9L8oamIQN0cH7 Orfw== X-Gm-Message-State: AOAM533YXszMsHJWKLAwh1ezVeFQGMsE0sCWfC5F1aB0geVpimQaIoWJ z+7HvsTEZI4TG12n+N2q1W5kyPUZbEY3vw== X-Google-Smtp-Source: ABdhPJwto7PuDjvkT0v6oBggsjglb1shWfc/zdUX0z8j8uuACraunI0ugJScRIlPzEq3EhzHGrIU+A== X-Received: by 2002:a17:906:e093:: with SMTP id gh19mr2819101ejb.510.1607532349719; Wed, 09 Dec 2020 08:45:49 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:49 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Lutz Pogrell Subject: [PATCH for-next 04/18] RDMA/rtrs-srv: Use sysfs_remove_file_self for disconnect Date: Wed, 9 Dec 2020 17:45:28 +0100 Message-Id: <20201209164542.61387-5-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Remove self first to avoid deadlock, we don't want to use close_work to remove sess sysfs. Signed-off-by: Jack Wang Tested-by: Lutz Pogrell --- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index d2edff3b8f0d..cca3a0acbabc 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -51,6 +51,8 @@ static ssize_t rtrs_srv_disconnect_store(struct kobject *kobj, sockaddr_to_str((struct sockaddr *)&sess->s.dst_addr, str, sizeof(str)); rtrs_info(s, "disconnect for path %s requested\n", str); + /* first remove sysfs itself to avoid deadlock */ + sysfs_remove_file_self(&sess->kobj, &attr->attr); close_sess(sess); return count; From patchwork Wed Dec 9 16:45:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961907 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.7 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,URIBL_BLOCKED, 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 0AE2AC433FE for ; Wed, 9 Dec 2020 16:47:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D522E22BE9 for ; Wed, 9 Dec 2020 16:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728587AbgLIQrH (ORCPT ); Wed, 9 Dec 2020 11:47:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727211AbgLIQrH (ORCPT ); Wed, 9 Dec 2020 11:47:07 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54107C0617A6 for ; Wed, 9 Dec 2020 08:45:52 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id x16so3058243ejj.7 for ; Wed, 09 Dec 2020 08:45:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0JaxSIHKTI1X89HEA600DvBOFqz5T5wMPCHd0uiQJW0=; b=is2QrUHd9hLN8dQB2NANTGusJx4uoUyo3Z7i0M6SvA2mvYkWh4BMgyF7WqwFhtL0I2 qoFn6kROfQWDKEtCiyC3SRBiDpmrFDFSpjTULCQRVUK73WZ7r5TeIjX4fyoeYnsAcNPV feEZIRKKTbVyYYg1xzPi6qEqQK3FqAmgl1/vIkpXeMr+3s1BDSGRSY2Ceij4wQj3KD2r pLxMk7Ow1G5nYx7DOZ0O+u3ksjlzv8uh9g3dxEzNuaApTcqH6shPyb9x1BsK41/1D09K hB6K1Nnzu7Oanm0Mi93lkqDph0K2wSO8Uu4q2aNo4rNxSe867/QpPFOYYPNrhUcADY34 1OJw== 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=0JaxSIHKTI1X89HEA600DvBOFqz5T5wMPCHd0uiQJW0=; b=BMRPnZf6pwPHHjt6ycbUiFsYPfKi6UIV+HyU0qAIbN8Y1mjetix53PQerluqksI2q2 1CA7JBsbKFnf2+LdykqU3DSDbZ7EpE5bzNm/LuF75Y/MtAa5z+vn66KhZRNnV5e7FvmQ x54IVEMcQsEyZzICtZ0V7tiqFupKNtALAIPn14Cm8LU1m52vGU4ikIB9QML1qf1I3z5Q od/PcGrE7pDzbpw0rQu5V9rUznYsCtH46EiUspi2RCC96L/G8SStxkrDTnZWgr5tbrqL hXznQGjz57ofRkE8zpUrvt7uYzRgCL9I8mu/lMVribNcKdsTWUfXJA5Pq5pGBxI64jtZ KiBA== X-Gm-Message-State: AOAM533PJXoGpuTqC2SqGpUFOfnVSKgy8e9IV3qID/8HuG+bf7BN0ybo DhwS7BnU7wQPWuvLBAy344sHZCJitgZ4fQ== X-Google-Smtp-Source: ABdhPJz0lAOSm/Q+hs6L0HjTRlDjmidHpoEhRaopbLJ4X9Ft74OVlocF0A3fVDhHU3uYiHCZDwvvwQ== X-Received: by 2002:a17:906:1a01:: with SMTP id i1mr2812491ejf.315.1607532350833; Wed, 09 Dec 2020 08:45:50 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:50 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Md Haris Iqbal Subject: [PATCH for-next 05/18] RDMA/rtrs-clt: Set mininum limit when create QP Date: Wed, 9 Dec 2020 17:45:29 +0100 Message-Id: <20201209164542.61387-6-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org 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. - SERVICE con, For max_send_wr/max_recv_wr, it's 2 times SERVICE_CON_QUEUE_DEPTH + 2 - IO con For max_send_wr/max_recv_wr, it's sess->queue_depth * 3 + 1 Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 719254fc83a1..b3fb5fb93815 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1511,7 +1511,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 wr_queue_size; + u32 max_send_wr, max_recv_wr, cq_size; int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; @@ -1523,7 +1523,8 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) * + 2 for drain and heartbeat * in case qp gets into error state */ - wr_queue_size = SERVICE_CON_QUEUE_DEPTH * 3 + 2; + max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; + max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; /* We must be the first here */ if (WARN_ON(sess->s.dev)) return -EINVAL; @@ -1555,25 +1556,29 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) /* Shared between connections */ sess->s.dev_ref++; - wr_queue_size = + max_send_wr = min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr, /* 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, + sess->queue_depth * 3 + 1); } /* 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(wr_queue_size, sizeof(*rsp), + con->rsp_ius = rtrs_iu_alloc(max_recv_wr, 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 = wr_queue_size; + con->queue_size = max_recv_wr; } + cq_size = max_send_wr + max_recv_wr; cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors; err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, - cq_vector, wr_queue_size, wr_queue_size, - wr_queue_size, IB_POLL_SOFTIRQ); + cq_vector, cq_size, max_send_wr, + max_recv_wr, IB_POLL_SOFTIRQ); /* * In case of error we do not bother to clean previous allocations, * since destroy_con_cq_qp() must be called. From patchwork Wed Dec 9 16:45:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961909 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.7 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,URIBL_BLOCKED, 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 36CA8C4361B for ; Wed, 9 Dec 2020 16:47:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06B8223C41 for ; Wed, 9 Dec 2020 16:47:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbgLIQrH (ORCPT ); Wed, 9 Dec 2020 11:47:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727894AbgLIQrH (ORCPT ); Wed, 9 Dec 2020 11:47:07 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C0CC0617A7 for ; Wed, 9 Dec 2020 08:45:53 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id jx16so3049307ejb.10 for ; Wed, 09 Dec 2020 08:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0Pn0i2ODFxtlo5fkTtHKkET0BlkV0Daj5off48gQ1UE=; b=M8hcGweIXwjhaE7L62nb/Eb/a3UB/DUuQcWK+0JOh2RydtuKSPxbnzpOv+atEAnYvP k7+/+S18bEQFzr2CrdWLBVR51XN62w7cY3wiQMcK81Viv6wewy51cdxNZuNxVNf+1+Ow o/6tQb1AOCMI8+gw34EX2vxHve77I7qbLmfNw1/ugZCwN9LnPVsApDIgtTMCemlGC5ev fTgZ4ol5n/0ByB9VFwV2f0uOh7wodZs+6w8ZsfATPdBICNanND/o11RKXL1/3okSEeP6 KqIleIQDhjLcEXa1fGN9601lCbfAT1au3m7weZgFlReFyJzNZSHQ7UExqtR4lVczciOT BDng== 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=0Pn0i2ODFxtlo5fkTtHKkET0BlkV0Daj5off48gQ1UE=; b=Y7tVYze8XHurgvOlg7PFoHLSAHPCeL+0aiz4KEcc5FOBnWFvRfflnAbKSvY5TwFBKL dfgAAaXumjYtT1BsbAygc20HJc4/fPLQTpB6DG2jFnhB+CtFj5Pz4uyw2aEWR0/daH4i RBuOJgNsk3bv4kd7jrF+JMOQHvpKClwKuu9B+lHlFMWvBEeNqDWQCgmWghfU//XFJR/z 5RS+ffH+WCl377dg3SaJ6kqwFG9PypaQMg/ykZJjy8hjiyqSAFmjpSE6Xv/EDtW71M+B PbOJkod67BN+WZp+q1/71yoVuS6ZWq8bwNdwY38Bign2dhrI2OFyTV6LJ/CXzqEaqqY8 O1vQ== X-Gm-Message-State: AOAM530EZ1N9eaK2coKXTam5NaQBluzTiisqyVw2fiV/Z8ifygP2ZBNO o1+goZsRFsX7uPUxVgMUjgVIe1+l0m99og== X-Google-Smtp-Source: ABdhPJwjEfHECaPJBXobzKGEC/OMQamBO9Jeo2f7ZOrD/e/V3wDPzWRXvUoZkFuyYmyHncAdpr8fBg== X-Received: by 2002:a17:906:ccc5:: with SMTP id ot5mr2781618ejb.248.1607532352060; Wed, 09 Dec 2020 08:45:52 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:51 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Gioh Kim Subject: [PATCH for-next 06/18] RDMA/rtrs-srv: Jump to dereg_mr label if allocate iu fails Date: Wed, 9 Dec 2020 17:45:30 +0100 Message-Id: <20201209164542.61387-7-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang The rtrs_iu_free is called in rtrs_iu_alloc if memory is limited, so we don't need to free the same iu again. Signed-off-by: Guoqing Jiang Reviewed-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index ef58fe021580..27ac5a03259a 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -651,7 +651,7 @@ static int map_cont_bufs(struct rtrs_srv_sess *sess) if (!srv_mr->iu) { err = -ENOMEM; rtrs_err(ss, "rtrs_iu_alloc(), err: %d\n", err); - goto free_iu; + goto dereg_mr; } } /* Eventually dma addr for each chunk can be cached */ @@ -667,7 +667,6 @@ static int map_cont_bufs(struct rtrs_srv_sess *sess) srv_mr = &sess->mrs[mri]; sgt = &srv_mr->sgt; mr = srv_mr->mr; -free_iu: rtrs_iu_free(srv_mr->iu, sess->s.dev->ib_dev, 1); dereg_mr: ib_dereg_mr(mr); From patchwork Wed Dec 9 16:45:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961911 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.7 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,URIBL_BLOCKED, 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 87A5FC4167B for ; Wed, 9 Dec 2020 16:47:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D28F22BE9 for ; Wed, 9 Dec 2020 16:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729090AbgLIQrI (ORCPT ); Wed, 9 Dec 2020 11:47:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727894AbgLIQrI (ORCPT ); Wed, 9 Dec 2020 11:47:08 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9BBDC0617B0 for ; Wed, 9 Dec 2020 08:45:54 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id f23so3080727ejk.2 for ; Wed, 09 Dec 2020 08:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7+ixKHzHTKsBZvAX0OK7xSXxQDyr1aV5shqn8qhWhFQ=; b=BolfRW4JXJ7cfdcMI/vJI9ppRqrkdobLUvEHXbVPV2VQkTfp+8uM3nsuFnAF0dUYrj iEmByrNrbCDlgn1NNCoy1+Pq8z924YKva35c7/djdJkVshGHD0c3Xhg7fdiqknSczclt f3DcUF5SJT3MKVZnfJDvabVsF4wC9JMN8Ay7nNJPvIeH6aCDCaLndAHxr4PSSBpPfJEd i7MTdwy9SxzvjURRDFqd/xCL75ebnoYd48AmhkNccTtKfNVWFv6NmUJszQwGPcxkfNV2 XmYRUgmtMtJHzi39TyZIPfHURqCEjRn22BSrhuS0k1b1jXh6cqmwYBLM9gUSxTqaxKrV 2HaA== 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=7+ixKHzHTKsBZvAX0OK7xSXxQDyr1aV5shqn8qhWhFQ=; b=cS2NZn/uvIH54nrIvj6CEGW9uLWcIhlZykvXg95NQw27hg1YMYdujl0+GhZRlYdhne AHL4jsF1Cwq90VCNi35F9HnaQLSpRwOc8badE88cFZT6R0oaqP1e/Ez27jLgkGA8UGB5 fVxwgLeuuQWnyJ4KwiK19r05i0Aqf31t8nJYt8s+ADyYTFwuX87R5gU0dEyDOsJ2j7nx dBBjRbUeUeZxBkeevNSIsyyeh6fWU0U4lHAGmIEY+sjH3GgxE3QHaB/qnvJ7ZGgge7MU V8p7VwfcUuMLLUW1R3/t7t6Y5IK+OtkInRA2gUPUPl9RxKw9rHCJ6vtyjXdMAzoTphTC no6Q== X-Gm-Message-State: AOAM531VLd4O1lUrLKsBh26kXbTEJMoIltnJM6/xMcKMrfPj9XggFXRK lyTqpJ9aY+OByKiXm9gpf+vGUCm1nWdWPA== X-Google-Smtp-Source: ABdhPJy8spD9DCA9owoi5YzZc1fB2Oci1oTuOCXwlCUjohEQjdpH3ZAKYk4+Lk1czHph8SL6DkWotw== X-Received: by 2002:a17:906:1752:: with SMTP id d18mr2834324eje.529.1607532353286; Wed, 09 Dec 2020 08:45:53 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:52 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal , Gioh Kim Subject: [PATCH for-next 07/18] RDMA/rtrs: Call kobject_put in the failure path Date: Wed, 9 Dec 2020 17:45:31 +0100 Message-Id: <20201209164542.61387-8-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Per the comment of kobject_init_and_add, we need to free the memory by call kobject_put. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Reviewed-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 2 ++ drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c index ba00f0de14ca..ad77659800cd 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c @@ -408,6 +408,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess) "%s", str); if (err) { pr_err("kobject_init_and_add: %d\n", err); + kobject_put(&sess->kobj); return err; } err = sysfs_create_group(&sess->kobj, &rtrs_clt_sess_attr_group); @@ -419,6 +420,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess) &sess->kobj, "stats"); if (err) { pr_err("kobject_init_and_add: %d\n", err); + kobject_put(&sess->stats->kobj_stats); goto remove_group; } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index cca3a0acbabc..0a3886629cae 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -236,6 +236,7 @@ static int rtrs_srv_create_stats_files(struct rtrs_srv_sess *sess) &sess->kobj, "stats"); if (err) { rtrs_err(s, "kobject_init_and_add(): %d\n", err); + kobject_put(&sess->stats->kobj_stats); return err; } err = sysfs_create_group(&sess->stats->kobj_stats, @@ -292,8 +293,8 @@ int rtrs_srv_create_sess_files(struct rtrs_srv_sess *sess) sysfs_remove_group(&sess->kobj, &rtrs_srv_sess_attr_group); put_kobj: kobject_del(&sess->kobj); - kobject_put(&sess->kobj); destroy_root: + kobject_put(&sess->kobj); rtrs_srv_destroy_once_sysfs_root_folders(sess); return err; From patchwork Wed Dec 9 16:45:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961913 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.7 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,URIBL_BLOCKED, 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 A46B3C19425 for ; Wed, 9 Dec 2020 16:47:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CA7023C41 for ; Wed, 9 Dec 2020 16:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727894AbgLIQrJ (ORCPT ); Wed, 9 Dec 2020 11:47:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728826AbgLIQrI (ORCPT ); Wed, 9 Dec 2020 11:47:08 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCB9EC06138C for ; Wed, 9 Dec 2020 08:45:55 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id lt17so3090606ejb.3 for ; Wed, 09 Dec 2020 08:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=81PSqEKTzeewp1eFw0SkbXHJmtuB6a/3wq15G2WR/5g=; b=dVeOT5AN38neXJXE5Q5P2egreXighdeMV857uiJff3y0FdZ7wW76rcXrQzQcqqRyqo ubuQCcR9aOZanCa+DAwJ0QABHPqJ19FmBBlOdSyPATjU0z4S2NohuIELX5zsY7KY+vWt FAYksWCargftoNqxZSiV+J579acLbYMREMgd88EJW0+PgeCegTOOqXxCyN289ScIwRzZ OVFop1D7dGUJT4aIj57IOB/HMerHwU5YcByzPqshkJCQAucSiHvkf2E8Zf1txa7icnbe GZGmr1tY8Apwprh5x4wV2h91xhwqOA2DcT+sRT3zKnOXk+sXdRdNy/Yq0eDvW36JlGG5 SqTg== 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=81PSqEKTzeewp1eFw0SkbXHJmtuB6a/3wq15G2WR/5g=; b=MBSY9nVFQ+5uEvb8kh2NfVoU0s7m+F9c0LwGY52aoNKfduMjwa+TkS7Jir+NOjiP8d b7qYAoesiPpdNSPUuD3phUApVsLL0aSmbdOfVhFMgnKPoeraEBRqUyUIX4VcqdXsdUIN wSUnVtiZUYUs7spmPyLip9rYdQj/w1NUmpMukBtpi33jjmOoYP82i3Y/7N2oDyoVdoqT SK91xYa+Kj0EHhe/9SJCbcKzZeHDwFprwsAXaAK2Jr0xNnD9TsUfLHZzykhTwMF1wBfl bcE7gOWaPp0lhRrE4GOPqDb5Td78yw/+TiYEiK7FoDsif5CDECG1ym6lSxulXXhQtN2H MNig== X-Gm-Message-State: AOAM5321kwbwuV/ytvlNOSQ3z6CvhIOl1hbOwhJq4dXZRHS7LMJ/LACa QrzHSVcABxaplRcWVRkulNsVjR9PnpfmgQ== X-Google-Smtp-Source: ABdhPJyL8THNDBIjQ3FttuMY6h9Qv/HgRwtfAbYIsSRZWY4PSPUxQUm/t1+AltBiC2b8Xg9YX3tAQA== X-Received: by 2002:a17:906:c087:: with SMTP id f7mr2812726ejz.492.1607532354434; Wed, 09 Dec 2020 08:45:54 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:53 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCH for-next 08/18] RDMA/rtrs-clt: Consolidate rtrs_clt_destroy_sysfs_root_{folder,files} Date: Wed, 9 Dec 2020 17:45:32 +0100 Message-Id: <20201209164542.61387-9-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Since the two functions are called together, let's consolidate them in a new function rtrs_clt_destroy_sysfs_root. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 9 +++------ drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++---- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 3 +-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c index ad77659800cd..b6a0abf40589 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c @@ -471,15 +471,12 @@ int rtrs_clt_create_sysfs_root_files(struct rtrs_clt *clt) return sysfs_create_group(&clt->dev.kobj, &rtrs_clt_attr_group); } -void rtrs_clt_destroy_sysfs_root_folders(struct rtrs_clt *clt) +void rtrs_clt_destroy_sysfs_root(struct rtrs_clt *clt) { + sysfs_remove_group(&clt->dev.kobj, &rtrs_clt_attr_group); + if (clt->kobj_paths) { kobject_del(clt->kobj_paths); kobject_put(clt->kobj_paths); } } - -void rtrs_clt_destroy_sysfs_root_files(struct rtrs_clt *clt) -{ - sysfs_remove_group(&clt->dev.kobj, &rtrs_clt_attr_group); -} diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index b3fb5fb93815..99fc34950032 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2707,8 +2707,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, rtrs_clt_close_conns(sess, true); kobject_put(&sess->kobj); } - rtrs_clt_destroy_sysfs_root_files(clt); - rtrs_clt_destroy_sysfs_root_folders(clt); + rtrs_clt_destroy_sysfs_root(clt); free_clt(clt); out: @@ -2725,8 +2724,7 @@ void rtrs_clt_close(struct rtrs_clt *clt) struct rtrs_clt_sess *sess, *tmp; /* Firstly forbid sysfs access */ - rtrs_clt_destroy_sysfs_root_files(clt); - rtrs_clt_destroy_sysfs_root_folders(clt); + rtrs_clt_destroy_sysfs_root(clt); /* Now it is safe to iterate over all paths without locks */ list_for_each_entry_safe(sess, tmp, &clt->paths_list, s.entry) { diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index b8dbd701b3cb..a97a068c4c28 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -243,8 +243,7 @@ ssize_t rtrs_clt_reset_all_help(struct rtrs_clt_stats *stats, /* rtrs-clt-sysfs.c */ int rtrs_clt_create_sysfs_root_files(struct rtrs_clt *clt); -void rtrs_clt_destroy_sysfs_root_folders(struct rtrs_clt *clt); -void rtrs_clt_destroy_sysfs_root_files(struct rtrs_clt *clt); +void rtrs_clt_destroy_sysfs_root(struct rtrs_clt *clt); int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess); void rtrs_clt_destroy_sess_files(struct rtrs_clt_sess *sess, From patchwork Wed Dec 9 16:45:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961917 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.7 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,URIBL_BLOCKED, 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 3E2BAC2BB40 for ; Wed, 9 Dec 2020 16:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18D5922BE9 for ; Wed, 9 Dec 2020 16:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729730AbgLIQrJ (ORCPT ); Wed, 9 Dec 2020 11:47:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728826AbgLIQrJ (ORCPT ); Wed, 9 Dec 2020 11:47:09 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C63C061282 for ; Wed, 9 Dec 2020 08:45:57 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id x16so3058661ejj.7 for ; Wed, 09 Dec 2020 08:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qy3ygq6w7O8DF53aV7q7DOLXGPF0OfN7MeSVY+w05wM=; b=P8yhX7tIpAX0zTWE6Js14kQ4vvoQu61Iv5DCKambWh6xLlgatcXBEn01/CoUd86j5s lsvue5aqXAdssfptBBi08SI0e9XA+e8n0MNmFXJeZQoTGaz3VdK/N18s/hpN49J9ax2Q FXjVudeDk8yYHMHWOcoDdVEXrMrMS30pa0Kq+XCsX39E8eJr5T79ISkiY0/IUyptohqU yGJP23A8tsgJwRUkG5ExWc6yQe9mfRjZ5K2XM1p3SF2BHcliU6/IL9H/SutjfKhxgvP1 ef+2DmAyExn8UycmzwP13dgG1MKJXyiLa7VSPkO4Pddpc/AJpVVJ0O/Bm/VrvKF5cLk1 1Rog== 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=Qy3ygq6w7O8DF53aV7q7DOLXGPF0OfN7MeSVY+w05wM=; b=gzz7z7w7OlFwktWVYhiYHz8DbeYEkUxrg+ICxlrbwTjh8AAcBQqOH6cGvMdVBpP7Do zD7uaw5d0SLd9NZlidN9JQTUHEZ8FddHwBygd7r4AXIvaFHiAocI26gzGYIy8MuMaeKD HKkN6pc/ar7eIfn3P4pyLiplwO27MYVGNxrr0leFFA94FauQwoFTR9fhcUUVYqfc6Bnc 9nuql3jtrFn0YydD8ttsRhNHjk2g42uKKoWCKKMDTdMMgHSD4PfrLn1uFtFMVvv2uf7n PBqWZPEvb+LTVOixM9Xh2c0TqlTIcaKYmymHxAb51TGjXVhRFdHwYl0M9XKPHIFi7Kdz jSOw== X-Gm-Message-State: AOAM5312ax1TYmdltvayyrukFd53tiK5P1FQA9l4PP1NfquHJAZVyrGq ZWNmOf/VLaBM4d5Fuy6ZbzPIXmr5bqS4ew== X-Google-Smtp-Source: ABdhPJweGwFwmW0nF/+f0AO+Wyf+8tUNsfV7eUKm8IQ8pntsG73tM4SObKsSqsWQOeMLjLSiPpX8Eg== X-Received: by 2002:a17:906:1294:: with SMTP id k20mr2754707ejb.404.1607532355835; Wed, 09 Dec 2020 08:45:55 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:55 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal Subject: [PATCH for-next 09/18] RDMA/rtrs-clt: Kill wait_for_inflight_permits Date: Wed, 9 Dec 2020 17:45:33 +0100 Message-Id: <20201209164542.61387-10-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Let's wait the inflight permits before free it. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 99fc34950032..6a5b72ad5ba1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1318,6 +1318,12 @@ static int alloc_permits(struct rtrs_clt *clt) static void free_permits(struct rtrs_clt *clt) { + if (clt->permits_map) { + size_t sz = clt->queue_depth; + + wait_event(clt->permits_wait, + find_first_bit(clt->permits_map, sz) >= sz); + } kfree(clt->permits_map); clt->permits_map = NULL; kfree(clt->permits); @@ -2607,19 +2613,8 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, return clt; } -static void wait_for_inflight_permits(struct rtrs_clt *clt) -{ - if (clt->permits_map) { - size_t sz = clt->queue_depth; - - wait_event(clt->permits_wait, - find_first_bit(clt->permits_map, sz) >= sz); - } -} - static void free_clt(struct rtrs_clt *clt) { - wait_for_inflight_permits(clt); free_permits(clt); free_percpu(clt->pcpu_path); mutex_destroy(&clt->paths_ev_mutex); From patchwork Wed Dec 9 16:45:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961915 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.7 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,URIBL_BLOCKED, 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 6F680C1B0D9 for ; Wed, 9 Dec 2020 16:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DD6C23C41 for ; Wed, 9 Dec 2020 16:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728826AbgLIQrJ (ORCPT ); Wed, 9 Dec 2020 11:47:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729635AbgLIQrJ (ORCPT ); Wed, 9 Dec 2020 11:47:09 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 514DBC061285 for ; Wed, 9 Dec 2020 08:45:58 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id x16so3058757ejj.7 for ; Wed, 09 Dec 2020 08:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3RUukiGOKC64hIM5ZnyE1+UPMzjrvnMOxG9huIVLy+s=; b=ERYkXltTsA2Kgi5mUdiKzeIbSWuL24PF6DHocmyjBmJPC1JZQj7yS3FNVYpERsyHzN zO45WxmMOmjJIqaeDs6HehrLHfCDz6PXIdIVm7IMd29Yvj02Wpc2ipc5bgQM0e+sfdKY abE0zK2dbo62l6M9hJilIAHRc2RdyVL5CAkOiPAtvosQkAfS4hycm3YKQTNtyCxF+R+8 qgTtTZBkzGSGyTzeSPOcav1abSIBVGVMbqtqJMstOiU40miXJqBojpHi8z5ipEH8xnvE 8/Q7du2tpPZfdVBBT2HGZOk/lVg+yvqr4FFfdizWJMT6Wlxs9LYNBr1k1ujw03PjTlo/ 613A== 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=3RUukiGOKC64hIM5ZnyE1+UPMzjrvnMOxG9huIVLy+s=; b=ikVRo8QGC/oGf4pmwx0lH0JWppGLImLimJp7/eZ3GB8FuO8txe14PRjVBIj3sxfYXX aN2FbTFWR3KCS86DLOo/NwcwrrOwrL5LQsFetxcVXnmaPnDH50t4sbhPk8+UAy2itkuA Tfsxdqzp8W0Fh1+mORklRJ3cTfXVyYM+laj2TTNDREwCxwqktA9zDYT3gKPFjbojX9/X pMXLYtXrPFb0GcNLmkq2rt6bC2wWbhLoJ62SN7aag6pgW/gObVU3AcDWP5gZVtzkyOQi YrnW7Wi0mSd31uNqnT4V0zkeKvgtGJVE+C6aVDIiR9QqOouqr4/BPHrlmPP3P6+ZNnyu QSzg== X-Gm-Message-State: AOAM531Ah+BXl3nHC8bNLk3JeSBCCTUHThnCs3IxN5CPMZt5tx5zCg1+ 5XWR4MwydeHc/1P8DQCUNuaFFDG91soqow== X-Google-Smtp-Source: ABdhPJw6aROIFtl2IEv8C3z8YWgDI7GgmGCW3zm2DpeDmyuqrTx2BZSdEh5d0SxpV9hdm0cfIr0YDA== X-Received: by 2002:a17:907:20a4:: with SMTP id pw4mr2730686ejb.499.1607532356906; Wed, 09 Dec 2020 08:45:56 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:56 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCH for-next 10/18] RDMA/rtrs-clt: Remove unnecessary 'goto out' Date: Wed, 9 Dec 2020 17:45:34 +0100 Message-Id: <20201209164542.61387-11-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang This is not needed since the label is just after the place. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 6a5b72ad5ba1..d99fb1a1c194 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2434,7 +2434,6 @@ static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) err = -ECONNRESET; else err = -ETIMEDOUT; - goto out; } out: From patchwork Wed Dec 9 16:45:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961925 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.7 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,URIBL_BLOCKED, 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 07710C1B0D9 for ; Wed, 9 Dec 2020 16:47:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C09BF23C41 for ; Wed, 9 Dec 2020 16:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729855AbgLIQrN (ORCPT ); Wed, 9 Dec 2020 11:47:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729635AbgLIQrK (ORCPT ); Wed, 9 Dec 2020 11:47:10 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68A48C061257 for ; Wed, 9 Dec 2020 08:45:59 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id a16so3074935ejj.5 for ; Wed, 09 Dec 2020 08:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K20am84mWdOPDtt/C3eABp6vABmQqQkIc3UUOw+LTjA=; b=ROQlrTW1UDRKLNLZg7IOm10GtzIuK1UDOJWwaLIZHv5Vgy+RauutoO9V6f7WGEqPEA Dsk5tPaGYlPsEXJme6qQ81k02rukxvpgUHdsf17vsrc2v/vj2EBcF2nrzW2XuWPNp1Bk cB9AjwM91tihues5095uV95u5dcYWh7ajWE/S1bD287S8Fn5aHwkKpxpPeBP0iXZYo7J BWKZMvBdX9yr7ZHGvdA4n6uY6BbU5PR5Rqm5UcTfMbaJSGgt3CmU2NJ5qwLsrwX7kD8h VGP0EqE9/waYAg4XhOcQDP1BWAdi6LLVNIAs0POKvEfFrcj6+B71Hl3KGHLja8ErtzVX 40uQ== 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=K20am84mWdOPDtt/C3eABp6vABmQqQkIc3UUOw+LTjA=; b=TtGFAwY5uzBbKpdoGtPFHAv+RXWJ9vhLI/xGeX4HfC1F4AWf+thGbM3VEyn+yLL+5F 70ChLxPBRLQB0etzCz8nVnbCN4pbfOzn9GIU45YqtjmZml8lugmuiu/KitLBDVoxG0ep 6SzpqLqe8889Y1Gu+4KEBMDhfVATb6u8yAu7mkVpPeESBOqnTiLT4ogzYn9wWBGOSWiZ 7XHqPvNq/ZwHpTyHA0poKOsl9/BbUqXJ6azIX68QhfY3Gwi4lxk0MQenzVXMn2lqACaQ fu7kbafBEJx9enJ7ra7Ork0TYQfJceVYEpGiWakWOJBKfeaiin0jySMc5BYyy2I1ePDq fZJA== X-Gm-Message-State: AOAM530IiWYECB6xx/9ORk09WAg/51ggzR7NWr+lGVaBgdgPfYF9CBSB 8XVQQnbO5wY5wd7c3JSP+3BRd2kxLzsKSg== X-Google-Smtp-Source: ABdhPJzSsZxW50R7q52vMayKq2fr+HzhstMPibIOMXFycfsnDO0iaqJFtMm5VZBwkLmHskDjIvWmEA== X-Received: by 2002:a17:906:1a4e:: with SMTP id j14mr2755879ejf.507.1607532357924; Wed, 09 Dec 2020 08:45:57 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:57 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCH for-next 11/18] RDMA/rtrs-clt: Kill rtrs_clt_change_state Date: Wed, 9 Dec 2020 17:45:35 +0100 Message-Id: <20201209164542.61387-12-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang It is just a wrapper of rtrs_clt_change_state_get_old, and we can reuse rtrs_clt_change_state_get_old with add the checking of 'old_state' is valid or not. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index d99fb1a1c194..39dc8423d7df 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1359,21 +1359,14 @@ static bool rtrs_clt_change_state_get_old(struct rtrs_clt_sess *sess, bool changed; spin_lock_irq(&sess->state_wq.lock); - *old_state = sess->state; + if (old_state) + *old_state = sess->state; changed = __rtrs_clt_change_state(sess, new_state); spin_unlock_irq(&sess->state_wq.lock); return changed; } -static bool rtrs_clt_change_state(struct rtrs_clt_sess *sess, - enum rtrs_clt_state new_state) -{ - enum rtrs_clt_state old_state; - - return rtrs_clt_change_state_get_old(sess, new_state, &old_state); -} - static void rtrs_clt_hb_err_handler(struct rtrs_con *c) { struct rtrs_clt_con *con = container_of(c, typeof(*con), c); @@ -1799,7 +1792,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con, static void rtrs_clt_close_conns(struct rtrs_clt_sess *sess, bool wait) { - if (rtrs_clt_change_state(sess, RTRS_CLT_CLOSING)) + if (rtrs_clt_change_state_get_old(sess, RTRS_CLT_CLOSING, NULL)) queue_work(rtrs_wq, &sess->close_work); if (wait) flush_work(&sess->close_work); @@ -2185,7 +2178,7 @@ static void rtrs_clt_close_work(struct work_struct *work) cancel_delayed_work_sync(&sess->reconnect_dwork); rtrs_clt_stop_and_destroy_conns(sess); - rtrs_clt_change_state(sess, RTRS_CLT_CLOSED); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CLOSED, NULL); } static int init_conns(struct rtrs_clt_sess *sess) @@ -2237,7 +2230,7 @@ static int init_conns(struct rtrs_clt_sess *sess) * doing rdma_resolve_addr(), switch to CONNECTION_ERR state * manually to keep reconnecting. */ - rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING_ERR); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING_ERR, NULL); return err; } @@ -2254,7 +2247,7 @@ static void rtrs_clt_info_req_done(struct ib_cq *cq, struct ib_wc *wc) if (unlikely(wc->status != IB_WC_SUCCESS)) { rtrs_err(sess->clt, "Sess info request send failed: %s\n", ib_wc_status_msg(wc->status)); - rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING_ERR); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING_ERR, NULL); return; } @@ -2378,7 +2371,7 @@ static void rtrs_clt_info_rsp_done(struct ib_cq *cq, struct ib_wc *wc) out: rtrs_clt_update_wc_stats(con); rtrs_iu_free(iu, sess->s.dev->ib_dev, 1); - rtrs_clt_change_state(sess, state); + rtrs_clt_change_state_get_old(sess, state, NULL); } static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) @@ -2443,7 +2436,7 @@ static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) rtrs_iu_free(rx_iu, sess->s.dev->ib_dev, 1); if (unlikely(err)) /* If we've never taken async path because of malloc problems */ - rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING_ERR); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING_ERR, NULL); return err; } @@ -2500,7 +2493,7 @@ static void rtrs_clt_reconnect_work(struct work_struct *work) /* Stop everything */ rtrs_clt_stop_and_destroy_conns(sess); msleep(RTRS_RECONNECT_BACKOFF); - if (rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING)) { + if (rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING, NULL)) { err = init_sess(sess); if (err) goto reconnect_again; @@ -2509,7 +2502,7 @@ static void rtrs_clt_reconnect_work(struct work_struct *work) return; reconnect_again: - if (rtrs_clt_change_state(sess, RTRS_CLT_RECONNECTING)) { + if (rtrs_clt_change_state_get_old(sess, RTRS_CLT_RECONNECTING, NULL)) { sess->stats->reconnects.fail_cnt++; delay_ms = clt->reconnect_delay_sec * 1000; queue_delayed_work(rtrs_wq, &sess->reconnect_dwork, From patchwork Wed Dec 9 16:45:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961919 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.7 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,URIBL_BLOCKED, 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 8A643C433FE for ; Wed, 9 Dec 2020 16:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 520C423C41 for ; Wed, 9 Dec 2020 16:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729767AbgLIQrM (ORCPT ); Wed, 9 Dec 2020 11:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729855AbgLIQrK (ORCPT ); Wed, 9 Dec 2020 11:47:10 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8837BC0611C5 for ; Wed, 9 Dec 2020 08:46:00 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id bo9so3038476ejb.13 for ; Wed, 09 Dec 2020 08:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TNCE9BUjl8LjgBBWvrzQwpmCGHe5xlvz+eb/c5dap0o=; b=eMwYPaUMhixxdtQV0Bc8zdEO4WF7h6ILnhRjsFfP7LGCvksv57xWUJvK4ut6YxSRwJ RlVEmO2JEXuVPm5SwJBq22HTsG1a7wEVkBhBjCFvXNyp5reEdtiWTNacnl3yzTrgV0O8 J+lgLfdV9dTVMGymRDeAHahxdX+x3xrtR4daIrKb7cQW4kaQgnsJVhfkETxQx1V/48cd Wwmwz247vn7FDzLnx+yHMkHig+Pl3FWusZw4FRITXGmZIgc8txi4rCzbLbyEmZvRTBsl S1N4kVoRzlGi2ASp4mF/IagFQYpBnVoY+yiBFy1/5TzkpguFHRzEE9DXdZIN45bUSA8d 1wNw== 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=TNCE9BUjl8LjgBBWvrzQwpmCGHe5xlvz+eb/c5dap0o=; b=S1+xTuCtN0YwyUcymkXK1H13LAqpUtWcPhUiPhGuAJ76sb68MUwioZacXgoEx1opo4 fwg4TK+78JdRQ/L8jadiBKPiHADMAZx63g9SMaDYmF6KRM6mnCLQKpgqDkK4TBhFO4FZ uo+R6x9LtGOPWbfjYUoQ1+TCsM8XA34/miPwnmYaDF1iIQHV4wO/ZzRbURJxVGzWXrc3 mKMdgbiEZlGiXmlM3YIGV1z52t+7NYR4lgmdHEcquygGZYmAg1vQ1Z+IdFmZBa3dim0x Nd7RttE3BKV6z2A8cLn86JYBWEm8LEoTN4r3XTXl+wjXSkiS3PSLWDwfydnnxqFLc82i T77Q== X-Gm-Message-State: AOAM532a4B107HGv5O6ofLZkGkmWj+cPJq8w/aP124zyEQk/XEHmVT24 zDVFx31CE6QSPUKrC7k3A4G3agDhWo/8kA== X-Google-Smtp-Source: ABdhPJxzBpGUKbaMs8FmW9fW8JQfmtGGJdGG88/hFPXKrPoIsuMYoFbOiaKeAQrWlrffZzJTjGPMOQ== X-Received: by 2002:a17:906:eb8d:: with SMTP id mh13mr2717951ejb.299.1607532359010; Wed, 09 Dec 2020 08:45:59 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:58 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal Subject: [PATCH for-next 12/18] RDMA/rtrs-clt: Rename __rtrs_clt_change_state to rtrs_clt_change_state Date: Wed, 9 Dec 2020 17:45:36 +0100 Message-Id: <20201209164542.61387-13-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Let's rename it to rtrs_clt_change_state since the previous one is killed. Also update the comment to make it more clear. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 39dc8423d7df..3c90718f668d 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -178,18 +178,18 @@ struct rtrs_clt_con *rtrs_permit_to_clt_con(struct rtrs_clt_sess *sess, } /** - * __rtrs_clt_change_state() - change the session state through session state + * rtrs_clt_change_state() - change the session state through session state * machine. * * @sess: client session to change the state of. * @new_state: state to change to. * - * returns true if successful, false if the requested state can not be set. + * returns true if sess's state is changed to new state, otherwise return false. * * Locks: * state_wq lock must be hold. */ -static bool __rtrs_clt_change_state(struct rtrs_clt_sess *sess, +static bool rtrs_clt_change_state(struct rtrs_clt_sess *sess, enum rtrs_clt_state new_state) { enum rtrs_clt_state old_state; @@ -286,7 +286,7 @@ static bool rtrs_clt_change_state_from_to(struct rtrs_clt_sess *sess, spin_lock_irq(&sess->state_wq.lock); if (sess->state == old_state) - changed = __rtrs_clt_change_state(sess, new_state); + changed = rtrs_clt_change_state(sess, new_state); spin_unlock_irq(&sess->state_wq.lock); return changed; @@ -1361,7 +1361,7 @@ static bool rtrs_clt_change_state_get_old(struct rtrs_clt_sess *sess, spin_lock_irq(&sess->state_wq.lock); if (old_state) *old_state = sess->state; - changed = __rtrs_clt_change_state(sess, new_state); + changed = rtrs_clt_change_state(sess, new_state); spin_unlock_irq(&sess->state_wq.lock); return changed; From patchwork Wed Dec 9 16:45:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961921 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.7 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,URIBL_BLOCKED, 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 70A1EC4361B for ; Wed, 9 Dec 2020 16:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3767E22BE9 for ; Wed, 9 Dec 2020 16:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730081AbgLIQrM (ORCPT ); Wed, 9 Dec 2020 11:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730188AbgLIQrM (ORCPT ); Wed, 9 Dec 2020 11:47:12 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D17FBC0611CA for ; Wed, 9 Dec 2020 08:46:01 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id h16so2275495edt.7 for ; Wed, 09 Dec 2020 08:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ce/Bwa3SIK5dxNWoTyb5Ghqa/Fpa/H/KZk3y3B+mcdU=; b=GFOyaUJkol6SisFyzhPsi1r1uwk6EAoGGZ/HIRtQqO2ZOX0GNiITJLC1MuW4P7+Z2u CIpP/UmukDTfNoT61JNdWGDNZ3NCba7pCjDhPzu55QjhpJMZFe74mI528OBFI7PyAO5Y DeMAdBgc7JvyJsBVTkrwAIf7m9XfMopatIHtFyYihhTB3ApFl1Amizf6k08nX6ZnWlF2 uZNpFREPbRXrVazsxQ78KYygDM1kN+cFmH8++B8ns4+SOFDYYHD3b8ujvbKaf2qvRYyZ qwEXGuR1np8I+/DojcwV8JK4All8MwlDh0fgCLheYM3VUQ0Pl7YtAzF/bM0EaCENI3vI mwEA== 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=Ce/Bwa3SIK5dxNWoTyb5Ghqa/Fpa/H/KZk3y3B+mcdU=; b=NPSFv0Kx7+IsMoPjv31Z7eO7/0xh9PZIOHBpmFB26ebrkcondT7G1v3r44GV/VO0Xi pOWEtyNi03zGJki01sjP6uxIf8UAS3QVQ0nofHeSWrEI8bOILNrd9s2U2LpWHj+q0Jtt fR6UruwCjjeg3ugy5gVRSM59C8rV79qiNYBAbqO5EqFxPUZLYa9sqUG1hFnLNAUW9dv9 VvEvFUQEqSVSWPuuVQyldTb8PwwOazS2pbWjodNcR6BRPEHC9p2deKEOlUwaNvBvjCu/ AHFZLcz7Z6HnN8IxubrYW3i6vKoC26BxPdXhhxbR3m3K52pNlfe8WY0UntFiU6WsD/e8 4F1g== X-Gm-Message-State: AOAM531QTOBvlRna1fCAEBpH+huLKU1i1R8g4OKviXBvG2s+IV7xzSbh 8DPYTQUJpBGMjvWNpDbx79yzYksw+9hqjg== X-Google-Smtp-Source: ABdhPJy7JIeEW4EQnchTNtfB67ibK11H6cVMS96M1eJ9bm8ewcrBAWAY9falCgJmI45nH3eC6Mlm4Q== X-Received: by 2002:a50:c299:: with SMTP id o25mr2815783edf.343.1607532360227; Wed, 09 Dec 2020 08:46:00 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:45:59 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Md Haris Iqbal , Guoqing Jiang Subject: [PATCH for-next 13/18] RDMA/rtrs-srv: Fix missing wr_cqe Date: Wed, 9 Dec 2020 17:45:37 +0100 Message-Id: <20201209164542.61387-14-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We had a few places wr_cqe is not set, which could lead to NULL pointer deref or GPF in error case. Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal Signed-off-by: Guoqing Jiang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 27ac5a03259a..c742bb5d965b 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -267,6 +267,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) WARN_ON_ONCE(rkey != wr->rkey); wr->wr.opcode = IB_WR_RDMA_WRITE; + wr->wr.wr_cqe = &io_comp_cqe; wr->wr.ex.imm_data = 0; wr->wr.send_flags = 0; @@ -294,6 +295,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) inv_wr.sg_list = NULL; inv_wr.num_sge = 0; inv_wr.opcode = IB_WR_SEND_WITH_INV; + inv_wr.wr_cqe = &io_comp_cqe; inv_wr.send_flags = 0; inv_wr.ex.invalidate_rkey = rkey; } @@ -304,6 +306,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) srv_mr = &sess->mrs[id->msg_id]; rwr.wr.opcode = IB_WR_REG_MR; + rwr.wr.wr_cqe = &local_reg_cqe; rwr.wr.num_sge = 0; rwr.mr = srv_mr->mr; rwr.wr.send_flags = 0; @@ -379,6 +382,7 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, if (need_inval) { if (likely(sg_cnt)) { + inv_wr.wr_cqe = &io_comp_cqe; inv_wr.sg_list = NULL; inv_wr.num_sge = 0; inv_wr.opcode = IB_WR_SEND_WITH_INV; @@ -421,6 +425,7 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, srv_mr = &sess->mrs[id->msg_id]; rwr.wr.next = &imm_wr; rwr.wr.opcode = IB_WR_REG_MR; + rwr.wr.wr_cqe = &local_reg_cqe; rwr.wr.num_sge = 0; rwr.wr.send_flags = 0; rwr.mr = srv_mr->mr; From patchwork Wed Dec 9 16:45:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961923 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.7 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,URIBL_BLOCKED, 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 DDDB1C4167B for ; Wed, 9 Dec 2020 16:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A631322BE9 for ; Wed, 9 Dec 2020 16:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730188AbgLIQrM (ORCPT ); Wed, 9 Dec 2020 11:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729544AbgLIQrM (ORCPT ); Wed, 9 Dec 2020 11:47:12 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41996C0611CB for ; Wed, 9 Dec 2020 08:46:03 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id h16so2275586edt.7 for ; Wed, 09 Dec 2020 08:46:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UFNb99s/RTR+9Z5BZf2S4yuaWavk0ZSJFDP1tqF7kdg=; b=KGl3SpWhDsbPX8C1TKapogbU35UkySnTh7YZZ+RtMBFzDNhiR/9maQ6KLCXQtWy2ub tW2nE1s4eFYEvuEpyiw5V5NCzhqT7fVjNWrq/d0pcXFOs99suQnRw8qa9lGXCvHLkYDu 4DbhlE+oSWUdJkOm87+6fSftZhmPZgUjb8331RvNvhWexcRvz/FZMle1b5qjWo4R82NP PKYh7GbbHQAmqA0Scp9r5bWQ90NE6nXgJwUwg8nY4sGeOrGsgtCos3+ohroeMT5kCzNy pghJXr2r1JK1BzlTfvE94KB2Ov1CKhFPrF/M4oFcbM/Ats9ho871D1vOOhbB4IrPlR2w a+jQ== 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=UFNb99s/RTR+9Z5BZf2S4yuaWavk0ZSJFDP1tqF7kdg=; b=BWw4W4TxUpVhNhqFa4wOxqF2piLwMPXPnxPY9R7m+ndBG64KhHy5Ga0sXre4sFBM4i tn5srXxnqy3QOIpzOSp7CoKTeWQ2V8UDcYU3CyvgOaL7oAG7QMo4k7G2sGfROC+bJqnh i4oFrsyEhSDmYL2Nd7mNjsNFPeh6yv+mLJuLkEt4Om7TEX6RrIkNhXAVLxokuk/ER4Fq kSBpp4rJAb5HX86/N05kO4kyM61+x+aBOzWsgq9Doar3PASyIvRB1yQ5F9KU4xu3cSYj FCVvyl9XoylwMJj4Xv40O6jFVufcjHN7oz92yukgIjDszep9TfSp9zxMO+JlTKq7Jp2g d7sA== X-Gm-Message-State: AOAM532ll2PGMHFivl/De14zXusNe3rtPuZAllaakWHY0PR1hc9ioUie 4t+Xt41brhSyY9daGPtNL6WKinPMlfsdZA== X-Google-Smtp-Source: ABdhPJxEeJCdG1Db4aYHbdhMgUW6toypLmMBXfhVhPixDqgViNIdswrXBELhPkDKXeknj5RP+tM/GA== X-Received: by 2002:a05:6402:1d24:: with SMTP id dh4mr2791438edb.161.1607532361764; Wed, 09 Dec 2020 08:46:01 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:46:00 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal Subject: [PATCH for-next 14/18] RDMA/rtrs-clt: Refactor the failure cases in alloc_clt Date: Wed, 9 Dec 2020 17:45:38 +0100 Message-Id: <20201209164542.61387-15-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Make all failure cases go to the common path to avoid duplicate code. And some issued existed before. 1. clt need to be freed to avoid memory leak. 2. return ERR_PTR(-ENOMEM) if kobject_create_and_add fails, because rtrs_clt_open checks the return value of by call "IS_ERR(clt)". Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 3c90718f668d..493f45a33b5e 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2568,11 +2568,8 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, clt->dev.class = rtrs_clt_dev_class; clt->dev.release = rtrs_clt_dev_release; err = dev_set_name(&clt->dev, "%s", sessname); - if (err) { - free_percpu(clt->pcpu_path); - kfree(clt); - return ERR_PTR(err); - } + if (err) + goto err; /* * Suppress user space notification until * sysfs files are created @@ -2580,29 +2577,31 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, dev_set_uevent_suppress(&clt->dev, true); err = device_register(&clt->dev); if (err) { - free_percpu(clt->pcpu_path); put_device(&clt->dev); - return ERR_PTR(err); + goto err; } clt->kobj_paths = kobject_create_and_add("paths", &clt->dev.kobj); if (!clt->kobj_paths) { - free_percpu(clt->pcpu_path); - device_unregister(&clt->dev); - return NULL; + err = -ENOMEM; + goto err_dev; } err = rtrs_clt_create_sysfs_root_files(clt); if (err) { - free_percpu(clt->pcpu_path); kobject_del(clt->kobj_paths); kobject_put(clt->kobj_paths); - device_unregister(&clt->dev); - return ERR_PTR(err); + goto err_dev; } dev_set_uevent_suppress(&clt->dev, false); kobject_uevent(&clt->dev.kobj, KOBJ_ADD); return clt; +err_dev: + device_unregister(&clt->dev); +err: + free_percpu(clt->pcpu_path); + kfree(clt); + return ERR_PTR(err); } static void free_clt(struct rtrs_clt *clt) From patchwork Wed Dec 9 16:45:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961929 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.7 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,URIBL_BLOCKED, 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 6CBECC4361B for ; Wed, 9 Dec 2020 16:47:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4227B23C41 for ; Wed, 9 Dec 2020 16:47:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728082AbgLIQrf (ORCPT ); Wed, 9 Dec 2020 11:47:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbgLIQrW (ORCPT ); Wed, 9 Dec 2020 11:47:22 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF3CDC0611CC for ; Wed, 9 Dec 2020 08:46:04 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ga15so3076144ejb.4 for ; Wed, 09 Dec 2020 08:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=15VQrmvhlUpyxMOUEn1612DZAbVr+8NuIXtdm8Gd1fw=; b=ftsCkmXvj3ClXhazKO2e+EZHBNCbOjYAGlwMZC/qbIY9NAVk4s2f7ZmSCMi/UWY9a+ ABIrmvDiErhhY5PiNAX71ivMieOtu/2ypkf4BtzWa/iPZL4Y36vuhv/zjLffl5GA84ub XGT7ONeuGIZEzFsa+7oCMn2wPMnjGkHseiq11oKfhp2jf1+0beMeRHYLJreSsExF+lv2 dnV463H6EBuXyHfAZYN+EA1a136eJs+6gye4c8DjLsw0abpHbszQo2vPjf8WY0aOW3hN GjEmzU/YO6GxHGRWw/W9WWk6D4OBDN4ANOMKBTqvjEhTfiXUjdkeQDMA0GeOE+CcDuS1 1P3w== 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=15VQrmvhlUpyxMOUEn1612DZAbVr+8NuIXtdm8Gd1fw=; b=JpWehOGpjU03r8iWfGZBXUCYg8V3EogSxR3TPem9Y33upGdlyV6smT/ZyjGazJpu5D p8EWurouLHSGA6GxbAYNjNS8UsoYqSLZIonQn1Ze2mhGwn57/6BPwfIaSGyRorkjY7Fv x3/b9EbjtxGVOsjZ0gPoi5iN7j3asAsHd2G0JdzBpsVglT1va4qpZS0OAh3/x905XJB/ W/f7N5rB3kR+nBzBQSwUh1HhWc8gjFTYk/JRFeXRK7KbFZ84AOWCti/yicBDrpcA5/lC K+pXq1JWD82zRZLVsfY/kRN4Vr4VPrkHXvfBvlUitDMDzt04dKkYTdQWdMoMEyC34M4d JAWg== X-Gm-Message-State: AOAM531SkaZs2dpaG4mmjCtPdp/3/L82QHcM9IpeImRpuG79tK0J7FhM zSawOueNgytjMV/7WAqp3joPCmmPUC8WqQ== X-Google-Smtp-Source: ABdhPJw54p/6Scj6YfCnIg0CaZxn+WUec42ilRO3sdghXIfSpWYTp6UTBt8NC7cleThlDjEvVkJNbg== X-Received: by 2002:a17:907:20dc:: with SMTP id qq28mr2737236ejb.403.1607532362910; Wed, 09 Dec 2020 08:46:02 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:46:02 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCH for-next 15/18] RDMA/rtrs: Do not signal for heatbeat Date: Wed, 9 Dec 2020 17:45:39 +0100 Message-Id: <20201209164542.61387-16-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org For HB, there is no need to generate signal for completion. Also remove a comment accordingly. Signed-off-by: Jack Wang Reported-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 1 - drivers/infiniband/ulp/rtrs/rtrs-srv.c | 1 - drivers/infiniband/ulp/rtrs/rtrs.c | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 493f45a33b5e..2053bf99418a 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -664,7 +664,6 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) case IB_WC_RDMA_WRITE: /* * post_send() RDMA write completions of IO reqs (read/write) - * and hb */ break; diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index c742bb5d965b..5065bf31729d 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1242,7 +1242,6 @@ static void rtrs_srv_rdma_done(struct ib_cq *cq, struct ib_wc *wc) case IB_WC_SEND: /* * post_send() RDMA write completions of IO reqs (read/write) - * and hb */ atomic_add(srv->queue_depth, &con->sq_wr_avail); diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index df52427f1710..97af8f0bb806 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -310,7 +310,7 @@ void rtrs_send_hb_ack(struct rtrs_sess *sess) imm = rtrs_to_imm(RTRS_HB_ACK_IMM, 0); err = rtrs_post_rdma_write_imm_empty(usr_con, sess->hb_cqe, imm, - IB_SEND_SIGNALED, NULL); + 0, NULL); if (err) { sess->hb_err_handler(usr_con); return; @@ -339,7 +339,7 @@ static void hb_work(struct work_struct *work) } imm = rtrs_to_imm(RTRS_HB_MSG_IMM, 0); err = rtrs_post_rdma_write_imm_empty(usr_con, sess->hb_cqe, imm, - IB_SEND_SIGNALED, NULL); + 0, NULL); if (err) { sess->hb_err_handler(usr_con); return; From patchwork Wed Dec 9 16:45:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961927 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.7 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,URIBL_BLOCKED, 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 071D0C433FE for ; Wed, 9 Dec 2020 16:47:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D49E323C41 for ; Wed, 9 Dec 2020 16:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726227AbgLIQr3 (ORCPT ); Wed, 9 Dec 2020 11:47:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730313AbgLIQrW (ORCPT ); Wed, 9 Dec 2020 11:47:22 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF525C0611CD for ; Wed, 9 Dec 2020 08:46:05 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id v22so2277682edt.9 for ; Wed, 09 Dec 2020 08:46:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6GRiAcnxnxyNYL2OZv9ru2Lq+clQj5bUxW2kCmsckao=; b=NEmcQroOuxQoZr/ULQ0KLg7/3GqIyI0gZYxL73DTTklC9yeKUKif8/551qlXr49dnu YRZASS2rJLxKFlpxozO3teYdum8yAHUNyIsh+J2QlZIM8GF+n5PhvnxM8KM/PO/G0lto Dgo3+djOffgCBlzlSKsjodeHQCoo/cYJDUWnMx3ndJfb3gnnckNum+iwzWb/1Ol6kpX8 ipzLlMT9+5DQ7assW/hiT29gFFRGvyBY4tljlVKzoj2SYBcBbaN3XH3wx9PeWwMcDopH ZaKrrFvPBI7dtDkyGys4Pgg7HWlE3S1VKE874XfereBqghB/sxbe03mcQ1KQF1hCz62D FhIw== 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=6GRiAcnxnxyNYL2OZv9ru2Lq+clQj5bUxW2kCmsckao=; b=ZzAh28ylnd8NYwz2LNKcdhlENSlygUqxXEVEIO8oLMmPUPDriyfUA12owN0F1bEzH/ PRkRg6N6aLuTJXcJpZvDEqwppegfiJKPnLzsFMgkinzP+D7Ld+QJNjvllR0Ipo2HGb0t I/MQUKTl1cXaJiFCbD371UJS0QAeWNjMxS0+NfG07iBd7qQxTyshZuwhQajO+Ff03sLF 84/ln/Phrn1tD/gZh/N++xqtgM2cYGOfYy5hRBtx+FY/vVl5p9jPpdLaP5t22b3LsnG8 5+x2quTpSV7sGZ2K2Jz6tXISrlgZEE52eVpmMAmYCMB47ZjZ5y2RwpOPcS3Aos8nei2/ WQ7A== X-Gm-Message-State: AOAM533aWezLXOcGmC6Nncqf+nrjurot14Ziifj/EeFGIuIrKpxpHb5M HavHHWi/CZSBCa9k009HiTuJYlrb/GmeXA== X-Google-Smtp-Source: ABdhPJz2ytA0BVAjvHJaQJg/iojrkQery+XdDJ0fK4Ce5Db1OZcwybudAJm4pMpEX6FM8b6nroTP9g== X-Received: by 2002:a50:c19a:: with SMTP id m26mr2813358edf.302.1607532364161; Wed, 09 Dec 2020 08:46:04 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:46:03 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCH for-next 16/18] RDMA/rtrs-clt: Use bitmask to check sess->flags Date: Wed, 9 Dec 2020 17:45:40 +0100 Message-Id: <20201209164542.61387-17-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We may want to add new flags, so it's better to use bitmask to check flags. Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 2053bf99418a..7644c3f627ca 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -494,7 +494,7 @@ static void rtrs_clt_recv_done(struct rtrs_clt_con *con, struct ib_wc *wc) int err; struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); - WARN_ON(sess->flags != RTRS_MSG_NEW_RKEY_F); + WARN_ON((sess->flags & RTRS_MSG_NEW_RKEY_F) == 0); iu = container_of(wc->wr_cqe, struct rtrs_iu, cqe); err = rtrs_iu_post_recv(&con->c, iu); @@ -514,7 +514,7 @@ static void rtrs_clt_rkey_rsp_done(struct rtrs_clt_con *con, struct ib_wc *wc) u32 buf_id; int err; - WARN_ON(sess->flags != RTRS_MSG_NEW_RKEY_F); + WARN_ON((sess->flags & RTRS_MSG_NEW_RKEY_F) == 0); iu = container_of(wc->wr_cqe, struct rtrs_iu, cqe); @@ -621,12 +621,12 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) } else if (imm_type == RTRS_HB_MSG_IMM) { WARN_ON(con->c.cid); rtrs_send_hb_ack(&sess->s); - if (sess->flags == RTRS_MSG_NEW_RKEY_F) + if (sess->flags & RTRS_MSG_NEW_RKEY_F) return rtrs_clt_recv_done(con, wc); } else if (imm_type == RTRS_HB_ACK_IMM) { WARN_ON(con->c.cid); sess->s.hb_missed_cnt = 0; - if (sess->flags == RTRS_MSG_NEW_RKEY_F) + if (sess->flags & RTRS_MSG_NEW_RKEY_F) return rtrs_clt_recv_done(con, wc); } else { rtrs_wrn(con->c.sess, "Unknown IMM type %u\n", @@ -654,7 +654,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) WARN_ON(!(wc->wc_flags & IB_WC_WITH_INVALIDATE || wc->wc_flags & IB_WC_WITH_IMM)); WARN_ON(wc->wr_cqe->done != rtrs_clt_rdma_done); - if (sess->flags == RTRS_MSG_NEW_RKEY_F) { + if (sess->flags & RTRS_MSG_NEW_RKEY_F) { if (wc->wc_flags & IB_WC_WITH_INVALIDATE) return rtrs_clt_recv_done(con, wc); @@ -679,7 +679,7 @@ static int post_recv_io(struct rtrs_clt_con *con, size_t q_size) struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); for (i = 0; i < q_size; i++) { - if (sess->flags == RTRS_MSG_NEW_RKEY_F) { + if (sess->flags & RTRS_MSG_NEW_RKEY_F) { struct rtrs_iu *iu = &con->rsp_ius[i]; err = rtrs_iu_post_recv(&con->c, iu); @@ -1563,7 +1563,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) sess->queue_depth * 3 + 1); } /* alloc iu to recv new rkey reply when server reports flags set */ - if (sess->flags == RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) { + if (sess->flags & RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) { con->rsp_ius = rtrs_iu_alloc(max_recv_wr, sizeof(*rsp), GFP_KERNEL, sess->s.dev->ib_dev, DMA_FROM_DEVICE, From patchwork Wed Dec 9 16:45:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961931 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.7 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,URIBL_BLOCKED, 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 4969CC433FE for ; Wed, 9 Dec 2020 16:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1528922BE9 for ; Wed, 9 Dec 2020 16:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729012AbgLIQrr (ORCPT ); Wed, 9 Dec 2020 11:47:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbgLIQrr (ORCPT ); Wed, 9 Dec 2020 11:47:47 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A64C0611CE for ; Wed, 9 Dec 2020 08:46:06 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id x16so3059366ejj.7 for ; Wed, 09 Dec 2020 08:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Tu9uEebi7AgTLMoh/8fJzo59NxyxXxaWkQigCjrk4A=; b=IKI7Rr3G+9EKmUPvgJjQGAyA2ltuvOIUgoGWKTtU3xP9Lb1xwpH2cK4fpYRHRf615i /IK0XcatOT8kHmww4gpO99oR/v0CD9JVxJvBj64gfIqCRB+e2utfpRp1gq35qmPu3wY3 pt+JfAF1Fyfd6IYfo4r4WEqIWy+vSaljVUGTLFpQaGRZlXXvNH32R07G4gL4YNLPlOCw tSYZCdNpNRoaQUWa17dfE2LT/yUxPVap5cUts9d5yDXy1KyBHwNi6VDYL561kiIRAC8J 1UKTp3CTCVIWjrnIMDzDfMhsuU5BG4OIVl73rRU8uGEYXBVGGKS8aC1Q4Vpr93BJgO+6 QVrQ== 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=7Tu9uEebi7AgTLMoh/8fJzo59NxyxXxaWkQigCjrk4A=; b=aO2umORAKbeJQZ5CicKCAzo+PsGZs8OyDzNWFzb4gqk9aIBeZUGYBScqGSjbdXD5mP qtjgevv9IAznY00bjWBW2L8eGpbMTWv3Be4vmPL8QV1+c1K9wJFGkRwPCUJaxDgjOs/U CD8Ax3AyxZY2j1DVe8cBYNIzxIAs6TYvBL46DMFP/dsfaX9BmwmZJlOUV5mJeeV0LSPG ir0S5ev4c9X9Aibt+cvAUxei/UhFVcO8sS0iTIU3llpjwBKT8hr/dU3l+24aRV5PqerH gRVjIyHsaz8xY4bwaNd+pwq4s3nDDl5b8KVmVjBxXxq01QLbtL5AQpy4fH9iv5cJpnjz oU3g== X-Gm-Message-State: AOAM531NFsGQKoQSFGxnFJhOa41EfbYg0RiCqTGAwMYa9ObHyduL8AQT dR3lISrbxjLEbAeQlh5dU5Fivq+vcJyfeA== X-Google-Smtp-Source: ABdhPJyvMDeeYnF8ic22j0cOS7dWpc5e34Om/ffHyJNsdoPE/g7zT/C9CiQxYjI9t9Ek4CQpxsKspg== X-Received: by 2002:a17:906:a183:: with SMTP id s3mr2914121ejy.60.1607532365339; Wed, 09 Dec 2020 08:46:05 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:46:04 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCH for-next 17/18] RDMA/rtrs-srv: Do not signal REG_MR Date: Wed, 9 Dec 2020 17:45:41 +0100 Message-Id: <20201209164542.61387-18-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We do not need to wait for REG_MR completion, so remove the SIGNAL flag. Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 5065bf31729d..8363c407ab4b 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -818,7 +818,7 @@ static int process_info_req(struct rtrs_srv_con *con, rwr[mri].wr.opcode = IB_WR_REG_MR; rwr[mri].wr.wr_cqe = &local_reg_cqe; rwr[mri].wr.num_sge = 0; - rwr[mri].wr.send_flags = mri ? 0 : IB_SEND_SIGNALED; + rwr[mri].wr.send_flags = 0; rwr[mri].mr = mr; rwr[mri].key = mr->rkey; rwr[mri].access = (IB_ACCESS_LOCAL_WRITE | From patchwork Wed Dec 9 16:45:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11961933 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.7 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,URIBL_BLOCKED, 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 993C2C4361B for ; Wed, 9 Dec 2020 16:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B09E22BE9 for ; Wed, 9 Dec 2020 16:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726698AbgLIQrr (ORCPT ); Wed, 9 Dec 2020 11:47:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728099AbgLIQrr (ORCPT ); Wed, 9 Dec 2020 11:47:47 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6EFFC0611CF for ; Wed, 9 Dec 2020 08:46:07 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id ce23so3058114ejb.8 for ; Wed, 09 Dec 2020 08:46:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QWpXk/5XKmoU4V5l78k0MQE8DoOGpWuFgtB9vCnVr8s=; b=IhObAFrMLBtJG7jUEvY7mCt5Vdjr+8tZhlUBZbxd4zNpNQJ4pbtA+5wVIDfeSVPAuK acu6zWsI2N/ZeIpCSNa32UmCFHBJaaauAZRjmBXxU2mhwJsxAyTWl89twGJYrR4nUwhz sq0TU5cC+9ZCsGYFQY0h/x2RYSiRZrJWBy3WqoKO0Y6ogUjbvBTrskNzk4deiGzwjjVe 50D+0QPvbfoJGD0iSDyYxxo4disRT9WVRwvKS76GzN0+JwMFDxg70clNn6btRxkH+1gL GDnBw9i5VlYFnA+1KG8Hoh9udu+ZgiHm4SzbBnYn2REEqq5ExM6LTTyxNE+J6WsCV9CN xGZQ== 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=QWpXk/5XKmoU4V5l78k0MQE8DoOGpWuFgtB9vCnVr8s=; b=oM94Mqm1qs8YWKK5CLuEp1aopluM0mqKd216GMJ9/1YPwE37+Ffog9WZcAkluaivoR gNF1x0T/0ih1nZ9VAezMth3OLQFNeYS8f8rsVYFbx5ehUL52Tlok6NgP9ZRiiJz4h/jg dO6r6nr9e21A1R0IZC8eW14ADWZrAl1uj/BUss56J2QNtg4pzy7y9WNTJt2PBFVj0gzD SzKU9JbpkLyJxayGDRd4B/DkEEtHeZGxps9Ri/bAI0X4FgWy5+W70flb2EPis0QcuLOX SFEGiZb8LvrYL0xU+JreHEtsUBs4a72BIP3IZC1iuq8kCR3VKFMjxSrg+LE7ADOOzj1A 4mow== X-Gm-Message-State: AOAM533ywIYN4m1ZFFLd5ytf5xqBTzp8ra3uq7msoV907u/aoNEA9x84 MZVBIAlPV2H9l+UvqmO5hmricd7n2fNSdQ== X-Google-Smtp-Source: ABdhPJyYpaE2xzOa9FCsJGLbwZkzneeK3de8n9iyH8rbOkgvSc5cMYUf5HP0M+dYkK41Yo99NpcpeA== X-Received: by 2002:a17:906:d10f:: with SMTP id b15mr2721962ejz.268.1607532366349; Wed, 09 Dec 2020 08:46:06 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49e0:2500:1d14:118d:b29c:98ec]) by smtp.gmail.com with ESMTPSA id h16sm1977915eji.110.2020.12.09.08.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 08:46:05 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCH for-next 18/18] RDMA/rtrs-srv: Init wr_cnt as 1 Date: Wed, 9 Dec 2020 17:45:42 +0100 Message-Id: <20201209164542.61387-19-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> References: <20201209164542.61387-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Fix up wr_avail accounting. if wr_cnt is 0, then we do SIGNAL for first wr, in completion we add queue_depth back, which is not right in the sense of tracking for available wr. So fix it by init wr_cnt to 1. Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 8363c407ab4b..e1907c10c7e7 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1603,7 +1603,7 @@ static int create_con(struct rtrs_srv_sess *sess, con->c.cm_id = cm_id; con->c.sess = &sess->s; con->c.cid = cid; - atomic_set(&con->wr_cnt, 0); + atomic_set(&con->wr_cnt, 1); if (con->c.cid == 0) { /*