From patchwork Sat May 14 03:04:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 12849678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF712C433F5 for ; Sat, 14 May 2022 03:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230221AbiENDHm (ORCPT ); Fri, 13 May 2022 23:07:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbiENDHk (ORCPT ); Fri, 13 May 2022 23:07:40 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 324B131E983 for ; Fri, 13 May 2022 20:07:39 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id m6-20020a05683023a600b0060612720715so6238873ots.10 for ; Fri, 13 May 2022 20:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wJzCta5hxvHHdGkcEjDzislssJoy6pu0EOCtdvMke5A=; b=cfBGX4amal5TQbU5ktgCGpDmB3APk1y4IE6lVXHjAv1ZzETScRc9ra3ck1oqQZ5rfr hNqyGsVqJMEr6gmIuFgnLCg6TF8bhyrkkFK2iMeXuowllI7Aw5NbSiQVjP60QViydAen xSa8vtxLBvsNYI4zho4mLBcq+efm6gcmwQM0Bkf6E/tNyieaCPtoNodNGw4psmjIdm8N EzSUXqZaU14Jka0H8OiEfTA8Xc6RrHVaJGYPw5NhztV+TpTjZtdA0fDDnrQipQjGGxDB Bi/Ywzte+JvQfEr0ODdpAgmSLLYCdJ+YpVR18mMzKsBRFL9C0xFgbS99A+KLQ2v5sx8n TBUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wJzCta5hxvHHdGkcEjDzislssJoy6pu0EOCtdvMke5A=; b=B5qRlnFDTTcYTIbQbLfQ+azYNZ0W8fDxTMu7FzM19KgYj4a0GrLQOz38USpA4gPo9C Qza+MyCL5YVTt/3EJs0jX5aM/Nire6Rn6Hm8yLY/GfpVXZygqKxl0e/h559PAjT4UgUj fb6IIk/jAmgMCPXfrdU/8LdxD98CHV1FWlt0ZSsjbrkb7D2p/spS8vM48ZckqKTanGEk JjzJ3MzPduOYRiX9CiucV6iMYf3KZEYegi5tcjlf1v/G0mvlte6pp6x4vfRUrLxBZQUf p478/eE+F/QJ6TChmvdmRAXGkHSANbaWWcCHwsfMbjAMFo57ss/D6IxJCAF1CqzvOLHl jayQ== X-Gm-Message-State: AOAM533KTahoxAg2WgCWUM14uvT0WlmGwGFWlAUV71bGdB0tM37W0oEK EEug6D/5jIWssJ0pUC62Vxw= X-Google-Smtp-Source: ABdhPJzY7yI41Pkzn9QVS0soDldDhIrPzyG2NyafIkJfbm+sy8blA+9n9PHksTzOGJxZFcDDcRkYhQ== X-Received: by 2002:a9d:20e5:0:b0:606:8c4a:c671 with SMTP id x92-20020a9d20e5000000b006068c4ac671mr2909821ota.342.1652497658535; Fri, 13 May 2022 20:07:38 -0700 (PDT) Received: from u-22.tx.rr.com (2603-8081-140c-1a00-0642-4ec7-2b63-14d6.res6.spectrum.com. [2603:8081:140c:1a00:642:4ec7:2b63:14d6]) by smtp.googlemail.com with ESMTPSA id h64-20020a9d2f46000000b0060603221262sm1691176otb.50.2022.05.13.20.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:07:38 -0700 (PDT) From: Bob Pearson To: jgg@nvidia.com, zyjzyj2000@gmail.com, tom@talpey.com, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-rc v2 1/4] RDMA/rxe: Rename qp->qp_timeout_jiffies Date: Fri, 13 May 2022 22:04:34 -0500 Message-Id: <20220514030435.91155-2-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220514030435.91155-1-rpearsonhpe@gmail.com> References: <20220514030435.91155-1-rpearsonhpe@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Replace qp->qp_timeout_jiffies by the shorter name qp->timeout_jiffies which is a little less redundant. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 4 ++-- drivers/infiniband/sw/rxe/rxe_qp.c | 8 ++++---- drivers/infiniband/sw/rxe/rxe_req.c | 5 +++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index 138b3e7d3a5f..badd423966dc 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -672,9 +672,9 @@ int rxe_completer(void *arg) if ((qp_type(qp) == IB_QPT_RC) && (qp->req.state == QP_STATE_READY) && (psn_compare(qp->req.psn, qp->comp.psn) > 0) && - qp->qp_timeout_jiffies) + qp->timeout_jiffies) mod_timer(&qp->retrans_timer, - jiffies + qp->qp_timeout_jiffies); + jiffies + qp->timeout_jiffies); ret = -EAGAIN; goto done; diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index 62acf890af6c..fc22ff36fdea 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -253,7 +253,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, rxe_init_task(rxe, &qp->comp.task, qp, rxe_completer, "comp"); - qp->qp_timeout_jiffies = 0; /* Can't be set for UD/UC in modify_qp */ + qp->timeout_jiffies = 0; /* Can't be set for UD/UC in modify_qp */ if (init->qp_type == IB_QPT_RC) { timer_setup(&qp->rnr_nak_timer, rnr_nak_timer, 0); timer_setup(&qp->retrans_timer, retransmit_timer, 0); @@ -633,12 +633,12 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask, if (mask & IB_QP_TIMEOUT) { qp->attr.timeout = attr->timeout; if (attr->timeout == 0) { - qp->qp_timeout_jiffies = 0; + qp->timeout_jiffies = 0; } else { /* According to the spec, timeout = 4.096 * 2 ^ attr->timeout [us] */ int j = nsecs_to_jiffies(4096ULL << attr->timeout); - qp->qp_timeout_jiffies = j ? j : 1; + qp->timeout_jiffies = j ? j : 1; } } @@ -781,7 +781,7 @@ int rxe_qp_chk_destroy(struct rxe_qp *qp) void rxe_qp_destroy(struct rxe_qp *qp) { qp->valid = 0; - qp->qp_timeout_jiffies = 0; + qp->timeout_jiffies = 0; rxe_cleanup_task(&qp->resp.task); if (qp_type(qp) == IB_QPT_RC) { diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index ae5fbc79dd5c..1884e3a64310 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -157,6 +157,7 @@ static struct rxe_send_wqe *req_next_wqe(struct rxe_qp *qp) return NULL; wqe = queue_addr_from_index(q, index); + WARN_ON((long)wqe & (L1_CACHE_BYTES - 1)); if (unlikely((qp->req.state == QP_STATE_DRAIN || qp->req.state == QP_STATE_DRAINED) && @@ -538,9 +539,9 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, qp->need_req_skb = 0; - if (qp->qp_timeout_jiffies && !timer_pending(&qp->retrans_timer)) + if (qp->timeout_jiffies && !timer_pending(&qp->retrans_timer)) mod_timer(&qp->retrans_timer, - jiffies + qp->qp_timeout_jiffies); + jiffies + qp->timeout_jiffies); } static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index e7eff1ca75e9..83b6f80440d8 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -249,11 +249,11 @@ struct rxe_qp { * started. The responder resets it whenever an ack is * received. */ - struct timer_list retrans_timer; - u64 qp_timeout_jiffies; + struct timer_list retrans_timer; + u64 timeout_jiffies; /* Timer for handling RNR NAKS. */ - struct timer_list rnr_nak_timer; + struct timer_list rnr_nak_timer; spinlock_t state_lock; /* guard requester and completer */ From patchwork Sat May 14 03:04:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 12849679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FE9BC433F5 for ; Sat, 14 May 2022 03:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230232AbiENDI3 (ORCPT ); Fri, 13 May 2022 23:08:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbiENDI2 (ORCPT ); Fri, 13 May 2022 23:08:28 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489A1322799 for ; Fri, 13 May 2022 20:08:23 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-f16a3e0529so2448434fac.2 for ; Fri, 13 May 2022 20:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gqPXfeaRqfxlpT8MOv9ifZh9DcX4RBWAPF+Dv9bYlVY=; b=TxzfEV/F7k+EYfztg/YK9tp6MFWlQQzN9rfaRju++3/iuYx6ou2NhCwfS64aEEDCms DnDXECjuHTPapTOrZTbubqhst6wPGU7zSD1jRCHcfK8CP0f4bWbk6E5WLaeRxvRU4Kvq SDCzYqW2w53cviIdPDu0Agtpi743ckg1zwiHRvfvfC/VJMJpAgVGzOAToHRaUtcEmM1y cVQao4A3OXFrSQEii0XTe8xrI+xAAEQycD9DGz9F+J+KxkkuYshnsCxKGBclcgw0ECr4 UrVqhTdjs2nWoxRxzDsNRmZH4YxPReDCCeB/ensv2vn0MBC0L7tY00j3gOI6lYKh8y4Y cn0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gqPXfeaRqfxlpT8MOv9ifZh9DcX4RBWAPF+Dv9bYlVY=; b=ZAUhxHA96ykkKQ1Rr9GBpIsSDS8KuQlvRXuFvGc6C8GZFLIhCuXhCnOSMep5dVDs1Y lwmQuWx5hl/TuJgzTDZsGiru4w15F3mGBVKe+BsmJ4hT+6p0J1kzPIa8EoSVSOsgnXJ0 feSAbl5s6aEG6NSCuqm4fAac6X+Zu0XqpMl9aaXBVgAb7JDLZ3DPy94Oh7J8368kiZ5D KePTY/8EkBeldSThte/Pb9PUuW5vtbvKr1gKLVOEfSxXNfzetzuCn3hraZkPoc23AT0G 6RFtmFWgQlDIRQ/wEdNzNu0OBfnWA8VC1mBWXgye9sd/rWNYT9KJQozCbBbVs17FO7e7 xUxQ== X-Gm-Message-State: AOAM530yaduiiLqgR3BqMQYftdH635rEb/ndWH+xIx0c/4928y5m16xd NpZdojE8IJk8QQgihf0SqeE= X-Google-Smtp-Source: ABdhPJwrBGm3/YRwFWKt6u5IUl49YonWLRJS9BdjNT3gqPPTa/RWB0fLKMfcl2Od7w4/ztmcX8hC2g== X-Received: by 2002:a05:6870:240a:b0:de:7fcb:56c0 with SMTP id n10-20020a056870240a00b000de7fcb56c0mr4178137oap.8.1652497702686; Fri, 13 May 2022 20:08:22 -0700 (PDT) Received: from u-22.tx.rr.com (2603-8081-140c-1a00-0642-4ec7-2b63-14d6.res6.spectrum.com. [2603:8081:140c:1a00:642:4ec7:2b63:14d6]) by smtp.googlemail.com with ESMTPSA id h64-20020a9d2f46000000b0060603221262sm1691176otb.50.2022.05.13.20.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:08:22 -0700 (PDT) From: Bob Pearson To: jgg@nvidia.com, zyjzyj2000@gmail.com, tom@talpey.com, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-rc v2 2/4] RDMA/rxe: Add a pkt->mask bit for ack_req Date: Fri, 13 May 2022 22:04:36 -0500 Message-Id: <20220514030435.91155-3-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220514030435.91155-1-rpearsonhpe@gmail.com> References: <20220514030435.91155-1-rpearsonhpe@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Add a bit to pkt->mask indicating that the ackreq bit has been set in the current packet. Use this bit to condition setting the retransmit timer since a packet without the ackreq bit set will not generate a response. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_opcode.h | 1 + drivers/infiniband/sw/rxe/rxe_req.c | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_opcode.h b/drivers/infiniband/sw/rxe/rxe_opcode.h index 8f9aaaf260f2..629504245e98 100644 --- a/drivers/infiniband/sw/rxe/rxe_opcode.h +++ b/drivers/infiniband/sw/rxe/rxe_opcode.h @@ -80,6 +80,7 @@ enum rxe_hdr_mask { RXE_END_MASK = BIT(NUM_HDR_TYPES + 10), RXE_LOOPBACK_MASK = BIT(NUM_HDR_TYPES + 12), + RXE_ACK_REQ_MASK = BIT(NUM_HDR_TYPES + 13), RXE_READ_OR_ATOMIC_MASK = (RXE_READ_MASK | RXE_ATOMIC_MASK), RXE_WRITE_OR_SEND_MASK = (RXE_WRITE_MASK | RXE_SEND_MASK), diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 1884e3a64310..d15165e9319c 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -394,11 +394,13 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp, ack_req = ((pkt->mask & RXE_END_MASK) || (qp->req.noack_pkts++ > RXE_MAX_PKT_PER_ACK)); - if (ack_req) + if (ack_req) { qp->req.noack_pkts = 0; + pkt->mask |= RXE_ACK_REQ_MASK; + } - bth_init(pkt, pkt->opcode, solicited, 0, pad, IB_DEFAULT_PKEY_FULL, qp_num, - ack_req, pkt->psn); + bth_init(pkt, pkt->opcode, solicited, 0, pad, IB_DEFAULT_PKEY_FULL, + qp_num, ack_req, pkt->psn); /* init optional headers */ if (pkt->mask & RXE_RETH_MASK) { @@ -539,7 +541,8 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, qp->need_req_skb = 0; - if (qp->timeout_jiffies && !timer_pending(&qp->retrans_timer)) + if ((pkt->mask & RXE_ACK_REQ_MASK) && qp->timeout_jiffies && + !timer_pending(&qp->retrans_timer)) mod_timer(&qp->retrans_timer, jiffies + qp->timeout_jiffies); } From patchwork Sat May 14 03:04:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 12849680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E5F0C433F5 for ; Sat, 14 May 2022 03:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230257AbiENDJY (ORCPT ); Fri, 13 May 2022 23:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbiENDJW (ORCPT ); Fri, 13 May 2022 23:09:22 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DC52332DF2 for ; Fri, 13 May 2022 20:09:20 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-d39f741ba0so12709637fac.13 for ; Fri, 13 May 2022 20:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FLYsPTf3mH4pLVB6koKRyPCBVVH6lTi57dBdJm9igvE=; b=dK2de0dlD5M61/vPU36dLGPnuz2n4n9bXwyn9zpA917p0PzXaDJXTwmjyrOPFifqXt MXPllpuxQHTy4tCSrjz6trkt8x/DXMh0SZPHxCqMXd/IsFSyA5XNbFWSZkySA6hA75Pb 7Hr7SaRY7ur751wWY+alE4Y5iYZ9vUtFWcQwmkmCwD6cMb5zD0mOXgC1N4hvR4lOF0a+ trme6ZsKX2Z/DF32TT2a0KXXYVxMRkiO4/NqYQdeZNPV1PhhUlQ67Dqc3984qjs9YXAp Kau97fmtC1MKijPWJO60MqGUvAfgrX2R1PHRHpxN+HQ5UHYOQQaktC/hPVlyotbukCwr I4KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FLYsPTf3mH4pLVB6koKRyPCBVVH6lTi57dBdJm9igvE=; b=UCenOCOErUlZ03iWRkCCqPRU6YKVTGqd80C/ZmULhhaGLK44sDr4xW7YlaXUV5Beu4 Epvj1ZGr0lC7fjLlSGKdp6qfPe+w/w4SX2uRRlK9WR4Zhvm1dUvnkaDzvq2PnrtGfEth qkG7lqtuZ78VXvFel54vCCSJbntkOTIEsmdez+FqF26FwnNN0T5mtJJtoaoPFusUWaqz wMVYadDVbP2l7M4YWiE7Hgrb/tUf31M7+79diwmsdyvXun4az26tfMRaocNSq+MEdkIV f6o/9ROYOmMAZFbE5Z9u80acadIFtQ36IkpRFuDfvmCEM344l9qfo7rmrA9Wr6BzqJqv kUkw== X-Gm-Message-State: AOAM533M9JdgCNc2/6eUBn4WbNmQJSLnr4ze9Smfr3wDgpJBto2vaqAp LhOMCf5TeKm+pifxFHCUcjAiOlfH9wQ= X-Google-Smtp-Source: ABdhPJymjLYI8crjRSzVqeo65J96EY97eCse5xpCsHE236JpPQYUaGTyCYCRdrVuxPOuPJbKbecFNg== X-Received: by 2002:a05:6870:7d08:b0:ee:7028:8829 with SMTP id os8-20020a0568707d0800b000ee70288829mr9581630oab.106.1652497759618; Fri, 13 May 2022 20:09:19 -0700 (PDT) Received: from u-22.tx.rr.com (2603-8081-140c-1a00-0642-4ec7-2b63-14d6.res6.spectrum.com. [2603:8081:140c:1a00:642:4ec7:2b63:14d6]) by smtp.googlemail.com with ESMTPSA id h64-20020a9d2f46000000b0060603221262sm1691176otb.50.2022.05.13.20.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:09:19 -0700 (PDT) From: Bob Pearson To: jgg@nvidia.com, zyjzyj2000@gmail.com, tom@talpey.com, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-rc v2 3/4] RDMA/rxe: Fix rnr retry behavior Date: Fri, 13 May 2022 22:04:38 -0500 Message-Id: <20220514030435.91155-4-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220514030435.91155-1-rpearsonhpe@gmail.com> References: <20220514030435.91155-1-rpearsonhpe@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Currently the completer tasklet when it sets the retransmit timer or the rnr timer sets the same flag (qp->req.need_retry) so that if either timer fires it will attempt to perform a retry flow on the send queue. This has the effect of responding to an RNR NAK at the first retransmit timer event which might not allow for the requested rnr timeout. This patch adds a new flag (qp->req.wait_for_rnr_timer) which, if set, prevents a retry flow until the rnr nak timer fires. This patch fixes rnr retry errors which can be observed by running the pyverbs test_rdmacm_async_traffic_external_qp multiple times. With this patch applied they do not occur. Link: https://lore.kernel.org/linux-rdma/a8287823-1408-4273-bc22-99a0678db640@gmail.com/ Link: https://lore.kernel.org/linux-rdma/2bafda9e-2bb6-186d-12a1-179e8f6a2678@talpey.com/ Fixes: 8700e3e7c485 ("Soft RoCE (RXE) - The software RoCE driver") Signed-off-by: Bob Pearson --- v2 Added comments and changed the name of the new flag to make things more understandable per an email exchange with Tom Talpey. --- drivers/infiniband/sw/rxe/rxe_comp.c | 8 +++++++- drivers/infiniband/sw/rxe/rxe_qp.c | 1 + drivers/infiniband/sw/rxe/rxe_req.c | 15 +++++++++++++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index badd423966dc..3c77201c01d1 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -114,6 +114,8 @@ void retransmit_timer(struct timer_list *t) { struct rxe_qp *qp = from_timer(qp, t, retrans_timer); + pr_debug("%s: fired for qp#%d\n", __func__, qp->elem.index); + if (qp->valid) { qp->comp.timeout = 1; rxe_run_task(&qp->comp.task, 1); @@ -729,11 +731,15 @@ int rxe_completer(void *arg) break; case COMPST_RNR_RETRY: + /* we come here if we received an RNR NAK */ if (qp->comp.rnr_retry > 0) { if (qp->comp.rnr_retry != 7) qp->comp.rnr_retry--; - qp->req.need_retry = 1; + /* don't start a retry flow until the + * rnr timer has fired + */ + qp->req.wait_for_rnr_timer = 1; pr_debug("qp#%d set rnr nak timer\n", qp_num(qp)); mod_timer(&qp->rnr_nak_timer, diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index fc22ff36fdea..2f6f378a232d 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -513,6 +513,7 @@ static void rxe_qp_reset(struct rxe_qp *qp) atomic_set(&qp->ssn, 0); qp->req.opcode = -1; qp->req.need_retry = 0; + qp->req.wait_for_rnr_timer = 0; qp->req.noack_pkts = 0; qp->resp.msn = 0; qp->resp.opcode = -1; diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index d15165e9319c..aa9066ff5257 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -103,7 +103,11 @@ void rnr_nak_timer(struct timer_list *t) { struct rxe_qp *qp = from_timer(qp, t, rnr_nak_timer); - pr_debug("qp#%d rnr nak timer fired\n", qp_num(qp)); + pr_debug("%s: fired for qp#%d\n", __func__, qp_num(qp)); + + /* request a send queue retry */ + qp->req.need_retry = 1; + qp->req.wait_for_rnr_timer = 0; rxe_run_task(&qp->req.task, 1); } @@ -628,10 +632,17 @@ int rxe_requester(void *arg) qp->req.need_rd_atomic = 0; qp->req.wait_psn = 0; qp->req.need_retry = 0; + qp->req.wait_for_rnr_timer = 0; goto exit; } - if (unlikely(qp->req.need_retry)) { + /* we come here if the retransmot timer has fired + * or if the rnr timer has fired. If the retransmit + * timer fires while we are processing an RNR NAK wait + * until the rnr timer has fired before starting the + * retry flow + */ + if (unlikely(qp->req.need_retry && !qp->req.wait_for_rnr_timer)) { req_retry(qp); qp->req.need_retry = 0; } diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index 83b6f80440d8..a6c6f0d786c7 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -123,6 +123,7 @@ struct rxe_req_info { int need_rd_atomic; int wait_psn; int need_retry; + int wait_for_rnr_timer; int noack_pkts; struct rxe_task task; }; From patchwork Sat May 14 03:04:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 12849681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1B9AC433F5 for ; Sat, 14 May 2022 03:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbiENDKy (ORCPT ); Fri, 13 May 2022 23:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbiENDKw (ORCPT ); Fri, 13 May 2022 23:10:52 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 227A233A27A for ; Fri, 13 May 2022 20:10:51 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id y63so12322383oia.7 for ; Fri, 13 May 2022 20:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NRENJ0bxgIqZBpmM5qNHMIVE3NOny+0esbBqnsG0aFA=; b=qB7jQY7AwkK82LmaVCd4lY4xCGu06NT9hCR0Wd5WfITv+2A6SFQac5L5yluIoNHfDd 1GT5GvbITbpSKIHeWfmwnnXEbJ2PspA/aaj8pTC9PL5R1hILfjTiYfn42PIRgmXfXFlO Xp/gV8jm45Ktfuwsy6qdqGOkNHY6oLrgEkqz6OgcihFKdkGc7Rf87cJn3EFGttgRuU9s 0KllgMNq/aTLvKoTLJKCxFtwEFuWWUhGDlESVye5i/UWvdJYZZ7NEjUv1/1SvW4s5O99 4mgxCWNzWJgQ7K3Fd2qo+cl+DLOJbg14RxWjYAjS/6H2EUcaWIzX5fZ4PugyTOE4Jpu9 NkmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NRENJ0bxgIqZBpmM5qNHMIVE3NOny+0esbBqnsG0aFA=; b=djavG1NxhMfgCV/RcndrigjrHZPJMpDqPHGba1AT7VOkBouZ68svqi73vmE8iYIdVj ccnuOns+UqzIuEipsTEz6miKQ8C+/Hd30Km/PeUhZuESC49Uxmm9DFeyLio8bb4Y6HbQ MG6zqEQ0kzCimZ+MEeLolB+Kz0+lhppfByinGeImkCXGsbA+VsEZ1ia/XJLSC3BcTQ9r kUJzHKLGjiLdpOGzz7rWdvTPcjLdHmt1P8WAuDS2eUFZGgNX36S/TdPhZYS0BfrMSgGX rvidDP36FDa33IA18buYix3Yzooa2zFoPqvOU+fLzkSkDL36a/zwyArdWcUO+Zubz/dq Xeqg== X-Gm-Message-State: AOAM5308Pa+EHw8WzpALlKSEx0QzLJGCu6UvYgt7HO1Kb96i9a1UDfTQ 2o22Ofi2Mm8IKcQmjT6V5W8= X-Google-Smtp-Source: ABdhPJyu4P/qf6oA87EjqQscDvT6zzrUh204HuGzFbguaIME5X1HpZ5ojdmGwheqwNHOC3ZoPqp94w== X-Received: by 2002:aca:f085:0:b0:328:c4cd:2b53 with SMTP id o127-20020acaf085000000b00328c4cd2b53mr5408519oih.197.1652497850465; Fri, 13 May 2022 20:10:50 -0700 (PDT) Received: from u-22.tx.rr.com (2603-8081-140c-1a00-0642-4ec7-2b63-14d6.res6.spectrum.com. [2603:8081:140c:1a00:642:4ec7:2b63:14d6]) by smtp.googlemail.com with ESMTPSA id h64-20020a9d2f46000000b0060603221262sm1691176otb.50.2022.05.13.20.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:10:50 -0700 (PDT) From: Bob Pearson To: jgg@nvidia.com, zyjzyj2000@gmail.com, tom@talpey.com, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-rc v2 4/4] RDMA/rxe: Reduce spurious retransmit timeouts Date: Fri, 13 May 2022 22:04:40 -0500 Message-Id: <20220514030435.91155-5-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220514030435.91155-1-rpearsonhpe@gmail.com> References: <20220514030435.91155-1-rpearsonhpe@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Currently the rxe driver sets a timer to handle response timeouts from lost packets or other failures. However this timer is never deleted so it will always fire in the period it was set for. Under heavy load this means that there will be retry flows attempted every few msec depending on the setting for retry timeout. This patch modifies the driver in several ways to reduce the number of spurious timeouts: - The psn of the current packet is saved when the timer is set for non-read requests and for read requests a psn in the expected response is saved. When a response packet is received by the completer tasklet that has a psn >= to the saved psn the timer is deleted. - As soon as there is no pending timer any new request will reset the timer. For long read replies the timer is reset as blocks of data arrive so that the response is covered by a timer. For typical heavy loads (e.g. ib_send_bw etc.) the number of retries is reduced from ~40 retries per second to one every several seconds. These are legitimate timeouts where the responder does not reply in the given time. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 50 ++++++++++++++++++--------- drivers/infiniband/sw/rxe/rxe_req.c | 26 ++++++++++++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 1 + 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index 3c77201c01d1..a8ef1f781a24 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -170,12 +170,44 @@ static inline void reset_retry_counters(struct rxe_qp *qp) qp->comp.started_retry = 0; } +static void update_retransmit_timer(struct rxe_qp *qp, + struct rxe_pkt_info *pkt, + struct rxe_send_wqe *wqe) +{ + /* reset the retry timer for long read responses + * if there is more data expected + */ + if ((pkt->opcode & 0x1f) == IB_OPCODE_RDMA_READ_REQUEST) { + int psn = (pkt->psn + RXE_MAX_PKT_PER_ACK) & 0xffffff; + + if (psn_compare(psn, wqe->last_psn) > 0) + psn = wqe->last_psn; + + if (psn_compare(psn, pkt->psn) > 0) { + atomic_set(&qp->timeout_psn, psn); + mod_timer(&qp->retrans_timer, + jiffies + qp->timeout_jiffies); + return; + } + } + + /* else just delete the timer */ + del_timer_sync(&qp->retrans_timer); +} + static inline enum comp_state check_psn(struct rxe_qp *qp, struct rxe_pkt_info *pkt, struct rxe_send_wqe *wqe) { s32 diff; + /* if this packet psn matches or exceeds the request that set the + * retry timer update the timer. + */ + if ((psn_compare(pkt->psn, atomic_read(&qp->timeout_psn)) >= 0) && + timer_pending(&qp->retrans_timer)) + update_retransmit_timer(qp, pkt, wqe); + /* check to see if response is past the oldest WQE. if it is, complete * send/write or error read/atomic */ @@ -663,20 +695,6 @@ int rxe_completer(void *arg) break; } - /* re reset the timeout counter if - * (1) QP is type RC - * (2) the QP is alive - * (3) there is a packet sent by the requester that - * might be acked (we still might get spurious - * timeouts but try to keep them as few as possible) - * (4) the timeout parameter is set - */ - if ((qp_type(qp) == IB_QPT_RC) && - (qp->req.state == QP_STATE_READY) && - (psn_compare(qp->req.psn, qp->comp.psn) > 0) && - qp->timeout_jiffies) - mod_timer(&qp->retrans_timer, - jiffies + qp->timeout_jiffies); ret = -EAGAIN; goto done; @@ -684,9 +702,7 @@ int rxe_completer(void *arg) /* we come here if the retry timer fired and we did * not receive a response packet. try to retry the send * queue if that makes sense and the limits have not - * been exceeded. remember that some timeouts are - * spurious since we do not reset the timer but kick - * it down the road or let it expire + * been exceeded. */ /* there is nothing to retry in this case */ diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index aa9066ff5257..5e031661bc49 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -397,7 +397,9 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp, qp->attr.dest_qp_num; ack_req = ((pkt->mask & RXE_END_MASK) || - (qp->req.noack_pkts++ > RXE_MAX_PKT_PER_ACK)); + (qp->req.noack_pkts++ > RXE_MAX_PKT_PER_ACK) || + (qp->timeout_jiffies && + !timer_pending(&qp->retrans_timer))); if (ack_req) { qp->req.noack_pkts = 0; pkt->mask |= RXE_ACK_REQ_MASK; @@ -545,10 +547,28 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, qp->need_req_skb = 0; - if ((pkt->mask & RXE_ACK_REQ_MASK) && qp->timeout_jiffies && - !timer_pending(&qp->retrans_timer)) + /* reset the retry timer if the packet has the ackreq bit set, + * we are using the retry timer and there is no timer set + * currently + */ + if (pkt->mask & RXE_ACK_REQ_MASK && qp->timeout_jiffies && + !timer_pending(&qp->retrans_timer)) { + int psn = pkt->psn; + + /* for read ops delay matching psn by RXE_MAX_PKT_PER_ACK + * up to the last psn. The completer will also reset the + * retry timer as required + */ + if ((pkt->opcode & 0x1f) == IB_OPCODE_RDMA_READ_REQUEST) { + psn = (psn + RXE_MAX_PKT_PER_ACK) & 0xffffff; + if (psn_compare(psn, wqe->last_psn) > 0) + psn = wqe->last_psn; + } + + atomic_set(&qp->timeout_psn, psn); mod_timer(&qp->retrans_timer, jiffies + qp->timeout_jiffies); + } } static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index a6c6f0d786c7..c41092d790f0 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -252,6 +252,7 @@ struct rxe_qp { */ struct timer_list retrans_timer; u64 timeout_jiffies; + atomic_t timeout_psn; /* Timer for handling RNR NAKS. */ struct timer_list rnr_nak_timer;