]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
io_uring: add reschedule point to handle_tw_list()
authorJens Axboe <axboe@kernel.dk>
Fri, 27 Jan 2023 16:50:31 +0000 (09:50 -0700)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 14 Mar 2023 15:47:18 +0000 (16:47 +0100)
BugLink: https://bugs.launchpad.net/bugs/2011425
commit f58680085478dd292435727210122960d38e8014 upstream.

If CONFIG_PREEMPT_NONE is set and the task_work chains are long, we
could be running into issues blocking others for too long. Add a
reschedule check in handle_tw_list(), and flush the ctx if we need to
reschedule.

Cc: stable@vger.kernel.org # 5.10+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
io_uring/io_uring.c

index d7e2a7432d8ae66edb4b484a5bac92c1a9c83269..80ba696e1c90280b05b91ea4895da8285e35050d 100644 (file)
@@ -1143,10 +1143,16 @@ static unsigned int handle_tw_list(struct llist_node *node,
                        /* if not contended, grab and improve batching */
                        *locked = mutex_trylock(&(*ctx)->uring_lock);
                        percpu_ref_get(&(*ctx)->refs);
-               }
+               } else if (!*locked)
+                       *locked = mutex_trylock(&(*ctx)->uring_lock);
                req->io_task_work.func(req, locked);
                node = next;
                count++;
+               if (unlikely(need_resched())) {
+                       ctx_flush_and_put(*ctx, locked);
+                       *ctx = NULL;
+                       cond_resched();
+               }
        }
 
        return count;