From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, io-uring <[email protected]>
Subject: Re: [PATCH v2] io_uring: enable toggle of iowait usage when waiting on CQEs
Date: Tue, 18 Mar 2025 20:07:53 +0000 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 3/18/25 18:36, Jens Axboe wrote:
> On 3/18/25 12:39 AM, Pavel Begunkov wrote:
>> On 3/17/25 14:07, Jens Axboe wrote:
>>> On 3/16/25 12:57 AM, Pavel Begunkov wrote:
>>>> On 3/14/25 18:48, Jens Axboe wrote:
>>>>> By default, io_uring marks a waiting task as being in iowait, if it's
>>>>> sleeping waiting on events and there are pending requests. This isn't
>>>>> necessarily always useful, and may be confusing on non-storage setups
>>>>> where iowait isn't expected. It can also cause extra power usage, by
>>>>
>>>> I think this passage hints on controlling iowait stats, and in my opinion
>>>> we shouldn't conflate stats and optimisations. Global iowait stats
>>>> is there to stay, but ideally we want to never account io_uring as iowait.
>>>> That's while there were talks about removing optimisation toggle at all
>>>> (and do it as internal cpufreq magic, I suppose).
>>>>
>>>> How about posing it as an optimisation option only and that iowait stat
>>>> is a side effect that can change. Explicitly spelling that in the commit
>>>> message and in a comment on top of the flag in an attempt to avoid the
>>>> uapi regression trap. We'd also need it in the option's man when it's
>>>> written. And I'd also add "hint" to the flag name, like
>>>> IORING_ENTER_HINT_NO_IOWAIT, as we might need to nop it if anything
>>>> changes on the cpufreq side.
>>>
>>> Having potentially the control of both would be useful, the stat
>>
>> It's not the right place to control the stat accounting though,
>> apps don't care about iowait, it's usually monitored by a different
>> entity / person from outside the app, so responsibilities don't
>> match. It's fine if you fully control the stack, but just imagine
>
> Sometimes those are one and the same thing, though - there's just the
> one application running. That's not uncommon in data centers.
Yep, but that's only a subset, and for others the very fact of the
feature existence creates a mess, which might be fine or not.
>> a bunch of apps using different frameworks with io_uring inside
>> that make different choices about it. The final iowait reading
>> would be just a mess. With this patch at least we can say it's
>> an unfortunate side effect.
>> If we can separately control the accounting, a sysctl knob would
>> probably be better, i.e. to be set globally from outside of an
>> app, but I don't think we care enough to add extra logic / overhead
>> for handling it.
>
> That's not a bad idea, maybe we just do that for starters? We can always
Do we really want it though? What are you trying to achieve, fixing
the iowait stat problem or providing an optimisation option? Because
as I see it, what's good for one is bad for the other, unfortunately.
A sysctl is not a great option as an optimisation, because with that
all apps in the system has either to be storage or net to be optimal
in relation to iowait / power consumption. That one you won't even
be able to use in a good number of server setups while getting
optimal power consumption, even if you own the entire stack.
It sounds to me like the best option is to choose which one we want
to solve at the moment. Global / sysctl option for the stat, but I'm
not sure it's that important atm, people complain less nowadays
as well. Enter flag goes fine for the iowait optimisation, but
messes with the stat. IMHO, that should be fine if we're clear
about it and that the stat part of it can change. That's what
I'd suggest doing.
The third option is to try to solve them both, but seems your
patches got buried in a discussion, and working it around at
io_uring side doesn't sound pretty, like two flags you
mentioned.
Another option is to just have v2 and tell that the optimisation
and the accounting is the same, having some mess on the stat
side, and deal with the consequences when the in-kernel semantics
changes.
> introduce per-enter flags for managing boost and/or stats, at least it
> provides a system wide setting that can just get overridden by flags,
> should we need it.
>
>>> accounting and the cpufreq boosting. I do think the current name is
>>> better, though, the hint doesn't really add anything. I think we'd want
>>
>> "Hint" tells the user that it's legit for the kernel to ignore
>> it, including the iowait stat differences the user may see. And
>> we may actually need to drop the flag if task->iowait knob will
>> get hidden from io_uring in the future. The main benefit here
>> is for it to be in the name, because there are always those who
>> don't read comments.
>
> But that's the part I have a problem with - sometimes you'd need to know
> if it's honored or not.
If the flag implements optimisation only part of iowait, I don't think
it's so necessary, but we can add some slow path for querying if it has
the iowait stat "side effect". If it's about the stat, yeah, probably
we can't just ignore it and "hint" is not a good idea.
--
Pavel Begunkov
next prev parent reply other threads:[~2025-03-18 20:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 18:48 [PATCH v2] io_uring: enable toggle of iowait usage when waiting on CQEs Jens Axboe
2025-03-16 6:57 ` Pavel Begunkov
2025-03-17 14:07 ` Jens Axboe
2025-03-18 6:39 ` Pavel Begunkov
2025-03-18 18:36 ` Jens Axboe
2025-03-18 20:07 ` Pavel Begunkov [this message]
2025-03-19 1:54 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox