Re: [PATCH v2 1/2] rust: add udelay() function
From: FUJITA Tomonori
Date: Sun Oct 26 2025 - 09:12:06 EST
On Fri, 24 Oct 2025 21:05:19 +0200
Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> wrote:
> On Fri, Oct 24, 2025 at 11:27 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>>
>> For range checks, seemingly unrelated code changes turn out to affect
>> these optimizations and break the code.
>
> Most of these calls use constants, so in those cases it would be fine
> (and otherwise it is really an issue on the optimizer).
>
> But, yes, using `build_assert!` on the "normal" version of `udelay()`
> will eventually surprise someone, because someone out there will start
> using it with runtime values that happen to work and that later may
> not when code gets shuffled around, especially given it shares the
> name with C.
>
> So for functions that do `build_assert!` on parameters we may want at
> least a suffix with a particular word (e.g. `_const`) or similar, so
> that it is clear calling them may have issues if not "obviously
> constant for the optimizer", leaving the "normal" name for the runtime
> one or the const generics one etc.
>
> Here, I would suggest we do what we did for `fsleep()` and likely move
> both to `debug_assert!` plus `pr_warn!` (and likely `pr_warn_once!`
> when supported).
I've sent v3 with debug_assert! added.
Is anyone currently working on pr_*_once? If I remember correctly,
there were a few proposals in the past, but they didn’t reach a
conclusion on how to implement it and never got merged.