Skip to content

Commit

Permalink
io_uring: use wait_event_interruptible for cq_wait conditional wait
Browse files Browse the repository at this point in the history
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 <liuyun01@kylinos.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jackie Liu authored and Jens Axboe committed May 16, 2019
1 parent dc6ce4b commit fdb288a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
{
struct io_cq_ring *ring = ctx->cq_ring;
sigset_t ksigmask, sigsaved;
DEFINE_WAIT(wait);
int ret;

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

do {
prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE);

ret = 0;
if (io_cqring_events(ring) >= min_events)
break;

schedule();

ret = wait_event_interruptible(ctx->wait, io_cqring_events(ring) >= min_events);
if (ret == -ERESTARTSYS)
ret = -EINTR;
if (signal_pending(current))
break;
} while (1);

finish_wait(&ctx->wait, &wait);

if (sig)
restore_user_sigmask(sig, &sigsaved);
Expand Down

0 comments on commit fdb288a

Please sign in to comment.