From: Cheng Yongkang <teel4res@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG] io_uring/timeout: multishot timeout rearms during cancel drain
Date: Sun, 15 Nov 2026 08:35:47 -0800 [thread overview]
Message-ID: <20261115163547.225149-1-teel4res@gmail.com> (raw)
Hi Jens,
I hit a corner case in io_timeout_complete(). It only shows up when
userspace sets the CQ head to a bogus value, so it may not be worth
fixing. I am reporting it in case you want the check.
io_timeout_complete() does not look at tw.cancel, unlike
io_poll_check_events(), io_req_task_submit() and the linked timeout
handler in the same file. During io_cancel_local_task_work(), a
zero-interval multishot timeout still posts a CQE and rearms its
timer, which queues new task work. The drain keeps running it until
CQE posting fails.
Normally the CQ fills up quickly and the request then completes. But
if userspace sets the CQ head to cq.tail + 0x7fffffff, posting keeps
succeeding for about 2^31 CQEs. On v7.3 with DEFER_TASKRUN and 4096
such timeouts, the ring was still not freed 5 seconds after close.
Skipping the rearm when tw.cancel is set fixes it:
- if (io_req_post_cqe(req, -ETIME, IORING_CQE_F_MORE)) {
+ if (!tw.cancel &&
+ io_req_post_cqe(req, -ETIME, IORING_CQE_F_MORE)) {
With this change the same test frees the ring in about 300 ms, and
normal multishot timeouts behave as before. The code is unchanged in
next-20261113. I can send a patch if you want one.
Thanks,
Cheng Yongkang
next reply other threads:[~2026-11-15 16:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 16:35 Cheng Yongkang [this message]
2026-11-15 16:42 ` Jens Axboe
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=20261115163547.225149-1-teel4res@gmail.com \
--to=teel4res@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®