summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorJackie Liu <liuyun01@kylinos.cn>2019-10-29 11:16:42 +0800
committerJens Axboe <axboe@kernel.dk>2019-11-01 08:36:36 -0600
commite9ffa5c2b77edf2689f876b640318b16fc3ea2a7 (patch)
tree0c09ee2658611352f73990090afcc6ef8528b92b /fs/io_uring.c
parent62755e35dfb2b113c52b81cd96d01c20971c8e02 (diff)
downloadlwn-e9ffa5c2b77edf2689f876b640318b16fc3ea2a7.tar.gz
lwn-e9ffa5c2b77edf2689f876b640318b16fc3ea2a7.zip
io_uring: set -EINTR directly when a signal wakes up in io_cqring_wait
We didn't use -ERESTARTSYS to tell the application layer to restart the system call, but instead return -EINTR. we can set -EINTR directly when wakeup by the signal, which can help us save an assignment operation and comparison operation. Reviewed-by: Bob Liu <bob.liu@oracle.com> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 76d653085987..a520c4262d85 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2976,7 +2976,7 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
.to_wait = min_events,
};
struct io_rings *rings = ctx->rings;
- int ret;
+ int ret = 0;
if (io_cqring_events(rings) >= min_events)
return 0;
@@ -2994,7 +2994,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
return ret;
}
- ret = 0;
iowq.nr_timeouts = atomic_read(&ctx->cq_timeouts);
trace_io_uring_cqring_wait(ctx, min_events);
do {
@@ -3004,15 +3003,13 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
break;
schedule();
if (signal_pending(current)) {
- ret = -ERESTARTSYS;
+ ret = -EINTR;
break;
}
} while (1);
finish_wait(&ctx->wait, &iowq.wq);
- restore_saved_sigmask_unless(ret == -ERESTARTSYS);
- if (ret == -ERESTARTSYS)
- ret = -EINTR;
+ restore_saved_sigmask_unless(ret == -EINTR);
return READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0;
}