summaryrefslogtreecommitdiffstats
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorOlivier Langlois <olivier@trillion01.com>2022-03-08 23:17:21 +0100
committerJens Axboe <axboe@kernel.dk>2022-03-10 17:18:30 +0100
commit950e79dd73131a263b2dd7fec521ceafd28d2724 (patch)
tree780fbac4afd60c4c2986fcd3aed8718fe24333dc /fs/io_uring.c
parentio_uring: add support for IORING_OP_MSG_RING command (diff)
downloadlinux-950e79dd73131a263b2dd7fec521ceafd28d2724.tar.xz
linux-950e79dd73131a263b2dd7fec521ceafd28d2724.zip
io_uring: minor io_cqring_wait() optimization
Move up the block manipulating the sig variable to execute code that may encounter an error and exit first before continuing executing the rest of the function and avoid useless computations Signed-off-by: Olivier Langlois <olivier@trillion01.com> Link: https://lore.kernel.org/r/84513f7cc1b1fb31d8f4cb910aee033391d036b4.1646777484.git.olivier@trillion01.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r--fs/io_uring.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 36b001365a79..3d2d47540e1b 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7919,14 +7919,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
break;
} while (1);
- if (uts) {
- struct timespec64 ts;
-
- if (get_timespec64(&ts, uts))
- return -EFAULT;
- timeout = ktime_add_ns(timespec64_to_ktime(ts), ktime_get_ns());
- }
-
if (sig) {
#ifdef CONFIG_COMPAT
if (in_compat_syscall())
@@ -7940,6 +7932,14 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
return ret;
}
+ if (uts) {
+ struct timespec64 ts;
+
+ if (get_timespec64(&ts, uts))
+ return -EFAULT;
+ timeout = ktime_add_ns(timespec64_to_ktime(ts), ktime_get_ns());
+ }
+
init_waitqueue_func_entry(&iowq.wq, io_wake_function);
iowq.wq.private = current;
INIT_LIST_HEAD(&iowq.wq.entry);