All of lore.kernel.org
 help / color / mirror / Atom feed
From: Seiji Nishikawa <snishika@redhat.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: Hannes Reinecke <hare@suse.de>, Chris Leech <cleech@redhat.com>,
	Seiji Nishikawa <snishika@redhat.com>,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/2] nvme-tcp: remove send_mutex
Date: Sun, 22 Nov 2026 10:18:26 +0900	[thread overview]
Message-ID: <20261122011826.1959697-3-snishika@redhat.com> (raw)
In-Reply-To: <20261122011826.1959697-1-snishika@redhat.com>

With the direct send path gone, io_work is the only context that sends
on a queue. A work item never runs concurrently with itself, so
send_mutex does not protect anything anymore.

Remove it, together with the mutex_trylock() in nvme_tcp_io_work() and
the got_send_mutex check, which is now always true.

Assisted-by: LLM
Signed-off-by: Seiji Nishikawa <snishika@redhat.com>
---
 drivers/nvme/host/tcp.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 2b832ac3068a..b116268fe2f5 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -142,7 +142,6 @@ struct nvme_tcp_queue {
 	int			io_cpu;
 
 	struct mutex		queue_lock;
-	struct mutex		send_mutex;
 	struct mutex		pf_cache_lock;
 	struct llist_head	req_list;
 	struct list_head	send_list;
@@ -1482,18 +1481,13 @@ static void nvme_tcp_io_work(struct work_struct *w)
 
 	do {
 		bool pending = false;
-		bool got_send_mutex = false;
 		int result;
 
-		if (mutex_trylock(&queue->send_mutex)) {
-			got_send_mutex = true;
-			result = nvme_tcp_try_send(queue);
-			mutex_unlock(&queue->send_mutex);
-			if (result > 0)
-				pending = true;
-			else if (unlikely(result < 0))
-				break;
-		}
+		result = nvme_tcp_try_send(queue);
+		if (result > 0)
+			pending = true;
+		else if (unlikely(result < 0))
+			break;
 
 		result = nvme_tcp_try_recv(queue);
 		if (result > 0)
@@ -1501,13 +1495,8 @@ static void nvme_tcp_io_work(struct work_struct *w)
 		else if (unlikely(result < 0))
 			return;
 
-		/*
-		 * did we get some space after spending time in recv?
-		 * Only check this if we could take send_mutex. Otherwise
-		 * the task holding it sends the requests and queues io_work
-		 * again after it releases the mutex.
-		 */
-		if (got_send_mutex && nvme_tcp_queue_has_pending(queue) &&
+		/* did we get some space after spending time in recv? */
+		if (nvme_tcp_queue_has_pending(queue) &&
 		    sk_stream_is_writeable(queue->sock->sk))
 			pending = true;
 
@@ -2087,7 +2076,6 @@ static void nvme_tcp_init_queue(struct nvme_tcp_ctrl *ctrl, int qid)
 
 	queue->ctrl = ctrl;
 	mutex_init(&queue->queue_lock);
-	mutex_init(&queue->send_mutex);
 	mutex_init(&queue->pf_cache_lock);
 	INIT_WORK(&queue->io_work, nvme_tcp_io_work);
 	queue->hdr_digest = ctrl->ctrl.opts->hdr_digest;
@@ -2099,7 +2087,6 @@ static void nvme_tcp_exit_queue(struct nvme_tcp_ctrl *ctrl, int qid)
 	struct nvme_tcp_queue *queue = &ctrl->queues[qid];
 
 	mutex_destroy(&queue->queue_lock);
-	mutex_destroy(&queue->send_mutex);
 	mutex_destroy(&queue->pf_cache_lock);
 }
 
-- 
2.56.1


      parent reply	other threads:[~2026-11-22  1:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  1:18 [RFC PATCH 0/2] nvme-tcp: remove the direct send path Seiji Nishikawa
2026-11-22  1:18 ` [RFC PATCH 1/2] " Seiji Nishikawa
2026-11-22  1:42   ` sashiko-bot
2026-11-22  4:37     ` Seiji Nishikawa
2026-11-23  8:20       ` Hannes Reinecke
2026-11-22  1:18 ` Seiji Nishikawa [this message]

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=20261122011826.1959697-3-snishika@redhat.com \
    --to=snishika@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=cleech@redhat.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.