io_uring: avoid syscall restart for signal_pending(), if possible tif-task_work.3
authorJens Axboe <axboe@kernel.dk>
Sat, 3 Oct 2020 17:53:38 +0000 (11:53 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 5 Oct 2020 14:43:24 +0000 (08:43 -0600)
Same kind of optimization we have for the JOBCTL_TASK_WORK. This is safe
to do, as we're running task_work manually for this case.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index aae0ef2ec34d2b7503b150efae46cb36988f4c06..ee8c1b6aeead793f9191fe7d2fe991cc9f06c429 100644 (file)
@@ -6755,6 +6755,11 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
                if (io_run_task_work())
                        continue;
                if (signal_pending(current)) {
+                       /* avoid restart, if we can */
+#ifdef TIF_NOTIFY_SIGNAL
+                       if (test_and_clear_thread_flag(TIF_NOTIFY_SIGNAL))
+                               continue;
+#endif
                        if (current->jobctl & JOBCTL_TASK_WORK) {
                                spin_lock_irq(&current->sighand->siglock);
                                current->jobctl &= ~JOBCTL_TASK_WORK;