public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@kernel.org>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
	Kamaljit Singh <kamaljit.singh1@wdc.com>,
	linux-nvme@lists.infradead.org, Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 3/3] nvme-tcp: do not queue io_work on a full socket
Date: Wed, 28 May 2025 08:45:35 +0200	[thread overview]
Message-ID: <20250528064535.135653-4-hare@kernel.org> (raw)
In-Reply-To: <20250528064535.135653-1-hare@kernel.org>

There really is no point in scheduling io_work from ->queue_rq()
if the socket is full; we'll be notified by the ->write_space()
callback once space on the socket becomes available.
Consequently we also need to remove the check for 'sk_stream_is_writeable()'
in the ->write_space() callback as we need to schedule io_work
to receive packets even if the sending side is blocked.

Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
 drivers/nvme/host/tcp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 0e178115dc04..e4dd1620dc28 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -411,6 +411,9 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
 	empty = llist_add(&req->lentry, &queue->req_list) &&
 		list_empty(&queue->send_list) && !queue->request;
 
+	if (!sk_stream_is_writeable(queue->sock->sk))
+		empty = false;
+
 	/*
 	 * 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
@@ -422,7 +425,8 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
 		mutex_unlock(&queue->send_mutex);
 	}
 
-	if (last && nvme_tcp_queue_has_pending(queue))
+	if (last && nvme_tcp_queue_has_pending(queue) &&
+	    sk_stream_is_writeable(queue->sock->sk))
 		queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work);
 }
 
@@ -1074,7 +1078,7 @@ static void nvme_tcp_write_space(struct sock *sk)
 
 	read_lock_bh(&sk->sk_callback_lock);
 	queue = sk->sk_user_data;
-	if (likely(queue && sk_stream_is_writeable(sk))) {
+	if (likely(queue)) {
 		clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
 		queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work);
 	}
-- 
2.35.3



  parent reply	other threads:[~2025-05-28  6:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28  6:45 [PATCHv4 0/3] nvme-tcp: fixup I/O stall on congested sockets Hannes Reinecke
2025-05-28  6:45 ` [PATCH 1/3] nvme-tcp: sanitize request list handling Hannes Reinecke
2025-05-29 12:34   ` Sagi Grimberg
2025-05-28  6:45 ` [PATCH 2/3] nvme-tcp: fix I/O stalls on congested sockets Hannes Reinecke
2025-05-29 12:34   ` Sagi Grimberg
2025-05-28  6:45 ` Hannes Reinecke [this message]
2025-05-29 12:38   ` [PATCH 3/3] nvme-tcp: do not queue io_work on a full socket Sagi Grimberg
2025-05-30  6:42     ` Hannes Reinecke
2025-06-04  8:04 ` [PATCHv4 0/3] nvme-tcp: fixup I/O stall on congested sockets Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250528064535.135653-4-hare@kernel.org \
    --to=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=kamaljit.singh1@wdc.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox