mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
svcrdma: Fewer calls to wake_up() in Send completion handler
Because wake_up() takes an IRQ-safe lock, it can be expensive, especially to call inside of a single-threaded completion handler. What's more, the Send wait queue almost never has waiters, so most of the time, this is an expensive no-op. As always, the goal is to reduce the average overhead of each completion, because a transport's completion handlers are single- threaded on one CPU core. This change reduces CPU utilization of the Send completion thread by 2-3% on my server. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-By: Tom Talpey <tom@talpey.com>
This commit is contained in:
parent
cd2d644ddb
commit
6c8c84f525
|
|
@ -207,6 +207,7 @@ extern void svc_rdma_send_error_msg(struct svcxprt_rdma *rdma,
|
|||
struct svc_rdma_send_ctxt *sctxt,
|
||||
struct svc_rdma_recv_ctxt *rctxt,
|
||||
int status);
|
||||
extern void svc_rdma_wake_send_waiters(struct svcxprt_rdma *rdma, int avail);
|
||||
extern int svc_rdma_sendto(struct svc_rqst *);
|
||||
extern int svc_rdma_result_payload(struct svc_rqst *rqstp, unsigned int offset,
|
||||
unsigned int length);
|
||||
|
|
|
|||
|
|
@ -248,8 +248,7 @@ static void svc_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc)
|
|||
|
||||
trace_svcrdma_wc_write(wc, &cc->cc_cid);
|
||||
|
||||
atomic_add(cc->cc_sqecount, &rdma->sc_sq_avail);
|
||||
wake_up(&rdma->sc_send_wait);
|
||||
svc_rdma_wake_send_waiters(rdma, cc->cc_sqecount);
|
||||
|
||||
if (unlikely(wc->status != IB_WC_SUCCESS))
|
||||
svc_xprt_deferred_close(&rdma->sc_xprt);
|
||||
|
|
@ -304,9 +303,7 @@ static void svc_rdma_wc_read_done(struct ib_cq *cq, struct ib_wc *wc)
|
|||
|
||||
trace_svcrdma_wc_read(wc, &cc->cc_cid);
|
||||
|
||||
atomic_add(cc->cc_sqecount, &rdma->sc_sq_avail);
|
||||
wake_up(&rdma->sc_send_wait);
|
||||
|
||||
svc_rdma_wake_send_waiters(rdma, cc->cc_sqecount);
|
||||
cc->cc_status = wc->status;
|
||||
complete(&cc->cc_done);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -258,6 +258,20 @@ void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma,
|
|||
spin_unlock(&rdma->sc_send_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* svc_rdma_wake_send_waiters - manage Send Queue accounting
|
||||
* @rdma: controlling transport
|
||||
* @avail: Number of additional SQEs that are now available
|
||||
*
|
||||
*/
|
||||
void svc_rdma_wake_send_waiters(struct svcxprt_rdma *rdma, int avail)
|
||||
{
|
||||
atomic_add(avail, &rdma->sc_sq_avail);
|
||||
smp_mb__after_atomic();
|
||||
if (unlikely(waitqueue_active(&rdma->sc_send_wait)))
|
||||
wake_up(&rdma->sc_send_wait);
|
||||
}
|
||||
|
||||
/**
|
||||
* svc_rdma_wc_send - Invoked by RDMA provider for each polled Send WC
|
||||
* @cq: Completion Queue context
|
||||
|
|
@ -275,11 +289,9 @@ static void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
|
|||
|
||||
trace_svcrdma_wc_send(wc, &ctxt->sc_cid);
|
||||
|
||||
svc_rdma_wake_send_waiters(rdma, 1);
|
||||
complete(&ctxt->sc_done);
|
||||
|
||||
atomic_inc(&rdma->sc_sq_avail);
|
||||
wake_up(&rdma->sc_send_wait);
|
||||
|
||||
if (unlikely(wc->status != IB_WC_SUCCESS))
|
||||
svc_xprt_deferred_close(&rdma->sc_xprt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user