[PATCH v2] nvme-tcp: limit the direct send path to poll queues

Hannes Reinecke hare at suse.de
Thu Nov 26 01:53:09 PST 2026


On 11/26/26 7:32 AM, Seiji Nishikawa wrote:
> nvme_tcp_queue_request() sends the request directly from the submitting
> context when it runs on the io_cpu of the queue, the queue is empty and
> it can take send_mutex. Commit db5ad6b7f8cd ("nvme-tcp: try to send
> request in queue_rq context") added this so that an idle queue can send
> the request without waiting for io_work to run.
> 
> Since then this path has needed a series of fixes for races and
> priority inversions between it and io_work. These are
> commit 5c11f7d9f843 ("nvme-tcp: Fix possible race of io_work and direct
> send"), commit a0fdd1418007 ("nvme-tcp: rerun io_work if req_list is
> not empty"), commit 70f437fb4395 ("nvme-tcp: fix io_work priority
> inversion"), commit 08acb54b063a ("nvme-tcp: defer TLS inline send to
> io_work") and commit 5db358f3a7f9 ("nvme-tcp: fix io_work priority
> inversion when send_mutex is held").
> 
> On a non-poll queue, the direct send path makes almost no difference to
> the latency. fio with libaio and 4k random I/O at queue depth 1 over a
> 1Gb network, with and without the direct send path (average of 3 runs
> of 60 seconds, latency in usec):
> 
>                        IOPS   slat   clat    lat
>    randread   with     4153    7.1  232.3  239.3
>               without  4154    4.7  234.7  239.4
>    randwrite  with     2472   24.5  375.6  400.1
>               without  2460   14.3  387.6  402.0
> 
> lat is slat plus clat. It changes by 0.1 usec for randread and by 1.9
> usec for randwrite.
> 
> On a poll queue, the latency becomes worse without the direct send path.
> The submitting task polls for the completion without sleeping. When it
> runs on io_cpu, where io_work also runs, the kworker that runs io_work
> can send the request only after the task is switched out. This happens
> once per request. fio with io_uring and --hipri at queue depth 1 over
> the same network, on the io_cpu of a poll queue (ctx is the number of
> context switches of fio in one run):
> 
>                        IOPS   slat    clat     lat      ctx
>    randread   with     5017   4.72  193.95  198.67      553
>               without  4179   9.35  229.70  239.05  251,318
>    randwrite  with     3619   5.60  269.94  275.54      542
>               without  3621  10.62  264.53  275.16  217,806
> 
> For randread, lat goes up by 40 usec (20%) without the direct send
> path.
> 
> So remove the direct send path, except for poll queues. The other
> queues always send from io_work, as TLS queues already do.
> 
> Add a queue flag, NVME_TCP_Q_POLLED, for this. nvme_tcp_alloc_queue()
> sets the flag when the queue is a poll queue, and
> nvme_tcp_queue_request() checks it.
> 
> Suggested-by: Hannes Reinecke <hare at suse.de>
> Signed-off-by: Seiji Nishikawa <snishika at redhat.com>
> ---
> Changes since RFC:
> - Keep the direct send path for poll queues. Sashiko pointed out the
>    cost on poll queues, and the numbers in the RFC thread confirm it.
> - Drop the patch that removed send_mutex. Poll queues still have 2
>    senders, so send_mutex is still needed.
> 
> RFC: https://lore.kernel.org/linux-nvme/20261122011826.1959697-1-snishika@redhat.com/
> 
>   drivers/nvme/host/tcp.c | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare at kernel.org>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare at suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich



More information about the Linux-nvme mailing list