This is a note to let you know that I've just added the patch titled io_uring: add a conditional reschedule to the IOPOLL cancelation loop to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-add-a-conditional-reschedule-to-the-iopoll-cancelation-loop.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From fcc926bb857949dbfa51a7d95f3f5ebc657f198c Mon Sep 17 00:00:00 2001 From: Jens Axboe <axboe@xxxxxxxxx> Date: Fri, 27 Jan 2023 09:28:13 -0700 Subject: io_uring: add a conditional reschedule to the IOPOLL cancelation loop From: Jens Axboe <axboe@xxxxxxxxx> commit fcc926bb857949dbfa51a7d95f3f5ebc657f198c upstream. If the kernel is configured with CONFIG_PREEMPT_NONE, we could be sitting in a tight loop reaping events but not giving them a chance to finish. This results in a trace ala: rcu: INFO: rcu_sched self-detected stall on CPU rcu: 2-...!: (5249 ticks this GP) idle=935c/1/0x4000000000000000 softirq=4265/4274 fqs=1 (t=5251 jiffies g=465 q=4135 ncpus=4) rcu: rcu_sched kthread starved for 5249 jiffies! g465 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0 rcu: Unless rcu_sched kthread gets sufficient CPU time, OOM is now expected behavior. rcu: RCU grace-period kthread stack dump: task:rcu_sched state:R running task stack:0 pid:12 ppid:2 flags:0x00000008 Call trace: __switch_to+0xb0/0xc8 __schedule+0x43c/0x520 schedule+0x4c/0x98 schedule_timeout+0xbc/0xdc rcu_gp_fqs_loop+0x308/0x344 rcu_gp_kthread+0xd8/0xf0 kthread+0xb8/0xc8 ret_from_fork+0x10/0x20 rcu: Stack dump where RCU GP kthread last ran: Task dump for CPU 0: task:kworker/u8:10 state:R running task stack:0 pid:89 ppid:2 flags:0x0000000a Workqueue: events_unbound io_ring_exit_work Call trace: __switch_to+0xb0/0xc8 0xffff0000c8fefd28 CPU: 2 PID: 95 Comm: kworker/u8:13 Not tainted 6.2.0-rc5-00042-g40316e337c80-dirty #2759 Hardware name: linux,dummy-virt (DT) Workqueue: events_unbound io_ring_exit_work pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) pc : io_do_iopoll+0x344/0x360 lr : io_do_iopoll+0xb8/0x360 sp : ffff800009bebc60 x29: ffff800009bebc60 x28: 0000000000000000 x27: 0000000000000000 x26: ffff0000c0f67d48 x25: ffff0000c0f67840 x24: ffff800008950024 x23: 0000000000000001 x22: 0000000000000000 x21: ffff0000c27d3200 x20: ffff0000c0f67840 x19: ffff0000c0f67800 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000001 x13: 0000000000000001 x12: 0000000000000000 x11: 0000000000000179 x10: 0000000000000870 x9 : ffff800009bebd60 x8 : ffff0000c27d3ad0 x7 : fefefefefefefeff x6 : 0000646e756f626e x5 : ffff0000c0f67840 x4 : 0000000000000000 x3 : ffff0000c2398000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000 Call trace: io_do_iopoll+0x344/0x360 io_uring_try_cancel_requests+0x21c/0x334 io_ring_exit_work+0x90/0x40c process_one_work+0x1a4/0x254 worker_thread+0x1ec/0x258 kthread+0xb8/0xc8 ret_from_fork+0x10/0x20 Add a cond_resched() in the cancelation IOPOLL loop to fix this. Cc: stable@xxxxxxxxxxxxxxx # 5.10+ Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- io_uring/io_uring.c | 1 + 1 file changed, 1 insertion(+) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2912,6 +2912,7 @@ static __cold bool io_uring_try_cancel_r while (!wq_list_empty(&ctx->iopoll_list)) { io_iopoll_try_reap_events(ctx); ret = true; + cond_resched(); } } Patches currently in stable-queue which might be from axboe@xxxxxxxxx are queue-6.1/sbitmap-use-single-per-bitmap-counting-to-wake-up-qu.patch queue-6.1/io_uring-handle-tif_notify_resume-when-checking-for-task_work.patch queue-6.1/block-don-t-allow-multiple-bios-for-iocb_nowait-issue.patch queue-6.1/sbitmap-correct-wake_batch-recalculation-to-avoid-po.patch queue-6.1/blk-mq-avoid-sleep-in-blk_mq_alloc_request_hctx.patch queue-6.1/io_uring-add-reschedule-point-to-handle_tw_list.patch queue-6.1/ublk_drv-remove-nr_aborted_queues-from-ublk_device.patch queue-6.1/io_uring-remove-msg_nosignal-from-recvmsg.patch queue-6.1/blk-mq-fix-potential-io-hung-for-shared-sbitmap-per-.patch queue-6.1/blk-mq-wait-on-correct-sbitmap_queue-in-blk_mq_mark_.patch queue-6.1/block-clear-bio-bi_bdev-when-putting-a-bio-back-in-the-cache.patch queue-6.1/io_uring-fix-fget-leak-when-fs-don-t-support-nowait-buffered-read.patch queue-6.1/ublk_drv-don-t-probe-partitions-if-the-ubq-daemon-is.patch queue-6.1/trace-blktrace-fix-memory-leak-with-using-debugfs_lo.patch queue-6.1/io_uring-rsrc-disallow-multi-source-reg-buffers.patch queue-6.1/x86-fpu-don-t-set-tif_need_fpu_load-for-pf_io_worker.patch queue-6.1/io_uring-replace-0-length-array-with-flexible-array.patch queue-6.1/blk-cgroup-dropping-parent-refcount-after-pd_free_fn.patch queue-6.1/block-be-a-bit-more-careful-in-checking-for-null-bdev-while-polling.patch queue-6.1/block-use-proper-return-value-from-bio_failfast.patch queue-6.1/block-fix-io-statistics-for-cgroup-in-throttle-path.patch queue-6.1/block-ublk-check-io-buffer-based-on-flag-need_get_da.patch queue-6.1/io_uring-use-user-visible-tail-in-io_uring_poll.patch queue-6.1/blk-cgroup-synchronize-pd_free_fn-from-blkg_free_wor.patch queue-6.1/sbitmap-remove-redundant-check-in-__sbitmap_queue_ge.patch queue-6.1/block-sync-mixed-merged-request-s-failfast-with-1st-.patch queue-6.1/blk-mq-remove-stale-comment-for-blk_mq_sched_mark_re.patch queue-6.1/blk-iocost-fix-divide-by-0-error-in-calc_lcoefs.patch queue-6.1/s390-dasd-fix-potential-memleak-in-dasd_eckd_init.patch queue-6.1/blk-mq-correct-stale-comment-of-.get_budget.patch queue-6.1/io_uring-add-a-conditional-reschedule-to-the-iopoll-cancelation-loop.patch queue-6.1/block-bio-integrity-copy-flags-when-bio_integrity_pa.patch