From: Xixin Liu <liuxixin@kylinos.cn>
To: linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
linux-kernel@vger.kernel.org, hare@kernel.org,
shinichiro.kawasaki@wdc.com, liuxixin@kylinos.cn
Subject: [PATCH] nvme-tcp: defer TLS inline send to io_work
Date: Wed, 19 Aug 2026 08:50:00 +0800 [thread overview]
Message-ID: <c6e2a91f0b62.1787100300.git.liuxixin@kylinos.cn> (raw)
In-Reply-To: <ee0225fa-6a0b-4933-9a4d-5c77792eb94b@suse.de>
blk_mq holds set->srcu while queuing and running requests. The kTLS
software send path takes ctx->tx_lock. lockdep knows that tx_lock
nests under elevator_lock which then waits on srcu, so an inline
send from that path under TLS triggers circular locking.
Skip the inline send optimization for TLS queues so the send runs
from the workqueue instead. The same workqueue already retries TLS
sends on write-space notifications. Plain TCP keeps the inline path.
Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Xixin Liu <liuxixin@kylinos.cn>
---
drivers/nvme/host/tcp.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index c0fe8cfb7229..22741570fb7f 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -415,8 +415,14 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
* 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);
--
2.53.0
next parent reply other threads:[~2026-08-19 9:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ajtk1CaN1pBreS4O@shinmob>
[not found] ` <cover.1782436781.git.liuxixin@kylinos.cn>
[not found] ` <8803a2bf-3f8e-4ee9-b6d7-5467bfc1b1ce@suse.de>
[not found] ` <reply-hannes.062lockdep.20260629.liuxixin@kylinos.cn>
[not found] ` <reply-hannes.062lockdep.20260701.liuxixin@kylinos.cn>
[not found] ` <aoPuIUSQvZxujmv7@shinhome>
[not found] ` <ee0225fa-6a0b-4933-9a4d-5c77792eb94b@suse.de>
2026-08-19 0:50 ` Xixin Liu [this message]
2026-08-25 2:57 ` Keith Busch
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=c6e2a91f0b62.1787100300.git.liuxixin@kylinos.cn \
--to=liuxixin@kylinos.cn \
--cc=axboe@kernel.dk \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.com \
/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
all inboxes | Powered by JetHome®