[PATCH] nvme: optimize passthrough IOPOLL completion for local ring context
Keith Busch
kbusch at kernel.org
Thu Jan 15 10:21:41 PST 2026
On Thu, Jan 15, 2026 at 04:59:52PM +0800, Ming Lei wrote:
> + if (blk_rq_is_poll(req) && req->poll_ctx == io_uring_cmd_ctx_handle(ioucmd)) {
...
> @@ -677,8 +691,14 @@ int nvme_ns_chr_uring_cmd_iopoll(struct io_uring_cmd *ioucmd,
> struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd);
> struct request *req = pdu->req;
>
> - if (req && blk_rq_is_poll(req))
> + if (req && blk_rq_is_poll(req)) {
> + /*
> + * Store the polling context in the request so end_io can
> + * detect if it's completing in the local ring's context.
> + */
> + req->poll_ctx = iob ? iob->poll_ctx : NULL;
I don't think this works. The io_uring polling always polls from a
single ctx's iopoll_list, so it's redundant to store the ctx in the iob
since it will always match the ctx of the ioucmd passed in.
Which then leads to the check at the top: if req->poll_ctx was ever set,
then it should always match its ioucmd ctx too, right? If it was set
once before, but the polling didn't find the completion, then another
ctx polling does find it, we won't complete it in the iouring task as
needed.
I think you want to save off ctx that called
'nvme_ns_chr_uring_cmd_iopoll()', but there doesn't seem to be an
immediate way to refer back to that from 'nvme_uring_cmd_end_io'. Maybe
stash it in current->io_uring->last instead, then check if
io_uring_cmd_ctx_handle(ioucmd)) equals that.
More information about the Linux-nvme
mailing list