nvme-tcp: question on poll return value

Daniel Wagner dwagner at suse.de
Wed Jan 24 07:31:44 PST 2024


Hi Sagi,

I am stubled across nr_cqe while debugging something else and I am not
sure if the poll function is doing the right thing with it. IIUC, the
blk_mq_ops poll callback is supposed to return > 0 value when it
processed at least one element. If this is the case, than I think we
would need to first copy the current value in nr_cqe before calling
nvme_tcp_try_recv. The function will reset queue->nr_cqe to 0, thus
nvme_tcp_poll will always return 0.

Does this make any sense?

Thanks,
Daniel

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index d79811cfa0ce..db9a105bd986 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2573,6 +2573,7 @@ static int nvme_tcp_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
 {
 	struct nvme_tcp_queue *queue = hctx->driver_data;
 	struct sock *sk = queue->sock->sk;
+	int nr_cqe;

 	if (!test_bit(NVME_TCP_Q_LIVE, &queue->flags))
 		return 0;
@@ -2580,9 +2581,10 @@ static int nvme_tcp_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
 	set_bit(NVME_TCP_Q_POLLING, &queue->flags);
 	if (sk_can_busy_loop(sk) && skb_queue_empty_lockless(&sk->sk_receive_queue))
 		sk_busy_loop(sk, true);
+	nr_cqe = queue->nr_cqe;
 	nvme_tcp_try_recv(queue);
 	clear_bit(NVME_TCP_Q_POLLING, &queue->flags);
-	return queue->nr_cqe;
+	return nr_cqe;
 }

 static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size)



More information about the Linux-nvme mailing list