From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795989936; b=FeEmZvHeHIM02niaWzih7x5wWNy9cGgzBRY+Vx9+sFKggu5CTnY1SUMYKVuluVP56kTB ahVlCVU9SWdwq/BbsvTOapYPBn0Vt5nXh7tAM2JOH86BuqHb0D2LwFAx5sf+vNDYM7UxZ bddogU0GW9tdObzqo7umCLbxytMZAnye/5Klm76fO5xLf1V1SHDFXl5+fDow+nOgmMaqw /FW8ldfT+tUIf6vDS2z2jg3t1Fl7LWnXxoT7sJiV5706stHtaZj35P2aUr1blgqL7MUi7 seGmuT8yCo2HqmeYTbXUufbK7hvGT0sKBg3NqL5S4OixAStpQTZADg989bLENQTt2Iw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795989936; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:Content-Transfer-Encoding:User-Agent:MIME-Version; bh=XxtTA0Krgl/jryN5J2dzmwCRI/8NqhT9kCj3KIQV4tQ=; b=G9OG2ue+2A6NJ/Yxd+3evoodznWQTb6/lb0e9qP8R7UUeyIWGB7HUlPVSeb1LdatPbtZ pKDtsehrjx0QXLPMaxx+T98oBzHsRtwS4OnSImauOS/ykC8sbxvOGSQwJ+3WJHePN/eld QmMisnpeDMfwFucFgoxt6TTgj0y942oGBjEzvuUxt2ZuZ5Dhn8e+M4wanzgqrLFRm4yZt U+rP1FkJmWkm1zUJn1btEHXAiRslp7PIixZ9386IaUoVJQLa0A7k2g2Yfz7m1MndydUQS yWTYLJVlsjM5K8Wa8hzQmiRFLczxpAhkOMcKjffIghU6U89VbfwZrT8EjQUddIOmObg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uYQKMqq2; arc=none smtp.remote-ip=209.85.210.41 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CB96606A6A6 for ; Sun, 29 Nov 2026 22:05:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8CB96606A6A6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uYQKMqq2 Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-862a5b64755so5484492a34.2 for ; Sun, 29 Nov 2026 14:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795989929; x=1796594729; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=XxtTA0Krgl/jryN5J2dzmwCRI/8NqhT9kCj3KIQV4tQ=; b=uYQKMqq2i/uLIPG+9+fZnpiOSkAo94l9ZH3KbZEEkUkJ0kDIAXjoVmIb5bHFf0w2HG leixTAXOCoCo7qLFnURdlJD5ImqonqEWhhHWaMjKFiHWIV7Fr+6Y4uGcqXKkUZSLR7j5 J9Eyzh/8UFFB+3erq/UrgVVkSrrIt2659ZqNcDdoI/8v7Ap9XS9oRESXFlmlhA9f543M HpFrd3c0NY5h14PZ6KtCOs9JNMQOriLfbVa+trMMLGmMZWsiSEK8LTRiTIuLgMkYKON1 UScwQ47twRsSROadZuqgxaxSHQaeOUTi39XcEyargFDP38gj7gZXWjBwCvVa3SLN1R2H iUgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795989929; x=1796594729; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XxtTA0Krgl/jryN5J2dzmwCRI/8NqhT9kCj3KIQV4tQ=; b=G0jIqYyDcUipZ7GtRxpv/yED2y+VA+Jwjxw04RBjD0OHzplE2uQU5sqX4LN6p/Kqbm 425dcwb74nAfbpFzvm6dfpjdkWDcKuX3IRhOLQ62+bYeR+2m0lni+V3J/kh44t/APNLL vt2lsOmivaZR+w1jwfbkbvwKqpShLWTnPcbfl9lys+DRQChcFRY6KBcj772nzkC/l8um 1Q8zZ9SBmc48ebpEsMold9n6Yc4g9zL1ek/OKlB+oX1lcYGEWi/pO8TXNVhzabqXzLcl U6qOkojRi/hAIFAjwbuDIa7YJp83abs4oMKtvIx78rMoYp117VwMwiPY0oMb7P4Ee/aD LooQ== X-Forwarded-Encrypted: i=1; AL+hErHMsQ4dcwXSPKGYcuDCAP6xz3sT9recdYpgOhRTOeGlk7xlojTNEeKllaeC/JubXhj8OhP+KL1hmwgBnGo=@vger.kernel.org X-Gm-Message-State: APuU4Z/LSzVvLHexRActxrDNWQhXEs+8Lr9ju77xaJbvY5MBj1uDhz/J GqCEwj4cAgLccWTHJhwPuA69ch5U7pECUaYD2YA+Rp6jrurZisc8LJw= X-Gm-Gg: AZFdTZdjAw6RQ1s00pE7AMQho2xi1QcIuzo4aL5zTktKupaHOrWK65XN9/vE2HoStiQ qV1TJJIt1rKAkm+97gJ2qbtjyaThTekRJllmB8kQPQPS5B4wdHyyGmww3kAfAh4MT8k9J5mDT1j MU44GdVCkknr98IUE5Z8ptFSRgy+Y5MTvMbgT1ceXldkWeDIXmQUmqs4TPDlAlUnQlgF2jD/6q8 pLz072aZSyiiY7FOYK4mzAtrbAhiHivwVnd8E2ngEA2rCWHClTQ9TtOqjYRjVsMEkMM06eCIRGX a789lmeA7xMxpyyTOLQ72tqpJdexm4MlVZhe+krJNvJAaJDiVR1Y8/usBqzJhxUz6aMRX8T39Uc PIcc90d4mgtRI2hny7l1E49ZO+QrzeyuyfkNgjCRAkhEEbqLpJh3LmqkL1dDZWVH8qB7WjGV+ha cfHs0DWnRc4aCIGwJfxKSsL70jkufMDDh4Jqi1ti99IcVm4v1Y3rRNDKEBBzZGDxATBON8Mi1lk U4dE1faAO8xLoRkoJWHXVzNnZsMnMJOX4jcef2Ypr5W6hnDEgY50sa5z8eh0hlxRZUJ2X1rxuFl oTt+PcgdsmQELkN13cDh+55ysapdbOuX3yXP15AD1Nb5Bx+DGOoM5KE6PSYOFnHJ3NwSkqZwl/4 i+mEJ938tm3cWLg2y0N7yALv1PEeckneuenwALxU6Gt3zdj5WjZFLqPP4HSlV9YsscoHhXaVRYN MQCsI4+IPNUJ1r X-Received: by 2002:a05:6830:442c:b0:862:b3fd:327f with SMTP id 46e09a7af769-863157869a3mr35655548a34.19.1795989929231; Sun, 29 Nov 2026 14:05:29 -0800 (PST) Received: from [192.168.75.157] (162-232-235-235.lightspeed.livnmi.sbcglobal.net. [162.232.235.235]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-8639242b7eesm6333332a34.24.2026.11.29.14.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 14:05:28 -0800 (PST) Message-ID: Subject: Re: [PATCH 1/1] xprtrdma: Post small RPC Calls inline From: Trond Myklebust To: me@andrei-z.com Cc: anna@kernel.org, linux-nfs@vger.kernel.org, cel@kernel.org, jlayton@kernel.org, neil@brown.name, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, linux-kernel@vger.kernel.org Date: Sun, 29 Nov 2026 17:05:26 -0500 In-Reply-To: <20261015124826.2962950-2-me@andrei-z.com> References: <20261015124826.2962950-2-me@andrei-z.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.62.1 (3.62.1-1.fc45) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Thu, 15 Oct 2026 15:48:26 +0300, Andrei-Alexandru Bleortu wrote: > diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c > index 7e5713367291..9c0ef7303439 100644 > --- a/net/sunrpc/xprtrdma/rpc_rdma.c > +++ b/net/sunrpc/xprtrdma/rpc_rdma.c [ ... ] > +static void rpcrdma_prepare_send_inline(struct rpcrdma_xprt *r_xprt, > + struct rpcrdma_req *req) > +{ > + struct ib_sge *sge =3D req->rl_wr.sg_list; > + unsigned int len =3D 0; > + int i; > + > + if (req->rl_sendctx->sc_unmap_count) > + return; > + for (i =3D 0; i < req->rl_wr.num_sge; i++) > + len +=3D sge[i].length; > + if (len > r_xprt->rx_ep->re_attr.cap.max_inline_data) > + return; > + > + sge[0].addr =3D (uintptr_t)rdmab_data(req->rl_rdmabuf); > + if (req->rl_wr.num_sge > 1) > + sge[1].addr =3D (uintptr_t)rdmab_data(req->rl_sendbuf); > + req->rl_wr.send_flags |=3D IB_SEND_INLINE; > +} With this, every provider that reports a non-zero max_inline_data for a kernel QP starts receiving IB_SEND_INLINE Sends with two SGEs. Do the kernel inline paths in bnxt_re and hns deliver that payload intact? In bnxt_re, bnxt_re_copy_wr_payload() puts inline data only into wqe->inline_data and leaves wqe->sg_list[] as zeroed by bnxt_re_post_send(): drivers/infiniband/hw/bnxt_re/ib_verbs.c:bnxt_re_copy_wr_payload() { if (wr->send_flags & IB_SEND_INLINE) { rc =3D bnxt_re_copy_inline_data(rdev, wr, wqe); ... } else { *payload_sz =3D bnxt_re_build_sgl(wr->sg_list, wqe->sg_list, wqe->num_sge); } } but bnxt_qplib_post_send()->bnxt_qplib_put_inline() builds the WQE from wqe->sg_list[] only, and nothing reads wqe->inline_data any more: drivers/infiniband/hw/bnxt_re/qplib_fp.c:bnxt_qplib_put_inline() { for (indx =3D 0; indx < wqe->num_sge; indx++) { len =3D wqe->sg_list[indx].size; il_src =3D (void *)wqe->sg_list[indx].addr; t_len +=3D len; ... } So data_len is 0 and the Send goes out with sqe->length =3D 0. This dates from commit 2bb3c32c5c5f ("RDMA/bnxt_re: Change wr posting logic to accommodate variable wqes"). In static WQE mode (chips before P7) bnxt_re reports 96 bytes back to this probe. The NULL Call that rpc_ping() sends from rpc_create() uses AUTH_NULL and is 68 bytes with the transport header, and a CB_NULL reply on the backchannel is 52 bytes. Would an NFS/RDMA mount over these adapters fail at the ping? In variable WQE mode the reported size can also exceed the 96-byte wqe->inline_data[], and bnxt_re_copy_inline_data() then fails the post with -EINVAL, after which xprt_rdma_send_request() closes the connection. In hns, kernel QPs on HIP09 and later get HNS_ROCE_EXSGE_FLAGS, and update_inline_data() reports the extended SGE space as max_inline_data (512 bytes with 19 send SGEs). Any inline Send longer than 32 bytes goes through set_rc_inl()->fill_ext_sge_inl_data(), which advances the destination by the length of the next SGE instead of the one just copied: drivers/infiniband/hw/hns/hns_roce_hw_v2.c:fill_ext_sge_inl_data() { ... if (len <=3D left_len_in_pg) { memcpy(dseg, addr, len); idx +=3D len / HNS_ROCE_SGE_SIZE; i++; if (i >=3D wr->num_sge) break; left_len_in_pg -=3D len; len =3D wr->sg_list[i].length; addr =3D (void *)(unsigned long)(wr->sg_list[i].addr); dseg +=3D len; ... } For the same 68-byte NULL Call, the 40-byte RPC message lands 40 bytes into the extended SGE area instead of 28. The 68 bytes sent would then be the transport header, 12 stale bytes, and the first 28 bytes of the RPC message. This dates from commit 30b707886aeb ("RDMA/hns: Support inline data in extented sge space for RC"). The only existing in-kernel inline user, SMC, uses a single SGE and never asks bnxt_re for inline data, so neither path appears to have been exercised before, and the rxe test in the cover letter covers neither. Should this wait for fixes to those two drivers, or avoid IB_SEND_INLINE on providers whose kernel inline path hasn't been verified? [ ... ] > diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c > index 54957295a631..2e8a7fb6b1a6 100644 > --- a/net/sunrpc/xprtrdma/verbs.c > +++ b/net/sunrpc/xprtrdma/verbs.c [ ... ] > @@ -487,7 +528,22 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt) > goto out_destroy; > } > =20 > - rc =3D rdma_create_qp(id, ep->re_pd, &ep->re_attr); > + /* Ask for enough inline data to copy small Sends into the send > + * WQE (see rpcrdma_prepare_send_inline()), or for as much as the > + * device accepts. > + */ > + attr =3D ep->re_attr; > + inline_size =3D rpcrdma_inline_size(device->attrs.vendor_id, > + RPCRDMA_WQE_INLINE_SIZE, false); > + for (;;) { > + ep->re_attr =3D attr; > + ep->re_attr.cap.max_inline_data =3D inline_size; > + rc =3D rdma_create_qp(id, ep->re_pd, &ep->re_attr); > + if (!rc || !inline_size) > + break; > + inline_size =3D rpcrdma_inline_size(device->attrs.vendor_id, > + inline_size, true); > + } > if (rc) > goto out_destroy; Does this probe print an error for each refused size on every connect and reconnect? bnxt_re_create_qp()->bnxt_re_test_qp_limits() logs each refusal at KERN_ERR: drivers/infiniband/hw/bnxt_re/ib_verbs.c:bnxt_re_test_qp_limits() { init_attr->cap.max_inline_data > dev_attr->max_inline_data) { ibdev_err(&rdev->ibdev, "Create QP failed - max exceeded! ...", ... } With a static-mode limit of 6 * sizeof(struct sq_sge) =3D 96, stepping down from 256 produces ten of these lines per connect. qedr_check_qp_attrs() does the same with DP_ERR() on qedr iWARP devices, where qed_iwarp_init_devinfo() sets max_inline to 128 (eight lines), and ocrdma_check_qp_params() prints two pr_err() lines per refused size when its firmware limit is below 256. The loop also retries on any rdma_create_qp() error, so a failure caused by another attribute is repeated, along with its driver message, up to 17 times. Could the size that worked be remembered per device so that reconnects don't repeat the probe? Is the larger send queue on mlx4 expected? set_kernel_sq_size() sizes the send WQE for the requested inline data and then reports cap->max_inline_data =3D 0 for kernel QPs. With 64K pages (four send SGEs) the SQ stride grows from 128 to 512 bytes, though no Call is ever posted inline there. [ ... ] I've dropped this from my testing branch for now. On Thu, Oct 15, 2026 08:48 AM, Andrei-Alexandru Bleortu wrote: > rpcrdma_ep_create() asks for no inline data, so every RPC Call is > posted by reference. Before the HCA can transmit a Call it has to > DMA-read the transport header and the RPC message from host memory, > and for a small Call that read is on the latency path of every RPC. >=20 > Ask for 256 bytes of inline data per Send WR when creating the QP. If > the device refuses, ask for less. Intel irdma has a fixed limit of > 216, > 101 or 48 bytes, depending on the generation, and Alibaba erdma one > of > 96. On those devices, found by vendor ID, try these limits first, > then > step down 16 bytes at a time to none. libfabric's verbs provider also > probes the inline limit by trial QP creation. >=20 > Post a Call with IB_SEND_INLINE when its SGEs cover only the > persistently mapped transport header and head buffers and it fits in > the > granted size. Calls with page or tail SGEs, and larger Calls, are > posted > by reference as before. IB_SEND_INLINE is unrelated to the RPC-over- > RDMA > inline threshold. >=20 > Providers copy inline data from sg_list[].addr as a kernel virtual > address, so on the inline path the SGEs point at the regbufs' virtual > addresses. These SGEs are rebuilt for every Send and are not used for > unmapping: rpcrdma_sendctx_dma_unmap() starts at the third SGE, and > the > regbufs stay mapped. >=20 > fio ran 4 KiB direct I/O at queue depth 1 on an NFSv3 mount of a > tmpfs > export, between two Xeon Platinum 8360Y hosts with ConnectX-6 Dx over > RoCEv2 at 100 Gb/s on a 7.0 kernel. An earlier version of this patch > lowered the mean completion latency of random writes by 0.1923 us > (95% CI 0.1139-0.2769) and of random reads by 0.2705 us (0.1908- > 0.3502). > That version made the same check in frwr_send() and asked for 512 > bytes. The largest Call in those runs was 216 bytes. >=20 > Assisted-by: LLM > Signed-off-by: Andrei-Alexandru Bleortu > --- > =C2=A0net/sunrpc/xprtrdma/rpc_rdma.c | 30 ++++++++++++++++++ > =C2=A0net/sunrpc/xprtrdma/verbs.c=C2=A0 =C2=A0 | 58 > +++++++++++++++++++++++++++++++++- > =C2=A02 files changed, 87 insertions(+), 1 deletion(-) >=20 > diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c > b/net/sunrpc/xprtrdma/rpc_rdma.c > index 7e5713367291..9c0ef7303439 100644 > --- a/net/sunrpc/xprtrdma/rpc_rdma.c > +++ b/net/sunrpc/xprtrdma/rpc_rdma.c > @@ -732,6 +732,33 @@ static bool rpcrdma_prepare_readch(struct > rpcrdma_xprt *r_xprt, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 return true; > =C2=A0} >=20 > +/* Post a Send inline when its SGEs cover only the transport header > + * and head buffers and it fits in the granted inline size. The CPU > + * then copies it into the send WQE and the HCA does not DMA-read > it. > + * Inline data is copied from kernel virtual addresses, so point the > + * SGEs there. The buffers stay DMA-mapped and are not unmapped > + * through these SGEs. > + */ > +static void rpcrdma_prepare_send_inline(struct rpcrdma_xprt *r_xprt, > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct= rpcrdma_req *req) > +{ > +=C2=A0 =C2=A0 =C2=A0 =C2=A0struct ib_sge *sge =3D req->rl_wr.sg_list; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int len =3D 0; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0int i; > + > +=C2=A0 =C2=A0 =C2=A0 =C2=A0if (req->rl_sendctx->sc_unmap_count) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < req->rl_wr.num_sge; i++) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0len +=3D sge[i].l= ength; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0if (len > r_xprt->rx_ep->re_attr.cap.max_inli= ne_data) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return; > + > +=C2=A0 =C2=A0 =C2=A0 =C2=A0sge[0].addr =3D (uintptr_t)rdmab_data(req->rl= _rdmabuf); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0if (req->rl_wr.num_sge > 1) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sge[1].addr =3D (= uintptr_t)rdmab_data(req->rl_sendbuf); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0req->rl_wr.send_flags |=3D IB_SEND_INLINE; > +} > + > =C2=A0/** > =C2=A0 * rpcrdma_prepare_send_sges - Construct SGEs for a Send WR > =C2=A0 * @r_xprt: controlling transport > @@ -760,6 +787,7 @@ inline int rpcrdma_prepare_send_sges(struct > rpcrdma_xprt *r_xprt, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 req->rl_wr.sg_list =3D req->rl_sendctx->sc_sg= es; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 req->rl_wr.num_sge =3D 0; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 req->rl_wr.opcode =3D IB_WR_SEND; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0req->rl_wr.send_flags &=3D ~IB_SEND_INLINE; >=20 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 rpcrdma_prepare_hdr_sge(r_xprt, req, hdrlen); >=20 > @@ -783,6 +811,8 @@ inline int rpcrdma_prepare_send_sges(struct > rpcrdma_xprt *r_xprt, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto out_unmap; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 } >=20 > +=C2=A0 =C2=A0 =C2=A0 =C2=A0rpcrdma_prepare_send_inline(r_xprt, req); > + > =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* The Send-side owner releases this referenc= e when the > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* Send has completed. > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ > diff --git a/net/sunrpc/xprtrdma/verbs.c > b/net/sunrpc/xprtrdma/verbs.c > index 54957295a631..2e8a7fb6b1a6 100644 > --- a/net/sunrpc/xprtrdma/verbs.c > +++ b/net/sunrpc/xprtrdma/verbs.c > @@ -55,6 +55,7 @@ > =C2=A0#include > =C2=A0#include > =C2=A0#include > +#include >=20 > =C2=A0#include >=20 > @@ -63,6 +64,44 @@ > =C2=A0#include "xprt_rdma.h" > =C2=A0#include >=20 > +/* Bytes of inline data (IB_SEND_INLINE) to ask for on each Send WR. > + * This is unrelated to the RPC-over-RDMA inline threshold. > + */ > +#define RPCRDMA_WQE_INLINE_SIZE=C2=A0 =C2=A0 =C2=A0 =C2=A0 (256) > +#define RPCRDMA_WQE_INLINE_STEP=C2=A0 =C2=A0 =C2=A0 =C2=A0 (16) > + > +/* The verbs API cannot report a device's inline data limit. Some > + * drivers have a fixed one: Intel irdma 216, 101 or 48 depending on > + * the generation, Alibaba erdma 96. Try those first, by vendor ID, > + * then step down RPCRDMA_WQE_INLINE_STEP bytes at a time to zero. > + * libfabric's verbs provider also probes the limit > + * (vrb_find_max_inline()). > + */ > +static const struct { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0u32=C2=A0 =C2=A0 =C2=A0vendor_id; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0u32=C2=A0 =C2=A0 =C2=A0max_inline; > +} rpcrdma_inline_limits[] =3D { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0{ PCI_VENDOR_ID_INTEL, 216 }, > +=C2=A0 =C2=A0 =C2=A0 =C2=A0{ PCI_VENDOR_ID_INTEL, 101 }, > +=C2=A0 =C2=A0 =C2=A0 =C2=A0{ PCI_VENDOR_ID_INTEL, 48 }, > +=C2=A0 =C2=A0 =C2=A0 =C2=A0{ PCI_VENDOR_ID_ALIBABA, 96 }, > +}; > + > +/* Inline data size to ask for: on the first try, @size capped at > the > + * vendor's first known limit; after a refusal, the vendor's next > + * smaller known limit, else one step smaller. > + */ > +static u32 rpcrdma_inline_size(u32 vendor_id, u32 size, bool > refused) > +{ > +=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int i; > + > +=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < ARRAY_SIZE(rpcrdma_inline_l= imits); i++) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (rpcrdma_inlin= e_limits[i].vendor_id =3D=3D vendor_id > && > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(!r= efused || rpcrdma_inline_limits[i].max_inline > < size)) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0return > min(rpcrdma_inline_limits[i].max_inline, size); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0return refused ? size - min(size, RPCRDMA_WQE= _INLINE_STEP) : > size; > +} > + > =C2=A0static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt); > =C2=A0static void rpcrdma_sendctxs_destroy(struct rpcrdma_xprt *r_xprt); > =C2=A0static unsigned long rpcrdma_sendctx_next(struct rpcrdma_buffer > *buf, > @@ -392,8 +431,10 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt > *r_xprt) > =C2=A0{ > =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct rpcrdma_connect_private *pmsg; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct ib_device *device; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0struct ib_qp_init_attr attr; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct rdma_cm_id *id; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct rpcrdma_ep *ep; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 inline_size; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 int rc; >=20 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 ep =3D kzalloc_obj(*ep, XPRTRDMA_GFP_FLAGS); > @@ -487,7 +528,22 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt > *r_xprt) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto out_destroy; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 } >=20 > -=C2=A0 =C2=A0 =C2=A0 =C2=A0rc =3D rdma_create_qp(id, ep->re_pd, &ep->re_= attr); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0/* Ask for enough inline data to copy small S= ends into the > send > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 * WQE (see rpcrdma_prepare_send_inline()), o= r for as much as > the > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 * device accepts. > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 */ > +=C2=A0 =C2=A0 =C2=A0 =C2=A0attr =3D ep->re_attr; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0inline_size =3D rpcrdma_inline_size(device->a= ttrs.vendor_id, > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0RPCRDMA_WQE_INLINE_SIZE, > false); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0for (;;) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ep->re_attr =3D a= ttr; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ep->re_attr.cap.m= ax_inline_data =3D inline_size; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rc =3D rdma_creat= e_qp(id, ep->re_pd, &ep->re_attr); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!rc || !inlin= e_size) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0break; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0inline_size =3D r= pcrdma_inline_size(device- > >attrs.vendor_id, > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0inline_size, true); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0} > =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (rc) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto out_destroy; >=20 > --=20 > 2.56.0 >=20 >=20 --=20 Trond Myklebust Linux NFS client maintainer, Hammerspace trondmy@kernel.org, trond.myklebust@hammerspace.com