xprtrdma Send completion batching
Subsystems (4)
cover xprtrdma Send completion batching
Hi Jason, Sagi-
As we discussed a few weeks ago, this patch series implements the following:
- Send SGEs are now managed via lock-less, wait-free circular queues
- Send SGEs referring to page cache pages are DMA unmapped during Send completion
- Send completions are batched to reduce interrupts, but still provide a periodic heartbeat signal for SQ housekeeping
- The circular queue prevents Send Queue overflow
The purpose of this change is to address the issue Sagi reported where the HCA continues to retry a delayed Send request _after_ RPC completion, resulting in a DMA error.
Also available as the first five commits in this topic branch:
http://git.linux-nfs.org/?p=cel/cel-2.6.git;a=shortlog;h=refs/heads/nfs-rdma-for-4.15
---
Chuck Lever (5):
xprtrdma: Clean up SGE accounting in rpcrdma_prepare_msg_sges()
xprtrdma: Change return value of rpcrdma_prepare_send_sges()
xprtrdma: Add data structure to manage RDMA Send arguments
xprtrdma: Manage RDMA Send arguments via lock-free circular queue
xprtrdma: Remove atomic send completion counting
net/sunrpc/xprtrdma/backchannel.c | 6 + net/sunrpc/xprtrdma/frwr_ops.c | 8 - net/sunrpc/xprtrdma/rpc_rdma.c | 104 +++++++++++------- net/sunrpc/xprtrdma/transport.c | 6 + net/sunrpc/xprtrdma/verbs.c | 210 +++++++++++++++++++++++++++++++++++-- net/sunrpc/xprtrdma/xprt_rdma.h | 66 +++++++----- 6 files changed, 308 insertions(+), 92 deletions(-)
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 1/5 xprtrdma: Clean up SGE accounting in rpcrdma_prepare_msg_sges()
rpcrdma_prepare_hdr_sges() sets num_sge to one, then rpcrdma_prepare_msg_sges() sets num_sge again to the count of SGEs it added, plus one for the header SGE just mapped in rpcrdma_prepare_hdr_sges().
Let's just add the number we mapped, instead of setting num_sge again. The behavior should be the same, but the code is slightly clearer and less likely to break due to unrelated changes.
Similarly, simplify mapped SGE counting by just adding the running count of SGEs before returning.
--- net/sunrpc/xprtrdma/rpc_rdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/sunrpc/xprtrdma/rpc_rdma.c +2 -3
@@ -607,7 +607,6 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, sge[sge_no].length = len; sge[sge_no].lkey = lkey; - req->rl_mapped_sges++; ppages++; remaining -= len; page_base =0 ;
@@ -633,11 +632,11 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, goto out_mapping_err; sge[sge_no].length = len; sge[sge_no].lkey = lkey; - req->rl_mapped_sges++; } out: - req->rl_send_wr.num_sge = sge_no +1 ; + req->rl_send_wr.num_sge += sge_no; + req->rl_mapped_sges += sge_no -1 ;return true; out_mapping_overflow:
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 2/5 xprtrdma: Change return value of rpcrdma_prepare_send_sges()
In reply to Chuck LeverClean up: Make rpcrdma_prepare_send_sges() return a negative errno instead of a bool. Soon callers will want distinct treatments of different types of failures.
--- net/sunrpc/xprtrdma/backchannel.c | 6 +++- net/sunrpc/xprtrdma/rpc_rdma.c | 52 +++++++++++++++++++++++-------------- net/sunrpc/xprtrdma/xprt_rdma.h | 6 +++- 3 files changed, 40 insertions(+), 24 deletions(-)
net/sunrpc/xprtrdma/backchannel.c +4 -2
@@ -206,6 +206,7 @@ int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst)struct rpcrdma_xprt *r_xprt =rpcx_to_rdmax (rqst->rq_xprt);struct rpcrdma_req *req =rpcr_to_rdmar (rqst);__be32 *p; +int rc;rpcrdma_set_xdrlen (&req->rl_hdrbuf,0 ); xdr_init_encode(&req->rl_stream, &req->rl_hdrbuf,
@@ -222,8 +223,9 @@ int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst) *p++ = xdr_zero; *p = xdr_zero; -if (!rpcrdma_prepare_send_sges (&r_xprt->rx_ia, req,RPCRDMA_HDRLEN_MIN , - &rqst->rq_snd_buf, rpcrdma_noch)) + rc =rpcrdma_prepare_send_sges (r_xprt, req,RPCRDMA_HDRLEN_MIN , + &rqst->rq_snd_buf, rpcrdma_noch); +if (rc)return -EIO ;return 0 ; }
net/sunrpc/xprtrdma/rpc_rdma.c +32 -20
96 lines not on this page · raw message
net/sunrpc/xprtrdma/xprt_rdma.h +4 -2
@@ -640,8 +640,10 @@ enum rpcrdma_chunktype { rpcrdma_replych }; -bool rpcrdma_prepare_send_sges (struct rpcrdma_ia *,struct rpcrdma_req *, -u32 ,struct xdr_buf *,enum rpcrdma_chunktype ); +int rpcrdma_prepare_send_sges (struct rpcrdma_xprt *r_xprt, +struct rpcrdma_req *req,u32 hdrlen, +struct xdr_buf *xdr, +enum rpcrdma_chunktype rtype);void rpcrdma_unmap_sges (struct rpcrdma_ia *,struct rpcrdma_req *);int rpcrdma_marshal_req (struct rpcrdma_xprt *r_xprt,struct rpc_rqst *rqst);void rpcrdma_set_max_header_sizes (struct rpcrdma_xprt *);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 3/5 xprtrdma: Add data structure to manage RDMA Send arguments
In reply to Chuck LeverRecently Sagi Grimberg <[email protected]> observed that kernel RDMA- enabled storage initiators don't handle delayed Send completion
correctly. If Send completion is delayed beyond the end of a ULP
transaction, the ULP may release resources that are still being used
by the HCA to complete a long-running Send operation.
This is a common design trait amongst our initiators. Most Send operations are faster than the ULP transaction they are part of. Waiting for a completion for these is typically unnecessary.
Infrequently, a network partition or some other problem crops up where an ordering problem can occur. In this case, the HCA can try to use memory that has been invalidated or DMA unmapped, and the connection is lost.
Thus we cannot assume that it is safe to release Send-related resources just because a ULP reply has arrived.
After some analysis, we have determined that the completion housekeeping will not be difficult for xprtrdma:
- Inline Send buffers are registered via the local DMA key, and are already left DMA mapped for the lifetime of a transport connection, thus no additional handling is necessary for those
- Gathered Sends involving page cache pages _will_ need to DMA unmap those pages after the Send completes. But like inline send buffers, they are registered via the local DMA key, and thus will not need to be invalidated
In this patch, the rpcrdma_sendctx object is introduced, and a lock-free circular queue is added to manage a set of them per transport.
The RPC client's send path already prevents sending more than one RPC Call at the same time. This allows us to treat the consumer side of the queue (rpcrdma_sendctx_get_locked) as if there is a single consumer thread.
The producer side of the queue (rpcrdma_sendctx_put_locked) is invoked only from the Send completion handler, which is a single thread of execution (soft IRQ).
The only care that needs to be taken is with the tail index, which is shared between the producer and consumer. Only the producer updates the tail index. The consumer compares the head with the tail to ensure that the a sendctx that is in use is never handed out again (or, more conventionally, the queue is empty).
When the sendctx queue empties completely, there are enough Sends outstanding that posting more Send operations can result in a provider Send queue overflow. In this case, the ULP is told to wait and try again.
As a final touch, Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> suggested a mechanism that does not require signaling every Send.
We signal once every N Sends, and SGE unmapping of N Send operations
during that one completion.
--- net/sunrpc/xprtrdma/rpc_rdma.c | 25 +++++ net/sunrpc/xprtrdma/transport.c | 5 + net/sunrpc/xprtrdma/verbs.c | 178 +++++++++++++++++++++++++++++++++++++++ net/sunrpc/xprtrdma/xprt_rdma.h | 33 +++++++ 4 files changed, 239 insertions(+), 2 deletions(-)
net/sunrpc/xprtrdma/rpc_rdma.c +25 -0
@@ -699,6 +699,31 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, }/** +* rpcrdma_unmap_send_sges - DMA-unmap Send buffers +* @sc: send_ctx containing SGEs to unmap +* +* The first two SGEs are always left mapped. They contain the transport +* header and the inline buffer. +*/ +void +rpcrdma_unmap_send_sges (struct rpcrdma_sendctx *sc) +{ +struct ib_sge *sge; + +dprintk ("RPC: %s: unmapping %u sges for sc=%p\n" , + __func__, sc->sc_unmap_count, sc); + + sge = &sc->sc_sges[2 ]; +while (sc->sc_unmap_count) { +ib_dma_unmap_page (sc->sc_device, sge->addr, sge->length, +DMA_TO_DEVICE ); + ++sge; + --sc->sc_unmap_count; + } + sc->sc_wr.num_sge =0 ; +} + +/** * rpcrdma_marshal_req - Marshal and send one RPC request * @r_xprt: controlling transport * @rqst: RPC request to be marshaled
net/sunrpc/xprtrdma/transport.c +3 -2
@@ -790,11 +790,12 @@ void xprt_rdma_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) r_xprt->rx_stats.failed_marshal_count, r_xprt->rx_stats.bad_reply_count, r_xprt->rx_stats.nomsg_call_count); -seq_printf (seq,"%lu %lu %lu %lu\n" , +seq_printf (seq,"%lu %lu %lu %lu %lu\n" , r_xprt->rx_stats.mrs_recovered, r_xprt->rx_stats.mrs_orphaned, r_xprt->rx_stats.mrs_allocated, - r_xprt->rx_stats.local_inv_needed); + r_xprt->rx_stats.local_inv_needed, + r_xprt->rx_stats.empty_sendctx_q); } static int
net/sunrpc/xprtrdma/verbs.c +178 -0
208 lines not on this page · raw message
net/sunrpc/xprtrdma/xprt_rdma.h +33 -0
@@ -93,6 +93,8 @@ enum {*/ struct rpcrdma_ep { +unsigned int rep_send_count; +unsigned int rep_send_batch;atomic_t rep_cqcount;int rep_cqinit;int rep_connected;
@@ -229,6 +231,20 @@ struct rpcrdma_rep {struct ib_recv_wr rr_recv_wr; }; +/* struct rpcrdma_sendctx - DMA mapped SGEs to unmap after Send completes +*/ +struct rpcrdma_buffer ; +struct rpcrdma_sendctx { +struct ib_send_wr sc_wr; +struct ib_cqe sc_cqe; + +struct rpcrdma_buffer *sc_buffers; + +unsigned int sc_unmap_count; +struct ib_device *sc_device; +struct ib_sge sc_sges[]; +}; +/* * struct rpcrdma_mw - external memory region metadata *
@@ -337,6 +353,14 @@ enum { RPCRDMA_MAX_SEND_SGES = 1 + 1 + RPCRDMA_MAX_PAGE_SGES + 1, }; +/* Limit the number of SGEs that can be unmapped during one +* Send completion. This caps the amount of work a single +* completion can do before returning to the provider. +*/ +enum { +RPCRDMA_MAX_SEND_BATCH =16 , +}; +struct rpcrdma_buffer ;struct rpcrdma_req {struct list_head rl_list;
@@ -400,6 +424,11 @@ struct rpcrdma_buffer {struct list_head rb_mws;struct list_head rb_all; +unsigned long rb_sc_head; +unsigned long rb_sc_tail; +unsigned long rb_sc_last; +struct rpcrdma_sendctx **rb_sc_ctxs; +spinlock_t rb_lock;/* protect buf lists */ int rb_send_count, rb_recv_count;struct list_head rb_send_bufs;
@@ -455,6 +484,7 @@ struct rpcrdma_stats {unsigned long mrs_recovered;unsigned long mrs_orphaned;unsigned long mrs_allocated; +unsigned long empty_sendctx_q;/* accessed when receiving a reply */ unsigned long long total_rdma_reply;
@@ -556,6 +586,8 @@ int rpcrdma_ep_post(struct rpcrdma_ia *, struct rpcrdma_ep *,void rpcrdma_destroy_req (struct rpcrdma_req *);int rpcrdma_buffer_create (struct rpcrdma_xprt *);void rpcrdma_buffer_destroy (struct rpcrdma_buffer *); +struct rpcrdma_sendctx *rpcrdma_sendctx_get_locked (struct rpcrdma_buffer *buf); +void rpcrdma_sendctx_put_locked (struct rpcrdma_sendctx *sc);static inline void rpcrdma_insert_req (struct rpcrdma_buffer *buffers,struct rpcrdma_req *req)
@@ -645,6 +677,7 @@ int rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt,struct xdr_buf *xdr, enum rpcrdma_chunktype rtype);void rpcrdma_unmap_sges (struct rpcrdma_ia *,struct rpcrdma_req *); +void rpcrdma_unmap_send_sges (struct rpcrdma_sendctx *sc);int rpcrdma_marshal_req (struct rpcrdma_xprt *r_xprt,struct rpc_rqst *rqst);void rpcrdma_set_max_header_sizes (struct rpcrdma_xprt *);void rpcrdma_reply_handler (struct work_struct *work);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 4/5 xprtrdma: Manage RDMA Send arguments via lock-free circular queue
In reply to Chuck LeverHook rpcrdma_ep_post and the send completion handler up with the new send ctxs, and remove Send buffer DMA unmapping from xprt_rdma_free.
Care must be taken if an error occurs before the Send is posted. In this case, the send_ctx has to be popped back onto the circular queue, since it will never be completed or flushed. This is done before send_request's call allows another RPC Call to proceed.
--- net/sunrpc/xprtrdma/rpc_rdma.c | 40 +++++++++++++++------------------------ net/sunrpc/xprtrdma/transport.c | 1 - net/sunrpc/xprtrdma/verbs.c | 28 ++++++++++++++++++++------- net/sunrpc/xprtrdma/xprt_rdma.h | 6 +----- 4 files changed, 36 insertions(+), 39 deletions(-)
net/sunrpc/xprtrdma/rpc_rdma.c +15 -25
@@ -517,20 +517,20 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, rpcrdma_prepare_hdr_sge(struct rpcrdma_ia *ia, struct rpcrdma_req *req, u32 len) { + struct rpcrdma_sendctx *sc = req->rl_sendctx;struct rpcrdma_regbuf *rb = req->rl_rdmabuf; -struct ib_sge *sge = &req->rl_send_sge[0 ]; +struct ib_sge *sge = sc->sc_sges; -if (unlikely (!rpcrdma_regbuf_is_mapped (rb))) { +if (unlikely (!rpcrdma_regbuf_is_mapped (rb)))if (!__rpcrdma_dma_map_regbuf (ia, rb)) goto out_regbuf; - sge->addr =rdmab_addr (rb); - sge->lkey =rdmab_lkey (rb); - } + sge->addr =rdmab_addr (rb); + sge->lkey =rdmab_lkey (rb); sge->length = len;ib_dma_sync_single_for_device (rdmab_device (rb), sge->addr, sge->length,DMA_TO_DEVICE ); - req->rl_send_wr.num_sge++; + sc->sc_wr.num_sge++;return true; out_regbuf:
@@ -545,13 +545,16 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, struct xdr_buf *xdr, enum rpcrdma_chunktype rtype) { + struct rpcrdma_sendctx *sc = req->rl_sendctx;unsigned int sge_no, page_base, len, remaining;struct rpcrdma_regbuf *rb = req->rl_sendbuf;struct ib_device *device = ia->ri_device; -struct ib_sge *sge = req->rl_send_sge; +struct ib_sge *sge = sc->sc_sges;u32 lkey = ia->ri_pd->local_dma_lkey;struct page *page, **ppages; + sc->sc_device = device; +/* The head iovec is straightforward, as it is already * DMA-mapped. Sync the content that has changed. */
@@ -639,8 +642,8 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, } out: - req->rl_send_wr.num_sge += sge_no; - req->rl_mapped_sges += sge_no -1 ; + sc->sc_wr.num_sge += sge_no; + sc->sc_unmap_count += sge_no -1 ;return true; out_regbuf:
@@ -671,8 +674,9 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req, u32 hdrlen, struct xdr_buf *xdr, enum rpcrdma_chunktype rtype) { - req->rl_send_wr.num_sge = 0; - req->rl_mapped_sges =0 ; + req->rl_sendctx = rpcrdma_sendctx_get_locked(&r_xprt->rx_buf); +if (!req->rl_sendctx) +return -ENOBUFS ;if (!rpcrdma_prepare_hdr_sge (&r_xprt->rx_ia, req, hdrlen))return -EIO ;
@@ -684,20 +688,6 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt,return 0 ; } -void -rpcrdma_unmap_sges (struct rpcrdma_ia *ia,struct rpcrdma_req *req) -{ -struct ib_device *device = ia->ri_device; -struct ib_sge *sge; -int count; - - sge = &req->rl_send_sge[2 ]; -for (count = req->rl_mapped_sges; count--; sge++) -ib_dma_unmap_page (device, sge->addr, sge->length, -DMA_TO_DEVICE ); - req->rl_mapped_sges =0 ; -} -/** * rpcrdma_unmap_send_sges - DMA-unmap Send buffers * @sc: send_ctx containing SGEs to unmap
net/sunrpc/xprtrdma/transport.c +0 -1
@@ -688,7 +688,6 @@rpcrdma_remove_req (&r_xprt->rx_buf, req);if (!list_empty (&req->rl_registered)) ia->ri_ops->ro_unmap_safe (r_xprt, req, !RPC_IS_ASYNC (task)); -rpcrdma_unmap_sges (ia, req);rpcrdma_buffer_put (req); }
net/sunrpc/xprtrdma/verbs.c +20 -8
@@ -128,11 +128,17 @@static void rpcrdma_wc_send (struct ib_cq *cq,struct ib_wc *wc) { +struct ib_cqe *cqe = wc->wr_cqe; +struct rpcrdma_sendctx *sc = + container_of(cqe, struct rpcrdma_sendctx, sc_cqe); +/* WARNING: Only wr_cqe and status are reliable at this point */ if (wc->status !=IB_WC_SUCCESS && wc->status !=IB_WC_WR_FLUSH_ERR )pr_err ("rpcrdma: Send: %s (%u/0x%x)\n" ,ib_wc_status_msg (wc->status), wc->status, wc->vendor_err); + +rpcrdma_sendctx_put_locked (sc); }/* Perform basic sanity checking to avoid using garbage
@@ -1113,13 +1119,8 @@ struct rpcrdma_req *spin_lock (&buffer->rb_reqslock);list_add (&req->rl_all, &buffer->rb_allreqs);spin_unlock (&buffer->rb_reqslock); - req->rl_cqe.done = rpcrdma_wc_send; req->rl_buffer = &r_xprt->rx_buf;INIT_LIST_HEAD (&req->rl_registered); - req->rl_send_wr.next =NULL ; - req->rl_send_wr.wr_cqe = &req->rl_cqe; - req->rl_send_wr.sg_list = req->rl_send_sge; - req->rl_send_wr.opcode =IB_WR_SEND ;return req; }
@@ -1410,7 +1411,6 @@ struct rpcrdma_req *struct rpcrdma_buffer *buffers = req->rl_buffer;struct rpcrdma_rep *rep = req->rl_reply; - req->rl_send_wr.num_sge =0 ; req->rl_reply =NULL ;spin_lock (&buffers->rb_lock);
@@ -1542,7 +1542,7 @@ struct rpcrdma_regbuf *struct rpcrdma_ep *ep, struct rpcrdma_req *req) { - struct ib_send_wr *send_wr = &req->rl_send_wr; + struct ib_send_wr *send_wr = &req->rl_sendctx->sc_wr;struct ib_send_wr *send_wr_fail;int rc;
@@ -1556,10 +1556,22 @@ struct rpcrdma_regbuf *dprintk ("RPC: %s: posting %d s/g entries\n" , __func__, send_wr->num_sge); -rpcrdma_set_signaled (ep, send_wr); +/* Signal Send once every "rep_send_batch" WRs: +* - Mitigate interrupts due to Send completions +* - Batch up DMA unmapping send buffers +* - Allow verbs provider housekeeping on the Send Queue +*/ +if (ep->rep_send_count) { + send_wr->send_flags &= ~IB_SEND_SIGNALED ; + --ep->rep_send_count; + }else { + send_wr->send_flags |=IB_SEND_SIGNALED ; + ep->rep_send_count = ep->rep_send_batch; + } rc =ib_post_send (ia->ri_id->qp, send_wr, &send_wr_fail);if (rc) goto out_postsend_err; +return 0 ; out_postsend_err:
net/sunrpc/xprtrdma/xprt_rdma.h +1 -5
@@ -365,19 +365,16 @@ enum {struct rpcrdma_req {struct list_head rl_list;__be32 rl_xid; -unsigned int rl_mapped_sges;unsigned int rl_connect_cookie;struct rpcrdma_buffer *rl_buffer;struct rpcrdma_rep *rl_reply;struct xdr_stream rl_stream;struct xdr_buf rl_hdrbuf; -struct ib_send_wr rl_send_wr; -struct ib_sge rl_send_sge[RPCRDMA_MAX_SEND_SGES ]; +struct rpcrdma_sendctx *rl_sendctx;struct rpcrdma_regbuf *rl_rdmabuf;/* xprt header */ struct rpcrdma_regbuf *rl_sendbuf;/* rq_snd_buf */ struct rpcrdma_regbuf *rl_recvbuf;/* rq_rcv_buf */ -struct ib_cqe rl_cqe;struct list_head rl_all;bool rl_backchannel;
@@ -676,7 +673,6 @@ int rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req, u32 hdrlen, struct xdr_buf *xdr, enum rpcrdma_chunktype rtype); -void rpcrdma_unmap_sges (struct rpcrdma_ia *,struct rpcrdma_req *);void rpcrdma_unmap_send_sges (struct rpcrdma_sendctx *sc);int rpcrdma_marshal_req (struct rpcrdma_xprt *r_xprt,struct rpc_rqst *rqst);void rpcrdma_set_max_header_sizes (struct rpcrdma_xprt *);
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 5/5 xprtrdma: Remove atomic send completion counting
In reply to Chuck LeverVerbs providers require that a posted send has to be signaled every so often. This is because the providers perform send queue house- keeping during the send completion.
However, send completion batching now guarantees send operations are signaled often enough that managing a count of posted sends and signaling every so often is no longer necessary for xprtrdma.
--- net/sunrpc/xprtrdma/frwr_ops.c | 8 -------- net/sunrpc/xprtrdma/verbs.c | 4 ---- net/sunrpc/xprtrdma/xprt_rdma.h | 21 --------------------- 3 files changed, 33 deletions(-)
net/sunrpc/xprtrdma/frwr_ops.c +0 -8
@@ -419,7 +419,6 @@ IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE :IB_ACCESS_REMOTE_READ ; -rpcrdma_set_signaled (&r_xprt->rx_ep, ®_wr->wr); rc =ib_post_send (ia->ri_id->qp, ®_wr->wr, &bad_wr);if (rc) goto out_senderr;
@@ -507,12 +506,6 @@ f->fr_cqe.done = frwr_wc_localinv_wake;reinit_completion (&f->fr_linv_done); -/* Initialize CQ count, since there is always a signaled -* WR being posted here. The new cqcount depends on how -* many SQEs are about to be consumed. -*/ -rpcrdma_init_cqcount (&r_xprt->rx_ep, count); -/* Transport disconnect drains the receive CQ before it * replaces the QP. The RPC reply handler won't call us * unless ri_id->qp is a valid pointer.
@@ -545,7 +538,6 @@/* Find and reset the MRs in the LOCAL_INV WRs that did not * get posted. */ -rpcrdma_init_cqcount (&r_xprt->rx_ep, -count);while (bad_wr) { f = container_of(bad_wr, struct rpcrdma_frmr, fr_invwr);
net/sunrpc/xprtrdma/verbs.c +0 -4
@@ -575,10 +575,6 @@ ep->rep_send_batch = min_t(unsigned int, RPCRDMA_MAX_SEND_BATCH, cdata->max_requests >>2 ); ep->rep_send_count = ep->rep_send_batch; - ep->rep_cqinit = ep->rep_attr.cap.max_send_wr/2 -1 ; -if (ep->rep_cqinit <=2 ) - ep->rep_cqinit =0 ;/* always signal? */ -rpcrdma_init_cqcount (ep,0 );init_waitqueue_head (&ep->rep_connect_wait);INIT_DELAYED_WORK (&ep->rep_connect_worker, rpcrdma_connect_worker);
net/sunrpc/xprtrdma/xprt_rdma.h +0 -21
@@ -95,8 +95,6 @@ enum {struct rpcrdma_ep {unsigned int rep_send_count;unsigned int rep_send_batch; -atomic_t rep_cqcount; -int rep_cqinit;int rep_connected;struct ib_qp_init_attr rep_attr;wait_queue_head_t rep_connect_wait;
@@ -106,25 +104,6 @@ struct rpcrdma_ep {struct delayed_work rep_connect_worker; }; -static inline void -rpcrdma_init_cqcount (struct rpcrdma_ep *ep,int count) -{ -atomic_set (&ep->rep_cqcount, ep->rep_cqinit - count); -} - -/* To update send queue accounting, provider must take a -* send completion every now and then. -*/ -static inline void -rpcrdma_set_signaled (struct rpcrdma_ep *ep,struct ib_send_wr *send_wr) -{ - send_wr->send_flags =0 ; -if (unlikely (atomic_sub_return (1 , &ep->rep_cqcount) <=0 )) { -rpcrdma_init_cqcount (ep,0 ); - send_wr->send_flags =IB_SEND_SIGNALED ; - } -} -/* Pre-allocate extra Work Requests for handling backward receives * and sends. This is a fixed value because the Work Queues are * allocated when the forward channel is set up.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Chuck Lever
- Send completions are batched to reduce interrupts, but still provide a periodic heartbeat signal for SQ housekeeping
I would scrub this commentary, it is very misleading.
The idea of a periodic completion does not match how verbs works at all, it was an incomplete root cause analysis from a HCA that uses different rules for freeing space in the SQ.
Instead, I would say this series creates strong SQ accounting and properly guarentees the SQ can never overflow by only releasing SQ's back into the pool when the HCA has confirmed they are completed via a CQ.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Jason Gunthorpe
Quoted 2 lines · Chuck Lever
- Send completions are batched to reduce interrupts, but still provide a periodic heartbeat signal for SQ housekeeping
I would scrub this commentary, it is very misleading.
The idea of a periodic completion does not match how verbs works at all, it was an incomplete root cause analysis from a HCA that uses different rules for freeing space in the SQ.
I think it does bear mentioning that, given this diagnosis, it is still safe to remove the ib_post_send counting mechanism in 5/5, which has been in xprtrdma for as long as I can recall, and has been effective (with a few minor adjustments) at preventing SQ overflow.
I'm not able to test this change with every HCA the Linux kernel currently supports, unfortunately. The best I can do is offer a "proof of correctness" and hope that vendors will jump on this and try it out.
Quoted 4 lines
Instead, I would say this series creates strong SQ accounting and properly guarentees the SQ can never overflow by only releasing SQ's back into the pool when the HCA has confirmed they are completed via a CQ.
I will adjust the cover letter (and patch descriptions as necessary) next time I post this series. Thanks for your suggestions and review.
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC 4/5] xprtrdma: Manage RDMA Send arguments via lock-free circular queue
In reply to Chuck LeverQuoted 10 lines · Chuck Lever
Hook
rpcrdma_ep_postand the send completion handler up with the new send ctxs, and remove Send buffer DMA unmapping fromxprt_rdma_free.Care must be taken if an error occurs before the Send is posted. In this case, the
send_ctxhas to be popped back onto the circular queue, since it will never be completed or flushed. This is done before send_request's call allows another RPC Call to proceed.
This second paragraph is obsolete. Please ignore it.
Quoted 227 lines
Reported-by Sagi Grimberg <[email protected]>Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/xprtrdma/rpc_rdma.c | 40 +++++++++++++++------------------------ net/sunrpc/xprtrdma/transport.c | 1 - net/sunrpc/xprtrdma/verbs.c | 28 ++++++++++++++++++++------- net/sunrpc/xprtrdma/xprt_rdma.h | 6 +----- 4 files changed, 36 insertions(+), 39 deletions(-)net/sunrpc/xprtrdma/rpc_rdma.c +6
-6@@ -517,20 +517,20 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, rpcrdma_prepare_hdr_sge(struct rpcrdma_ia *ia, struct rpcrdma_req *req, u32 len) { + struct rpcrdma_sendctx *sc = req->rl_sendctx;struct rpcrdma_regbuf *rb = req->rl_rdmabuf; -struct ib_sge *sge = &req->rl_send_sge[0 ]; +struct ib_sge *sge = sc->sc_sges; -if (unlikely (!rpcrdma_regbuf_is_mapped (rb))) { +if (unlikely (!rpcrdma_regbuf_is_mapped (rb)))if (!__rpcrdma_dma_map_regbuf (ia, rb)) goto out_regbuf; - sge->addr =rdmab_addr (rb); - sge->lkey =rdmab_lkey (rb); - } + sge->addr =rdmab_addr (rb); + sge->lkey =rdmab_lkey (rb); sge->length = len;ib_dma_sync_single_for_device (rdmab_device (rb), sge->addr, sge->length,DMA_TO_DEVICE ); - req->rl_send_wr.num_sge++; + sc->sc_wr.num_sge++;return true;
out_regbuf:net/sunrpc/xprtrdma/rpc_rdma.c +4
-1@@ -545,13 +545,16 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, struct xdr_buf *xdr, enum rpcrdma_chunktype rtype) { + struct rpcrdma_sendctx *sc = req->rl_sendctx;unsigned int sge_no, page_base, len, remaining;struct rpcrdma_regbuf *rb = req->rl_sendbuf;struct ib_device *device = ia->ri_device; -struct ib_sge *sge = req->rl_send_sge; +struct ib_sge *sge = sc->sc_sges;u32 lkey = ia->ri_pd->local_dma_lkey;struct page *page, **ppages; + sc->sc_device = device; +/* The head iovec is straightforward, as it is already * DMA-mapped. Sync the content that has changed. */ @@ -639,8 +642,8 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, }out:
net/sunrpc/xprtrdma/rpc_rdma.c +2
-2- req->rl_send_wr.num_sge += sge_no; - req->rl_mapped_sges += sge_no -1 ; + sc->sc_wr.num_sge += sge_no; + sc->sc_unmap_count += sge_no -1 ;return true;
out_regbuf:net/sunrpc/xprtrdma/rpc_rdma.c +3
-16@@ -671,8 +674,9 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req, u32 hdrlen, struct xdr_buf *xdr, enum rpcrdma_chunktype rtype) { - req->rl_send_wr.num_sge = 0; - req->rl_mapped_sges =0 ; + req->rl_sendctx = rpcrdma_sendctx_get_locked(&r_xprt->rx_buf); +if (!req->rl_sendctx) +return -ENOBUFS ;if (!rpcrdma_prepare_hdr_sge (&r_xprt->rx_ia, req, hdrlen))return -EIO ;@@ -684,20 +688,6 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt,return 0 ; } -void -rpcrdma_unmap_sges (struct rpcrdma_ia *ia,struct rpcrdma_req *req) -{ -struct ib_device *device = ia->ri_device; -struct ib_sge *sge; -int count; - - sge = &req->rl_send_sge[2 ]; -for (count = req->rl_mapped_sges; count--; sge++) -ib_dma_unmap_page (device, sge->addr, sge->length, -DMA_TO_DEVICE ); - req->rl_mapped_sges =0 ; -} -/** * rpcrdma_unmap_send_sges - DMA-unmap Send buffers * @sc: send_ctx containing SGEs to unmap net/sunrpc/xprtrdma/transport.c +0
-1@@ -688,7 +688,6 @@rpcrdma_remove_req (&r_xprt->rx_buf, req);if (!list_empty (&req->rl_registered)) ia->ri_ops->ro_unmap_safe (r_xprt, req, !RPC_IS_ASYNC (task)); -rpcrdma_unmap_sges (ia, req);rpcrdma_buffer_put (req); }net/sunrpc/xprtrdma/verbs.c +0
-0@@ -128,11 +128,17 @@static void
rpcrdma_wc_send(struct ib_cq *cq, struct ib_wc *wc){net/sunrpc/xprtrdma/verbs.c +4
-0+struct ib_cqe *cqe = wc->wr_cqe; +struct rpcrdma_sendctx *sc = + container_of(cqe, struct rpcrdma_sendctx, sc_cqe); +/* WARNING: Only wr_cqe and status are reliable at this point */ if (wc->status != IB_WC_SUCCESS && wc->status != IB_WC_WR_FLUSH_ERR) pr_err("rpcrdma: Send: %s (%u/0x%x)\n", ib_wc_status_msg(wc->status), wc->status, wc->vendor_err);net/sunrpc/xprtrdma/verbs.c +2
-0+ +rpcrdma_sendctx_put_locked (sc);}
/* Perform basic sanity checking to avoid using garbage
net/sunrpc/xprtrdma/verbs.c +14
-8@@ -1113,13 +1119,8 @@ struct rpcrdma_req *spin_lock (&buffer->rb_reqslock);list_add (&req->rl_all, &buffer->rb_allreqs);spin_unlock (&buffer->rb_reqslock); - req->rl_cqe.done = rpcrdma_wc_send; req->rl_buffer = &r_xprt->rx_buf;INIT_LIST_HEAD (&req->rl_registered); - req->rl_send_wr.next =NULL ; - req->rl_send_wr.wr_cqe = &req->rl_cqe; - req->rl_send_wr.sg_list = req->rl_send_sge; - req->rl_send_wr.opcode =IB_WR_SEND ;return req; }@@ -1410,7 +1411,6 @@ struct rpcrdma_req *struct rpcrdma_buffer *buffers = req->rl_buffer;struct rpcrdma_rep *rep = req->rl_reply; - req->rl_send_wr.num_sge =0 ; req->rl_reply =NULL ;spin_lock (&buffers->rb_lock);@@ -1542,7 +1542,7 @@ struct rpcrdma_regbuf *struct rpcrdma_ep *ep, struct rpcrdma_req *req) { - struct ib_send_wr *send_wr = &req->rl_send_wr; + struct ib_send_wr *send_wr = &req->rl_sendctx->sc_wr;struct ib_send_wr *send_wr_fail;int rc;@@ -1556,10 +1556,22 @@ struct rpcrdma_regbuf *dprintk ("RPC: %s: posting %d s/g entries\n" , __func__, send_wr->num_sge); -rpcrdma_set_signaled (ep, send_wr); +/* Signal Send once every "rep_send_batch" WRs: +* - Mitigate interrupts due to Send completions +* - Batch up DMA unmapping send buffers +* - Allow verbs provider housekeeping on the Send Queue +*/ +if (ep->rep_send_count) { + send_wr->send_flags &= ~IB_SEND_SIGNALED ; + --ep->rep_send_count; + }else { + send_wr->send_flags |=IB_SEND_SIGNALED ; + ep->rep_send_count = ep->rep_send_batch; + } rc =ib_post_send (ia->ri_id->qp, send_wr, &send_wr_fail);if (rc) goto out_postsend_err; +return 0 ;
out_postsend_err:net/sunrpc/xprtrdma/xprt_rdma.h +1
-6@@ -365,19 +365,16 @@ enum {struct rpcrdma_req {struct list_head rl_list;__be32 rl_xid; -unsigned int rl_mapped_sges;unsigned int rl_connect_cookie;struct rpcrdma_buffer *rl_buffer;struct rpcrdma_rep *rl_reply;struct xdr_stream rl_stream;struct xdr_buf rl_hdrbuf; -struct ib_send_wr rl_send_wr; -struct ib_sge rl_send_sge[RPCRDMA_MAX_SEND_SGES ]; +struct rpcrdma_sendctx *rl_sendctx;struct rpcrdma_regbuf *rl_rdmabuf;/* xprt header */ struct rpcrdma_regbuf *rl_sendbuf;/* rq_snd_buf */ struct rpcrdma_regbuf *rl_recvbuf;/* rq_rcv_buf */ -struct ib_cqe rl_cqe;struct list_head rl_all;bool rl_backchannel;@@ -676,7 +673,6 @@ int rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req, u32 hdrlen, struct xdr_buf *xdr, enum rpcrdma_chunktype rtype); -void rpcrdma_unmap_sges (struct rpcrdma_ia *,struct rpcrdma_req *);void rpcrdma_unmap_send_sges (struct rpcrdma_sendctx *sc);int rpcrdma_marshal_req (struct rpcrdma_xprt *r_xprt,struct rpc_rqst *rqst);void rpcrdma_set_max_header_sizes (struct rpcrdma_xprt *); --
Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Chuck Lever
Quoted 13 lines · Jason Gunthorpe
Quoted 2 lines · Chuck Lever
- Send completions are batched to reduce interrupts, but still provide a periodic heartbeat signal for SQ housekeeping
I would scrub this commentary, it is very misleading.
The idea of a periodic completion does not match how verbs works at all, it was an incomplete root cause analysis from a HCA that uses different rules for freeing space in the SQ.
Quoted 5 lines
I think it does bear mentioning that, given this diagnosis, it is still safe to remove the
ib_post_sendcounting mechanism in 5/5, which has been in xprtrdma for as long as I can recall, and has been effective (with a few minor adjustments) at preventing SQ overflow.
Sure, but lets just talk about it in the context of ensuing the SQ does not go full, and not some nebulous idea of heartbeat.
The new approach directly prevents overflow, and the past failings in NFS all boiled down to stuffing SQEs into a full SQ, as some NICs do not 'empty' the SQ until the CQ is generated.
Quoted 4 lines
I'm not able to test this change with every HCA the Linux kernel currently supports, unfortunately. The best I can do is offer a "proof of correctness" and hope that vendors will jump on this and try it out.
Assuming it is implemented properly in NFS, any HCA that fails with this is broken by definition.. A HCA must work correctly if the SQ is full, and all but the last entry are unsignaled.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tom Talpey
reviewerQuoted 3 lines · Chuck Lever
I think it does bear mentioning that, given this diagnosis, it is still safe to remove the
ib_post_sendcounting mechanism in 5/5, which has been in xprtrdma for as long as I can recall, and has
2007. :-)
Quoted 7 lines
been effective (with a few minor adjustments) at preventing SQ overflow.
I'm not able to test this change with every HCA the Linux kernel currently supports, unfortunately. The best I can do is offer a "proof of correctness" and hope that vendors will jump on this and try it out.
Someday, a proper set of verbs test cases? Alas.
Tom.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line
Hi Jason, Sagi-
Hey Chuck,
Quoted 10 lines
As we discussed a few weeks ago, this patch series implements the following:
- Send SGEs are now managed via lock-less, wait-free circular queues
- Send SGEs referring to page cache pages are DMA unmapped during Send completion
- Send completions are batched to reduce interrupts, but still provide a periodic heartbeat signal for SQ housekeeping
- The circular queue prevents Send Queue overflow
Quoted 3 lines
The purpose of this change is to address the issue Sagi reported where the HCA continues to retry a delayed Send request _after_ RPC completion, resulting in a DMA error.
Question, what happens in direct-io for example? Can a mapped buffer be reclaimed/free'd before the send completion arrives?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 19 lines · Sagi Grimberg
Quoted 2 lines
Hi Jason, Sagi-
Hey Chuck,
Quoted 11 lines
As we discussed a few weeks ago, this patch series implements the following:
- Send SGEs are now managed via lock-less, wait-free circular queues
- Send SGEs referring to page cache pages are DMA unmapped during Send completion
- Send completions are batched to reduce interrupts, but still provide a periodic heartbeat signal for SQ housekeeping
- The circular queue prevents Send Queue overflow
The purpose of this change is to address the issue Sagi reported where the HCA continues to retry a delayed Send request _after_ RPC completion, resulting in a DMA error.
Quoted 2 lines
Question, what happens in direct-io for example? Can a mapped buffer be reclaimed/free'd before the send completion arrives?
Good Q! RPC completion allows memory containing the arguments and results to be re-used. IIRC our conclusion was that a retransmitted Send could expose the wrong argument data on the wire in this case.
Buffer re-use implies that the RPC has completed. Either a matching RPC Reply was received, or the RPC was terminated via a POSIX signal.
If the client has already received an RPC Reply for this transaction, a previous transmission of the RPC Call has already executed on the server, and this retransmission will be ignored. It's only purpose is to generate an appropriate RDMA ACK.
A re-used buffer might be subsequently used for data that is sensitive, and the retransmission will expose that data on the wire. To protect against that, RPC can use a GSS flavor that protects confidentiality of RPC arguments and results. This would also require RPC-over-RDMA to use only RDMA Read to convey RPC Call messages. Send would be used only to convey the chunk lists, never data.
Note that the buffers used to construct RPC Calls are always mapped and Send uses the local DMA key to post them. These can also be re-used immediately after RPC completion. The exposure risk there is of RPC headers and non-data arguments.
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 24 lines · Jason Gunthorpe
Quoted 14 lines · Chuck Lever
Quoted 13 lines · Jason Gunthorpe
Quoted 2 lines · Chuck Lever
- Send completions are batched to reduce interrupts, but still provide a periodic heartbeat signal for SQ housekeeping
I would scrub this commentary, it is very misleading.
The idea of a periodic completion does not match how verbs works at all, it was an incomplete root cause analysis from a HCA that uses different rules for freeing space in the SQ.
Quoted 5 lines
I think it does bear mentioning that, given this diagnosis, it is still safe to remove the
ib_post_sendcounting mechanism in 5/5, which has been in xprtrdma for as long as I can recall, and has been effective (with a few minor adjustments) at preventing SQ overflow.
Quoted 6 lines
Sure, but lets just talk about it in the context of ensuing the SQ does not go full, and not some nebulous idea of heartbeat.
The new approach directly prevents overflow, and the past failings in NFS all boiled down to stuffing SQEs into a full SQ, as some NICs do not 'empty' the SQ until the CQ is generated.
Understood. There are one or two code comments introduced by this series that will need to be similarly adjusted.
Quoted 10 lines
Quoted 4 lines
I'm not able to test this change with every HCA the Linux kernel currently supports, unfortunately. The best I can do is offer a "proof of correctness" and hope that vendors will jump on this and try it out.
Assuming it is implemented properly in NFS, any HCA that fails with this is broken by definition.. A HCA must work correctly if the SQ is full, and all but the last entry are unsignaled.
Jason
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines
Quoted 3 lines
Question, what happens in direct-io for example? Can a mapped buffer be reclaimed/free'd before the send completion arrives?
Good Q! RPC completion allows memory containing the arguments and results to be re-used. IIRC our conclusion was that a retransmitted Send could expose the wrong argument data on the wire in this case.
Buffer re-use implies that the RPC has completed. Either a matching RPC Reply was received, or the RPC was terminated via a POSIX signal.
Quoted 7 lines
If the client has already received an RPC Reply for this transaction, a previous transmission of the RPC Call has already executed on the server, and this retransmission will be ignored. It's only purpose is to generate an appropriate RDMA ACK.
A re-used buffer might be subsequently used for data that is sensitive, and the retransmission will expose that data on the wire.
That was where I was going with this...
Quoted 10 lines
To protect
against that, RPC can use a GSS flavor that protects confidentiality of RPC arguments and results. This would also require RPC-over-RDMA to use only RDMA Read to convey RPC Call messages. Send would be used only to convey the chunk lists, never data.Note that the buffers used to construct RPC Calls are always mapped and Send uses the local DMA key to post them. These can also be re-used immediately after RPC completion. The exposure risk there is of RPC headers and non-data arguments.
I see, but how can the user know that that it needs to use RPCSEC_GSS otherwise nfs/rdma might compromise sensitive data? And is this a valid constraint? (just asking, you're the expert)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 30 lines · Sagi Grimberg
Quoted 4 lines
Quoted 4 lines
Question, what happens in direct-io for example? Can a mapped buffer be reclaimed/free'd before the send completion arrives?
Quoted 11 lines
Good Q! RPC completion allows memory containing the arguments and results to be re-used. IIRC our conclusion was that a retransmitted Send could expose the wrong argument data on the wire in this case. Buffer re-use implies that the RPC has completed. Either a matching RPC Reply was received, or the RPC was terminated via a POSIX signal. If the client has already received an RPC Reply for this transaction, a previous transmission of the RPC Call has already executed on the server, and this retransmission will be ignored. It's only purpose is to generate an appropriate RDMA ACK.
A re-used buffer might be subsequently used for data that is sensitive, and the retransmission will expose that data on the wire.That was where I was going with this...
Quoted 9 lines
To protect
against that, RPC can use a GSS flavor that protects confidentiality of RPC arguments and results. This would also require RPC-over-RDMA to use only RDMA Read to convey RPC Call messages. Send would be used only to convey the chunk lists, never data.
Note that the buffers used to construct RPC Calls are always mapped and Send uses the local DMA key to post them. These can also be re-used immediately after RPC completion. The exposure risk there is of RPC headers and non-data arguments.
Quoted 3 lines
I see, but how can the user know that that it needs to use
RPCSEC_GSSotherwise nfs/rdma might compromise sensitive data? And is this a valid constraint? (just asking, you're the expert)
sec=krb5p is used in cases where data on the wire must remain confidential. Otherwise, sensitive or no, data on the wire goes in the clear.
But an administrator might not expect that other sensitive data on the client (not involved with NFS) can be placed on the wire by the vagaries of memory allocation and hardware retransmission, as exceptionally rare as that might be.
Memory in which Send data resides is donated to the device until the Send completion fires: the ULP has no way to get it back in the meantime. ULPs can invalidate memory used for RDMA Read at any time, but Send memory is registered with the local DMA key (as anything else is just as expensive as an RDMA data transfer).
The immediate solution is to never use Send to move file data directly. It will always have to be copied into a buffer or we use RDMA Read. These buffers contain only data that is destined for the wire. Does that close the unwanted exposure completely?
If the HCA can guarantee that all Sends complete quickly (either successful, flush, or time out after a few seconds) then it could be fair to make RPC completion also wait for Send completion. Otherwise, a ^C on a file operation targeting an unreachable server will hang indefinitely.
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines
Quoted 4 lines
I see, but how can the user know that that it needs to use
RPCSEC_GSSotherwise nfs/rdma might compromise sensitive data? And is this a valid constraint? (just asking, you're the expert)sec=krb5p is used in cases where data on the wire must remain confidential. Otherwise, sensitive or no, data on the wire goes in the clear.
But an administrator might not expect that other sensitive data on the client (not involved with NFS) can be placed on the wire by the vagaries of memory allocation and hardware retransmission, as exceptionally rare as that might be.
Memory in which Send data resides is donated to the device until the Send completion fires: the ULP has no way to get it back in the meantime. ULPs can invalidate memory used for RDMA Read at any time, but Send memory is registered with the local DMA key (as anything else is just as expensive as an RDMA data transfer).
Quoted 5 lines
The immediate solution is to never use Send to move file data directly. It will always have to be copied into a buffer or we use RDMA Read. These buffers contain only data that is destined for the wire. Does that close the unwanted exposure completely?
It would, but is that a smaller sacrifice than signaling send completions for small writes?
Quoted 5 lines
If the HCA can guarantee that all Sends complete quickly (either successful, flush, or time out after a few seconds) then it could be fair to make RPC completion also wait for Send completion. Otherwise, a ^C on a file operation targeting an unreachable server will hang indefinitely.
You could set retry_count=0/1 which will fail with zero or one send retries (a matter of seconds), but that would make the qp go to error state which is probably not what we want...
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · Sagi Grimberg
Quoted 17 lines
Quoted 5 lines
I see, but how can the user know that that it needs to use
RPCSEC_GSSotherwise nfs/rdma might compromise sensitive data? And is this a valid constraint? (just asking, you're the expert)sec=krb5p is used in cases where data on the wire must remain confidential. Otherwise, sensitive or no, data on the wire goes in the clear.
But an administrator might not expect that other sensitive data on the client (not involved with NFS) can be placed on the wire by the vagaries of memory allocation and hardware retransmission, as exceptionally rare as that might be.
Memory in which Send data resides is donated to the device until the Send completion fires: the ULP has no way to get it back in the meantime. ULPs can invalidate memory used for RDMA Read at any time, but Send memory is registered with the local DMA key (as anything else is just as expensive as an RDMA data transfer).
Quoted 8 lines
Quoted 5 lines
The immediate solution is to never use Send to move file data directly. It will always have to be copied into a buffer or we use RDMA Read. These buffers contain only data that is destined for the wire. Does that close the unwanted exposure completely?
It would, but is that a smaller sacrifice than signaling send completions for small writes?
Recall that if there's no file data, the transport will utilize a persistently registered and DMA mapped buffer that it owns in which to build the RPC Call message and post the Send.
If there is file data, the same buffer is used, but the memory containing the file data is DMA mapped and added to the Send SGE list.
With sendctx, every 16th Send [*] is signaled whether it is carrying extra SGEs that need to be unmapped, or not. All other Sends are not signaled. This guarantees correct Send Queue accounting for all workloads and registration modes, using a minimum number of completions.
During each Send completion, the handler walks through SGEs since the last completion, and unmaps them if needed.
If we choose never to do scatter-gather Send with file data, then this last step is unneeded because then only persistently registered and mapped buffers would be used for sending RPC Call messages.
But note that either mechanism results in the same Send completion rate.
[*] 16 is adjusted down to accommodate smaller Send Queues as needed.
Quoted 9 lines
Quoted 5 lines
If the HCA can guarantee that all Sends complete quickly (either successful, flush, or time out after a few seconds) then it could be fair to make RPC completion also wait for Send completion. Otherwise, a ^C on a file operation targeting an unreachable server will hang indefinitely.
You could set retry_count=0/1 which will fail with zero or one send retries (a matter of seconds), but that would make the qp go to error state which is probably not what we want...
I'm told that not letting the hardware try as hard as it can to transmit a Send is asking for data corruption. Thus the current setting is 6. That should cause a time out in less than a minute? It depends on the HCA I guess.
Dropping the connection is desirable to force a full reconnect (with address resolution) and to kick off another Send. It is not desirable because it will also interrupt all other outstanding RPCs on that connection.
As I see it, the options are to apply sendctx (this series), and then:
A. Remove the post-v4.6 scatter-gather code, or
B. Force RPC completion to wait for Send completion, which would allow the post-v4.6 scatter-gather code to work safely. This would need some guarantee that Sends will always complete in a short period.
For B, the signaling scheme would have to be: signal non-data-bearing Send every so often, but signal all data-bearing Sends. RPC completion would have to be able to tell the difference and wait as needed. I can probably handle this by adding a couple of atomic bits in struct rpcrdma_req.
A. seems like the more straightforward approach.
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Chuck Lever
B. Force RPC completion to wait for Send completion, which would allow the post-v4.6 scatter-gather code to work safely. This would need some guarantee that Sends will always complete in a short period.
Why is waiting for the send completion so fundamentally different from waiting for the remote RPC reply?
I would say that 99% of time the send completion and RPC reply completion will occure approximately concurrently.
eg It is quite likely the RPC reply SEND carries an embeded ack for the requesting SEND..
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Jason Gunthorpe
Quoted 4 lines · Chuck Lever
B. Force RPC completion to wait for Send completion, which would allow the post-v4.6 scatter-gather code to work safely. This would need some guarantee that Sends will always complete in a short period.
Quoted 8 lines
Why is waiting for the send completion so fundamentally different from waiting for the remote RPC reply?
I would say that 99% of time the send completion and RPC reply completion will occure approximately concurrently.
eg It is quite likely the RPC reply SEND carries an embeded ack for the requesting SEND..
Depends on implementation. Average RTT on IB is 3-5 usecs. Average RPC RTT is about an order of magnitude more. Typically the Send is ACK'd more quickly than the RPC Reply can be sent.
But I get your point: the normal case isn't a problem.
The problematic case arises when the Send is not able to complete because the NFS server is not reachable. User starts pounding on ^C, RPC can't complete because Send won't complete, control doesn't return to user.
The Send Queue is blocked in that case anyway. That should result in the sendctx queue becoming empty, so that RPCs can't even post another Send, and we avoid the problem with newly issued RPCs.
We really do prefer the mechanics of the transport to be detached from the ability of the RPC client and above to respond to user signals, IMO.
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 23 lines · Chuck Lever
Quoted 10 lines · Jason Gunthorpe
Quoted 4 lines · Chuck Lever
B. Force RPC completion to wait for Send completion, which would allow the post-v4.6 scatter-gather code to work safely. This would need some guarantee that Sends will always complete in a short period.
Quoted 8 lines
Why is waiting for the send completion so fundamentally different from waiting for the remote RPC reply?
I would say that 99% of time the send completion and RPC reply completion will occure approximately concurrently.
eg It is quite likely the RPC reply SEND carries an embeded ack for the requesting SEND..
Depends on implementation. Average RTT on IB is 3-5 usecs. Average RPC RTT is about an order of magnitude more. Typically the Send is ACK'd more quickly than the RPC Reply can be sent.
Quoted 6 lines
But I get your point: the normal case isn't a problem.
The problematic case arises when the Send is not able to complete because the NFS server is not reachable. User starts pounding on ^C, RPC can't complete because Send won't complete, control doesn't return to user.
Sure, but why is that so different from the NFS server not generating a response?
I thought you already implemetned a ctrl-c scheme that killed the QP? Or was that just a discussion?
That is the only way to async terminate outstanding RPCs and clean up. Killing the QP will allow the send to be 'completed'.
Having ctrl-c escalate to a QP tear down after a short timeout seems reasonable. 99% of cases will not need the teardown since the send will complete..
How does sockets based NFS handle this? Doesn't it zero copy from these same buffers into SKBs? How does it cancel the SKBs before the NIC transmits them?
Seems like exactly the same kind of problem to me..
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 34 lines · Jason Gunthorpe
Quoted 23 lines · Chuck Lever
Quoted 10 lines · Jason Gunthorpe
Quoted 4 lines · Chuck Lever
B. Force RPC completion to wait for Send completion, which would allow the post-v4.6 scatter-gather code to work safely. This would need some guarantee that Sends will always complete in a short period.
Quoted 8 lines
Why is waiting for the send completion so fundamentally different from waiting for the remote RPC reply?
I would say that 99% of time the send completion and RPC reply completion will occure approximately concurrently.
eg It is quite likely the RPC reply SEND carries an embeded ack for the requesting SEND..
Depends on implementation. Average RTT on IB is 3-5 usecs. Average RPC RTT is about an order of magnitude more. Typically the Send is ACK'd more quickly than the RPC Reply can be sent.
Quoted 6 lines
But I get your point: the normal case isn't a problem.
The problematic case arises when the Send is not able to complete because the NFS server is not reachable. User starts pounding on ^C, RPC can't complete because Send won't complete, control doesn't return to user.
Quoted 5 lines
Sure, but why is that so different from the NFS server not generating a response?
I thought you already implemetned a ctrl-c scheme that killed the QP? Or was that just a discussion?
No, we want to _avoid_ killing the QP if we can. A ctrl-C (or a timer signal, say) on an otherwise healthy connection must not perturb other outstanding RPCs, if possible.
What I implemented was a scheme to invalidate the memory of a (POSIX) signaled RPC before it completes, in case the RPC Reply hadn't yet arrived.
Currently, the only time the QP might be killed is if the server attempts to RDMA Write an RPC Reply into one of these invalidated memory regions. That case can't be avoided with the current RPC- over-RDMA protocol.
Quoted 2 lines
That is the only way to async terminate outstanding RPCs and clean up. Killing the QP will allow the send to be 'completed'.
It forces outstanding Sends to flush.
But as you explained it at the time, xprtrdma needs to wait somehow for the QP to complete it's transition to error state before allowing RPCs to complete. Probably ib_drain_qp would be enough.
And again, we want to preserve the connection if it is healthy.
Quoted 3 lines
Having ctrl-c escalate to a QP tear down after a short timeout seems reasonable. 99% of cases will not need the teardown since the send will complete..
So I think we are partially there already. If an RPC timeout occurs (which should be after a few minutes) then xprtrdma does disconnect, which tears down the QP.
If a timer signal fires on an RPC waiting for a server that is unreachable, the application won't see the signal until the RPC times out. Maybe that's how it works now?
And, otherwise, a ^C on an app waiting for an unresponsive server will not have immediate results. But again, I think that's how it works now.
Quoted 5 lines
How does sockets based NFS handle this? Doesn't it zero copy from these same buffers into SKBs? How does it cancel the SKBs before the NIC transmits them?
Seems like exactly the same kind of problem to me..
TCP has keep-alive, where the sockets consumer is notified as soon as the network layer determines the remote is unresponsive. The connection is closed from underneath the consumer.
For RDMA, which has no keep-alive mechanism, we seem to be going with waiting for the RPC to time out, then the consumer itself breaks the connection.
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Chuck Lever
What I implemented was a scheme to invalidate the memory of a (POSIX) signaled RPC before it completes, in case the RPC Reply hadn't yet arrived.
Currently, the only time the QP might be killed is if the server attempts to RDMA Write an RPC Reply into one of these invalidated memory regions. That case can't be avoided with the current RPC- over-RDMA protocol.
Okay..
Quoted 1 line
And again, we want to preserve the connection if it is healthy.
Well, if SENDs are not completing then it is not healthly. It is analogous to what TCP Keep Alive does.
Quoted 9 lines
Quoted 5 lines
How does sockets based NFS handle this? Doesn't it zero copy from these same buffers into SKBs? How does it cancel the SKBs before the NIC transmits them?
Seems like exactly the same kind of problem to me..
TCP has keep-alive, where the sockets consumer is notified as soon as the network layer determines the remote is unresponsive. The connection is closed from underneath the consumer.
keep-alive is something different, it pings the remote periodicaly and detects dead connections even when there is no traffic.
RDMA detects dead connections via retries and timeouts, but only if there is traffic.
My questions was about how the same situation is handled in TCP. If it does DMA directly from the source buffers by chaining them into SKBs then it has exactly the same problem, it cannot release the buffers until SKB is released from the TCP stack after NIC xmit. Like in RDMA, this only happens once TCP has got the ack back.
Perhaps the answer is that TCP does not zero copy these buffers, or TCP doesn't care about transmitting random memory, but it seems a question worth asking.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tom Talpey
reviewerQuoted 7 lines · Jason Gunthorpe
Quoted 4 lines · Chuck Lever
B. Force RPC completion to wait for Send completion, which would allow the post-v4.6 scatter-gather code to work safely. This would need some guarantee that Sends will always complete in a short period.
Quoted 5 lines
Why is waiting for the send completion so fundamentally different from waiting for the remote RPC reply?
I would say that 99% of time the send completion and RPC reply completion will occure approximately concurrently.
Absolutely not. The RPC reply requires upper layer processing at the server, which involves work requests, context switches, file system and disk i/o operations, and plain old queuing. RPC replies typically can be expected in milliseconds from traditional HDDs, and hundreds of microseconds from SSDs. Storage class memory is reducing these by two orders of magnitude, but it's still not in the range of a network round trip.
Quoted 2 lines
eg It is quite likely the RPC reply SEND carries an embeded ack for the requesting SEND..
That's not what we've seen, even on InfiniBand. On adapters such as iWARP, I will note, the send completion is often generated when the adapter buffers the outgoing message, and has almost nothing to do with the remote transport ack.
Tom.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Tom Talpey
Quoted 5 lines
Why is waiting for the send completion so fundamentally different from waiting for the remote RPC reply?
I would say that 99% of time the send completion and RPC reply completion will occure approximately concurrently.
Absolutely not. The RPC reply requires upper layer processing at the server, which involves work requests, context switches, file
I should have said '99% of the time the SEND will occure approximately concurrently or sooner'
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tom Talpey
reviewerQuoted 5 lines · Jason Gunthorpe
Quoted 3 lines · Tom Talpey
Quoted 3 lines
Why is waiting for the send completion so fundamentally different from waiting for the remote RPC reply?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I would say that 99% of time the send completion and RPC reply completion will occure approximately concurrently.
Absolutely not. The RPC reply requires upper layer processing at the server, which involves work requests, context switches, file
I should have said '99% of the time the SEND will occure approximately concurrently or sooner'
Ok, that I agree with. Unfortunately though, the code has to handle either sequence, and sends do complete after replies in many cases.
One reason for that is the RNIC and network, but another is more insidious. When sends and receives go to separate CQs, there's basically no causality between the two, and they synchronize with different MSI vectors (and therefore CPU cores), different locks, and different upcall code paths. There's no way to sort that out without serializing everything much too heavily.
Tom.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html