Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'io_uring-6.5-2023-07-28' of git://git.kernel.dk/linux

Pull io_uring fix from Jens Axboe:
"Just a single tweak to a patch from last week, to avoid having idle
cqring waits be attributed as iowait"

* tag 'io_uring-6.5-2023-07-28' of git://git.kernel.dk/linux:
io_uring: gate iowait schedule on having pending requests

+17 -6
+17 -6
io_uring/io_uring.c
··· 2493 2493 return 0; 2494 2494 } 2495 2495 2496 + static bool current_pending_io(void) 2497 + { 2498 + struct io_uring_task *tctx = current->io_uring; 2499 + 2500 + if (!tctx) 2501 + return false; 2502 + return percpu_counter_read_positive(&tctx->inflight); 2503 + } 2504 + 2496 2505 /* when returns >0, the caller should retry */ 2497 2506 static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, 2498 2507 struct io_wait_queue *iowq) 2499 2508 { 2500 - int token, ret; 2509 + int io_wait, ret; 2501 2510 2502 2511 if (unlikely(READ_ONCE(ctx->check_cq))) 2503 2512 return 1; ··· 2520 2511 return 0; 2521 2512 2522 2513 /* 2523 - * Use io_schedule_prepare/finish, so cpufreq can take into account 2524 - * that the task is waiting for IO - turns out to be important for low 2525 - * QD IO. 2514 + * Mark us as being in io_wait if we have pending requests, so cpufreq 2515 + * can take into account that the task is waiting for IO - turns out 2516 + * to be important for low QD IO. 2526 2517 */ 2527 - token = io_schedule_prepare(); 2518 + io_wait = current->in_iowait; 2519 + if (current_pending_io()) 2520 + current->in_iowait = 1; 2528 2521 ret = 0; 2529 2522 if (iowq->timeout == KTIME_MAX) 2530 2523 schedule(); 2531 2524 else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) 2532 2525 ret = -ETIME; 2533 - io_schedule_finish(token); 2526 + current->in_iowait = io_wait; 2534 2527 return ret; 2535 2528 } 2536 2529