From: Yuanhe Shu <xiangzao@linux.alibaba.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Cc: Pavel Begunkov <asml.silence@gmail.com>,
linux-kernel@vger.kernel.org, xiangzao@linux.alibaba.com
Subject: [PATCH 0/2] io_uring: add schedule points to request freeing loops
Date: Tue, 20 Oct 2026 14:44:50 +0800 [thread overview]
Message-ID: <20261020064452.3633250-1-xiangzao@linux.alibaba.com> (raw)
An I/O stress test on a production v6.6-based debug kernel (stress-ng -a 1
--class io -t 7h on a 384-CPU machine) hit the soft lockup watchdog
twice. The kernel was built with KASAN, kmemleak, lockdep and
CONFIG_PREEMPT_NONE=y. Both lockups occurred while a CPU was busy
in an io_uring request freeing loop that has no scheduling point:
1) A stress-ng worker looped in io_free_batch_list(), reached from
exit-time task_work, until the machine panicked on "softlockup:
hung tasks".
2) A completion fallback work item held uring_lock for 671 seconds
in that same free loop, until the watchdog fired again
("BUG: soft lockup - CPU#61 stuck for 671s").
The field kernel is v6.6-based, so to check whether the same
weakness exists in current mainline, I tried to reproduce the
pattern on v7.3-rc7 on a 192-CPU debug kernel (KASAN, kmemleak,
lockdep; preempt=none - see the note below), with a test
that submits 32K requests per ring and then kills the rings. I
don't know whether real workloads hit these exact loops on
mainline as hard as our test does, but the loops clearly have the
same unbounded shape:
- A single io_free_batch_list() call freeing a 32K completion batch
took 443ms with no scheduling point in between.
- Killing 48 rings at once made one __io_req_caches_free() call
drain a single cache for up to 13 seconds, with 8 kworkers each
stuck for over 12 seconds; a separate run with 96 rings produced
97 soft lockup warnings during teardown (the stack is in patch 2).
With this series applied, the same 96-ring run produces zero
kworker soft lockup warnings: all 97 drain-path warnings are gone.
This series targets the request freeing and cache draining paths;
the submission loop itself may need a separate treatment and is
intentionally left out of this series.
The free loops are the remaining gap: the CQ overflow flush already
drops the lock and reschedules (eac2ca2d682f), and io_add_buffers(),
io_remove_buffers_legacy(), the fdinfo dump loops and the tctx
teardown all iterate with a cond_resched() in the loop. These two
request freeing loops have none. The debug options amplify the
per-request cost, but the loops are otherwise bounded only by the
number of completed or cached requests. No functional change is
intended; the patches only add scheduling points to long loops,
and cond_resched() only invokes the scheduler if need_resched()
is set. Unlike the overflow flush resched point, these do not drop
the lock or leave any critical section, so they introduce no
reordering concerns.
Note: the mainline test was booted with preempt=none to match
the production kernel above. On x86 this required a local Kconfig
adjustment to disable PREEMPT_LAZY; this is a test-environment
detail and does not change the fix. cond_resched() is the standard
schedule point on PREEMPT_NONE/VOLUNTARY kernels.
Tested with CONFIG_DEBUG_ATOMIC_SLEEP and CONFIG_PROVE_LOCKING
enabled; no might_sleep or scheduling-while-atomic warnings during
the reproduction runs.
Yuanhe Shu (2):
io_uring: add a schedule point in io_free_batch_list()
io_uring: add a schedule point in __io_req_caches_free()
io_uring/io_uring.c | 2 ++
1 file changed, 2 insertions(+)
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
--
2.43.7
next reply other threads:[~2026-10-20 6:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 6:44 Yuanhe Shu [this message]
2026-10-20 6:44 ` [PATCH 1/2] io_uring: add a schedule point in io_free_batch_list() Yuanhe Shu
2026-10-20 6:44 ` [PATCH 2/2] io_uring: add a schedule point in __io_req_caches_free() Yuanhe Shu
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=20261020064452.3633250-1-xiangzao@linux.alibaba.com \
--to=xiangzao@linux.alibaba.com \
--cc=asml.silence@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®