Re: [PATCH net-next v3 5/8] rust: time: Add wrapper for fsleep function
From: FUJITA Tomonori
Date: Wed Oct 23 2024 - 20:23:08 EST
On Wed, 16 Oct 2024 11:42:07 +0200
Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> wrote:
> On Wed, Oct 16, 2024 at 10:29 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>>
>> You probably want this:
>>
>> delta.as_nanos().saturating_add(time::NSEC_PER_USEC - 1) / time::NSEC_PER_USEC
>>
>> This would avoid a crash if someone passes i64::MAX nanoseconds and
>> CONFIG_RUST_OVERFLOW_CHECKS is enabled.
>
> I think we should document whether `fsleep` is expected to be usable
> for "forever" values.
>
> It sounds like that, given "too large" values in `msecs_to_jiffies`
> mean "infinite timeout".
Do you mean msecs_to_jiffies() returns MAX_JIFFY_OFFSET ((LONG_MAX >>
1)-1) with a value exceeding i32::MAX milliseconds?