All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, Stefan Metzmacher <metze@samba.org>,
	io-uring@vger.kernel.org
Cc: Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH v2 2/2] io_uring/timeout: immediate timeout arg
Date: Fri, 27 Feb 2026 22:47:52 +0000	[thread overview]
Message-ID: <11058b2c-55b2-4a4f-8d80-7533211b16bf@gmail.com> (raw)
In-Reply-To: <3a8e5738-b417-440a-9851-b8ecc2a82b82@kernel.dk>

On 2/27/26 22:19, Jens Axboe wrote:
...
>> They should be enabled in the same release, but we've been rather
>> discussing the way to do that. I was saying that u64 is enough to
>> pass the abs timeout value, and we can extend it to another u64 if
>> needed in several centuries from now. And it's not a bad option
>> because plain u64 ns makes much much more sense for the relative
>> mode. And even for the abs scenario above, I'd prefer that rather
>> than doing second adjustments every single time.
> 
> ABS makes very little sense as nanoseconds, that's pretty confusing on
> the userspace side. That's the main issue.
> 
> I'm not sure why it's such a big deal to just encode the sec/nsec so
> that userspace can use it directly from a timespec or timeval which is
> most likely what they are querying time from anyway? If you do absolute,
> surely you'd do
> 
> get_time(&t);
> t.tv_sec += 1;

More like +N ms, which would be

t.tv_sec += N / 1000;
t.tv_nsec += (N % 1000) * NS_IN_MS;
if (t.tv_nsec >= NS_IN_SEC) {
	t.tv_nsec -= NS_IN_SEC;
	t.tv_sec++;
}

And then you want to compare them and calculate differences. io_uring
works with __kernel_timespec, but just take a look at liburing
tests/examples, lots of them open code some version of
get_time_[m,u,n]s unless they hard code a specific relative timeout.
It's a self propelling misery.

> now issue timeout for that. That's a hell of a lot more natural to use
> than converting to and from nsecs.

I'd rather convert it to ns once and use that after. And I bet it'll
be nicer with other non Linux specific libraries. e.g. you can get
ns from std c++.

> For relative it's obviously not a huge deal, but it'd be nice to keep
> them consistent.
> 

-- 
Pavel Begunkov


  reply	other threads:[~2026-02-27 22:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 10:35 [PATCH v2 0/2] timeout immediate arg Pavel Begunkov
2026-02-25 10:35 ` [PATCH v2 1/2] io_uring/timeout: READ_ONCE sqe->addr Pavel Begunkov
2026-02-25 10:35 ` [PATCH v2 2/2] io_uring/timeout: immediate timeout arg Pavel Begunkov
2026-02-27 14:08   ` Stefan Metzmacher
2026-02-27 15:05     ` Jens Axboe
2026-02-27 16:17       ` Stefan Metzmacher
2026-02-27 16:21         ` Jens Axboe
2026-02-27 19:08     ` Pavel Begunkov
2026-02-27 19:39       ` Jens Axboe
2026-02-27 20:03         ` Pavel Begunkov
2026-02-27 20:19           ` Jens Axboe
2026-02-27 21:09             ` Pavel Begunkov
2026-02-27 21:17               ` Jens Axboe
2026-02-27 22:10                 ` Pavel Begunkov
2026-02-27 22:19                   ` Jens Axboe
2026-02-27 22:47                     ` Pavel Begunkov [this message]
2026-02-28 13:44                       ` Jens Axboe
2026-02-28 13:55                         ` Jens Axboe
2026-03-02 12:58                         ` Pavel Begunkov
2026-02-25 15:36 ` (subset) [PATCH v2 0/2] timeout immediate arg 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 \
    --in-reply-to=11058b2c-55b2-4a4f-8d80-7533211b16bf@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=kbusch@kernel.org \
    --cc=metze@samba.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.