Skip to content

Commit

Permalink
io_uring: clear TIF_NOTIFY_SIGNAL if set and task_work not available
Browse files Browse the repository at this point in the history
With how task_work is added and signaled, we can have TIF_NOTIFY_SIGNAL
set and no task_work pending as it got run in a previous loop. Treat
TIF_NOTIFY_SIGNAL like get_signal(), always clear it if set regardless
of whether or not task_work is pending to run.

Cc: stable@vger.kernel.org
Fixes: 46a525e ("io_uring: don't gate task_work run on TIF_NOTIFY_SIGNAL")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jens Axboe committed Nov 25, 2022
1 parent 12ad3d2 commit 7cfe7a0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions io_uring/io_uring.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,14 @@ static inline unsigned int io_sqring_entries(struct io_ring_ctx *ctx)

static inline int io_run_task_work(void)
{
/*
* Always check-and-clear the task_work notification signal. With how
* signaling works for task_work, we can find it set with nothing to
* run. We need to clear it for that case, like get_signal() does.
*/
if (test_thread_flag(TIF_NOTIFY_SIGNAL))
clear_notify_signal();
if (task_work_pending(current)) {
if (test_thread_flag(TIF_NOTIFY_SIGNAL))
clear_notify_signal();
__set_current_state(TASK_RUNNING);
task_work_run();
return 1;
Expand Down

0 comments on commit 7cfe7a0

Please sign in to comment.