Commit f5868008 authored by Jens Axboe's avatar Jens Axboe

io_uring: add reschedule point to handle_tw_list()

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: default avatarJens Axboe <axboe@kernel.dk>
parent fcc926bb
...@@ -1179,10 +1179,16 @@ static unsigned int handle_tw_list(struct llist_node *node, ...@@ -1179,10 +1179,16 @@ static unsigned int handle_tw_list(struct llist_node *node,
/* if not contended, grab and improve batching */ /* if not contended, grab and improve batching */
*locked = mutex_trylock(&(*ctx)->uring_lock); *locked = mutex_trylock(&(*ctx)->uring_lock);
percpu_ref_get(&(*ctx)->refs); percpu_ref_get(&(*ctx)->refs);
} } else if (!*locked)
*locked = mutex_trylock(&(*ctx)->uring_lock);
req->io_task_work.func(req, locked); req->io_task_work.func(req, locked);
node = next; node = next;
count++; count++;
if (unlikely(need_resched())) {
ctx_flush_and_put(*ctx, locked);
*ctx = NULL;
cond_resched();
}
} }
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment