[RFC PATCH 1/2] nvme-tcp: remove the direct send path

sashiko-bot at kernel.org sashiko-bot at kernel.org
Sat Nov 21 17:42:49 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] nvme-tcp: poll queue starvation and latency regression in
  nvme_tcp_queue_request()
--

commit 7f6babf6da3e0f7ca956d6a355e996efe6f74e66
Author: Seiji Nishikawa <snishika at redhat.com>

nvme-tcp: remove the direct send path

This commit removes the inline direct send path in nvme_tcp_queue_request()
and nvme_tcp_send_all(), deferring all request transmissions to
queue->io_work on nvme_tcp_wq.

> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 62a594b8ab9bf..2b832ac3068a9 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
[ ... ]
> @@ -446,28 +435,10 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
>  		bool last)
>  {
>  	struct nvme_tcp_queue *queue = req->queue;
> -	bool empty;
>  
> -	empty = llist_add(&req->lentry, &queue->req_list) &&
> -		list_empty(&queue->send_list) && !queue->request;
> -
> -	/*
> -	 * if we're the first on the send_list and we can try to send
> -	 * directly, otherwise queue io_work. Also, only do that if we
> -	 * are on the same cpu, so we don't introduce contention.
> -	 *
> -	 * TLS kTLS send takes ctx->tx_lock while blk_mq holds set->srcu.
> -	 * lockdep reports circular locking via elevator_lock.  Defer TLS
> -	 * sends to the io workqueue instead of inline from this path.
> -	 */
> -	if (queue->io_cpu == raw_smp_processor_id() &&
> -	    !nvme_tcp_queue_tls(queue) &&
> -	    empty && mutex_trylock(&queue->send_mutex)) {
> -		nvme_tcp_send_all(queue);
> -		mutex_unlock(&queue->send_mutex);
> -	}
> +	llist_add(&req->lentry, &queue->req_list);
>  
> -	if (last && nvme_tcp_queue_has_pending(queue))
> +	if (last)
>  		queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work);
>  }

[Severity: Medium]
Does removing the inline send from nvme_tcp_queue_request() break polled
I/O on HCTX_TYPE_POLL queues?

nvme_tcp_set_queue_io_cpu() binds queue->io_cpu for a poll queue to a CPU
in set->map[HCTX_TYPE_POLL].mq_map, while nvme_tcp_poll() only polls the
receive side and never drains queue->req_list:

drivers/nvme/host/tcp.c:nvme_tcp_poll() {
    ...
	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);
	ret = nvme_tcp_try_recv(queue);
	clear_bit(NVME_TCP_Q_POLLING, &queue->flags);
    ...
}

Previously, a task submitting and polling on queue->io_cpu sent the
request inline when the queue was idle and completed it without waking
nvme_tcp_wq.  With all sends deferred to queue->io_work on queue->io_cpu,
a SCHED_FIFO or SCHED_RR task polling via io_uring IORING_SETUP_IOPOLL or
blk_execute_rq() on queue->io_cpu starves the SCHED_NORMAL nvme_tcp_wq
worker on the same CPU and spins in nvme_tcp_poll() waiting for a request
still sitting in queue->req_list until RT throttling or the 30-second
NVMe I/O timeout fires.  For SCHED_NORMAL tasks on queue->io_cpu, waking
the WQ_HIGHPRI worker sets TIF_NEED_RESCHED, causing blk_hctx_poll() and
io_iopoll_check() to abort polling on need_resched() or forcing two
context switches per polled I/O.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122011826.1959697-1-snishika@redhat.com?part=1



More information about the Linux-nvme mailing list