Patch "nvme-rdma: remove race conditions from IB signalling" has been added to the 4.12-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
nvme-rdma: remove race conditions from IB signalling
to the 4.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
nvme-rdma-remove-race-conditions-from-ib-signalling.patch
and it can be found in the queue-4.12 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
5e599d73c1c1816af07f94ddba879499aa39b43cMon Sep 17 00:00:00 2001
From: Marta Rybczynska <[email protected]>
Date: Tue, 6 Jun 2017 13:27:21 +0200
Subject: nvme-rdma: remove race conditions from IB signalling
From: Marta Rybczynska <[email protected]>
commit 5e599d73c1c1816af07f94ddba879499aa39b43c upstream.
This patch improves the way the RDMA IB signalling is done by using atomic operations for the signalling variable. This avoids race conditions on sig_count.
The signalling interval changes slightly and is now the largest power of two not larger than queue depth / 2.
ilog() usage idea by Bart Van Assche.
--- drivers/nvme/host/rdma.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/nvme/host/rdma.c +10 -10
@@ -88,7 +88,7 @@ enum nvme_rdma_queue_flags {struct nvme_rdma_queue {struct nvme_rdma_qe *rsp_ring; -u8 sig_count; +atomic_t sig_count;int queue_size;size_t cmnd_capsule_len;struct nvme_rdma_ctrl *ctrl;
@@ -553,6 +553,7 @@ static int nvme_rdma_init_queue(struct n queue->cmnd_capsule_len =sizeof (struct nvme_command ); queue->queue_size = queue_size; +atomic_set (&queue->sig_count,0 ); queue->cm_id =rdma_create_id (&init_net, nvme_rdma_cm_handler, queue,RDMA_PS_TCP ,IB_QPT_RC );
@@ -1040,17 +1041,16 @@ static void nvme_rdma_send_done(struct invme_rdma_wr_error (cq, wc,"SEND" ); } -static inline int nvme_rdma_queue_sig_limit (struct nvme_rdma_queue *queue) +/* +* We want to signal completion at least every queue depth/2. This returns the +* largest power of two that is not above half of (queue size + 1) to optimize +* (avoid divisions). +*/ +static inline bool nvme_rdma_queue_sig_limit (struct nvme_rdma_queue *queue) { -int sig_limit; +int limit =1 <<ilog2 ((queue->queue_size +1 ) /2 ); -/* -* We signal completion every queue depth/2 and also handle the -* degenerated case of a device with queue_depth=1, where we -* would need to signal every message. -*/ - sig_limit =max (queue->queue_size /2 ,1 ); -return (++queue->sig_count % sig_limit) ==0 ; +return (atomic_inc_return (&queue->sig_count) & (limit -1 )) ==0 ; } static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
Patches currently in stable-queue which might be from [email protected] are
queue-4.12/nvme-rdma-remove-race-conditions-from-ib-signalling.patch