From 539777a03dbf74197afb49c63a050e516964ce6d Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sat, 3 Oct 2020 11:53:38 -0600 Subject: [PATCH] io_uring: avoid syscall restart for signal_pending(), if possible 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 --- fs/io_uring.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index aae0ef2ec34d..ee8c1b6aeead 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -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(¤t->sighand->siglock); current->jobctl &= ~JOBCTL_TASK_WORK; -- 2.25.1