Skip to content

Commit fdb288a

Browse files
JackieLiu1axboe
authored andcommitted
io_uring: use wait_event_interruptible for cq_wait conditional wait
The previous patch has ensured that io_cqring_events contain smp_rmb memory barriers, Now we can use wait_event_interruptible to keep the code simple. Signed-off-by: Jackie Liu <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent dc6ce4b commit fdb288a

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

fs/io_uring.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
21812181
{
21822182
struct io_cq_ring *ring = ctx->cq_ring;
21832183
sigset_t ksigmask, sigsaved;
2184-
DEFINE_WAIT(wait);
21852184
int ret;
21862185

21872186
if (io_cqring_events(ring) >= min_events)
@@ -2201,21 +2200,9 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
22012200
return ret;
22022201
}
22032202

2204-
do {
2205-
prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE);
2206-
2207-
ret = 0;
2208-
if (io_cqring_events(ring) >= min_events)
2209-
break;
2210-
2211-
schedule();
2212-
2203+
ret = wait_event_interruptible(ctx->wait, io_cqring_events(ring) >= min_events);
2204+
if (ret == -ERESTARTSYS)
22132205
ret = -EINTR;
2214-
if (signal_pending(current))
2215-
break;
2216-
} while (1);
2217-
2218-
finish_wait(&ctx->wait, &wait);
22192206

22202207
if (sig)
22212208
restore_user_sigmask(sig, &sigsaved);

0 commit comments

Comments
 (0)