Rust for Linux List
 help / color / mirror / Atom feed
From: FUJITA Tomonori <tomo@flapping.org>
To: gary@garyguo.net
Cc: tomo@flapping.org, markus.probst@posteo.de, aliceryhl@google.com,
	dakr@kernel.org, ojeda@kernel.org, a.hindborg@kernel.org,
	acourbot@nvidia.com, bjorn3_gh@protonmail.com, boqun@kernel.org,
	daniel.almeida@collabora.com, lossin@kernel.org,
	tamird@kernel.org, tmgross@umich.edu, work@onurozkan.dev,
	linux-serial@vger.kernel.org, rust-for-linux@vger.kernel.org,
	fujita.tomonori@gmail.com
Subject: Re: [PATCH v1] rust: serdev: use Delta<Jiffy> for timeouts
Date: Thu, 01 Oct 2026 13:26:33 +0900 (JST)	[thread overview]
Message-ID: <20261001.132633.73542440712145669.tomo@flapping.org> (raw)
In-Reply-To: <DLT5AOYLEZXE.C2HPEP6WSP33@garyguo.net>

On Thu, 01 Oct 2026 03:27:39 +0100
"Gary Guo" <gary@garyguo.net> wrote:

> On Thu Oct 1, 2026 at 2:28 AM BST, FUJITA Tomonori wrote:

[...]

>>> Alternatively, just use `MAX_SCHEDULE_TIMEOUT` (i.e.
>>> `Delta::from_jiffies(isize::MAX)`). We can perhaps add a `Delta::MAX` for this.
>>
>> I don't think Delta::<Jiffy>::MAX is a good idea. Whether the maximum
>> value means an indefinite wait depends on the function. For example,
>> it doesn't for Queue::enqueue_delayed().
> 
> Whether it means infinite or not depends on the function, but that's still mean
> "MAX", no?

If I understand you correctly, a Rust function that takes Delta<Jiffy>
turns Delta::<Jiffy>::MAX into the maximum value of the C function it
calls, and documents what MAX means.

isize::MAX is MAX_SCHEDULE_TIMEOUT, so schedule_timeout() and the
functions built on it need nothing. Other functions might need a
clamp, because C avoids LONG_MAX as a jiffies span:

| /*
|  * Change timeval to jiffies, trying to avoid the
|  * most obvious overflows..
|  *
|  * And some not so obvious.
|  *
|  * Note that we don't want to return LONG_MAX, because
|  * for various timeout reasons we often end up having
|  * to wait "jiffies+1" in order to guarantee that we wait
|  * at _least_ "jiffies" - so "jiffies+1" had better still
|  * be positive.
|  */
| #define MAX_JIFFY_OFFSET ((LONG_MAX >> 1)-1)

With that, I'm fine with Delta::<Jiffy>::MAX.

      reply	other threads:[~2026-10-01  4:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  4:13 [PATCH v1] rust: serdev: use Delta<Jiffy> for timeouts FUJITA Tomonori
2026-09-30 12:59 ` Markus Probst
2026-09-30 13:52   ` Gary Guo
2026-09-30 14:07     ` Markus Probst
2026-10-01  0:29     ` FUJITA Tomonori
2026-10-01  0:39       ` Gary Guo
2026-10-01  1:28         ` FUJITA Tomonori
2026-10-01  2:27           ` Gary Guo
2026-10-01  4:26             ` FUJITA Tomonori [this message]

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=20261001.132633.73542440712145669.tomo@flapping.org \
    --to=tomo@flapping.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-serial@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=markus.probst@posteo.de \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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