Re: [PATCH v6 4/7] rust: time: add Delta::to_jiffies_timeout() for timeout conversion

Miguel Ojeda <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux
Message-ID <CANiq72kHP1s7bGr4=xfJGR8KY=aUpjOB4OwLEG5E=TKULXg5Rg@mail.gmail.com>
On Sat, Aug 8, 2026 at 9:48 AM FUJITA Tomonori <[email protected]> wrote:
>
> +        // CAST: `__msecs_to_jiffies()` returns a value in `0..=MAX_JIFFY_OFFSET`, i.e.
> +        // `((LONG_MAX >> 1) - 1)`, which is non-negative and well within `isize`.

I don't think I can pick up this one, because this comment isn't true
for arm32 `HZ=1000`, i.e. `__msecs_to_jiffies()` can be higher than
`MAX_JIFFY_OFFSET` and can actually reach `isize::MAX`.

Which in turns means that we don't saturate to `MAX_JIFFY_OFFSET` like
the commit message mentions.

It also makes the method non-monotonic, i.e. going from:

    Delta::from_millis(i64::from(i32::MAX)).to_jiffies_timeout()

to:

    Delta::from_millis(i64::from(i32::MAX) + 1).to_jiffies_timeout()

means a big drop, which was not what I would naively expect from the method.

Could the documentation clarify what the saturation is? And add some
doctests? (Also to the previous patch's function if possible).

Thanks!

Cheers,
Miguel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.