Skip to content

Commit 45a41e7

Browse files
committed
io_uring: move schedule wait logic into helper
In preparation for expanding how we handle waits, move the actual schedule and schedule_timeout() handling into a helper. Signed-off-by: Jens Axboe <[email protected]>
1 parent f42b58e commit 45a41e7

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

io_uring/io_uring.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,22 +2350,10 @@ static bool current_pending_io(void)
23502350
return percpu_counter_read_positive(&tctx->inflight);
23512351
}
23522352

2353-
/* when returns >0, the caller should retry */
2354-
static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
2355-
struct io_wait_queue *iowq)
2353+
static int __io_cqring_wait_schedule(struct io_ring_ctx *ctx,
2354+
struct io_wait_queue *iowq)
23562355
{
2357-
int ret;
2358-
2359-
if (unlikely(READ_ONCE(ctx->check_cq)))
2360-
return 1;
2361-
if (unlikely(!llist_empty(&ctx->work_llist)))
2362-
return 1;
2363-
if (unlikely(test_thread_flag(TIF_NOTIFY_SIGNAL)))
2364-
return 1;
2365-
if (unlikely(task_sigpending(current)))
2366-
return -EINTR;
2367-
if (unlikely(io_should_wake(iowq)))
2368-
return 0;
2356+
int ret = 0;
23692357

23702358
/*
23712359
* Mark us as being in io_wait if we have pending requests, so cpufreq
@@ -2374,7 +2362,6 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
23742362
*/
23752363
if (current_pending_io())
23762364
current->in_iowait = 1;
2377-
ret = 0;
23782365
if (iowq->timeout == KTIME_MAX)
23792366
schedule();
23802367
else if (!schedule_hrtimeout_range_clock(&iowq->timeout, 0,
@@ -2384,6 +2371,24 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
23842371
return ret;
23852372
}
23862373

2374+
/* If this returns > 0, the caller should retry */
2375+
static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
2376+
struct io_wait_queue *iowq)
2377+
{
2378+
if (unlikely(READ_ONCE(ctx->check_cq)))
2379+
return 1;
2380+
if (unlikely(!llist_empty(&ctx->work_llist)))
2381+
return 1;
2382+
if (unlikely(test_thread_flag(TIF_NOTIFY_SIGNAL)))
2383+
return 1;
2384+
if (unlikely(task_sigpending(current)))
2385+
return -EINTR;
2386+
if (unlikely(io_should_wake(iowq)))
2387+
return 0;
2388+
2389+
return __io_cqring_wait_schedule(ctx, iowq);
2390+
}
2391+
23872392
struct ext_arg {
23882393
size_t argsz;
23892394
struct __kernel_timespec __user *ts;

0 commit comments

Comments
 (0)