lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87seko1tl9.fsf@kernel.org>
Date: Wed, 28 May 2025 20:24:50 +0200
From: Andreas Hindborg <a.hindborg@...nel.org>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: rust-for-linux@...r.kernel.org,  Arnd Bergmann <arnd@...db.de>,  Boqun
 Feng <boqun.feng@...il.com>,  linux-kernel@...r.kernel.org,
  a.hindborg@...sung.com,  frederic@...nel.org,  lyude@...hat.com,
  tglx@...utronix.de,  anna-maria@...utronix.de,  jstultz@...gle.com,
  sboyd@...nel.org,  ojeda@...nel.org,  alex.gaynor@...il.com,
  gary@...yguo.net,  bjorn3_gh@...tonmail.com,  benno.lossin@...ton.me,
  aliceryhl@...gle.com,  tmgross@...ch.edu,  chrisi.schrefl@...il.com,
  linux@...linux.org.uk
Subject: Re: [PATCH v2] rust: time: Avoid 64-bit integer division on 32-bit
 architectures

FUJITA Tomonori <fujita.tomonori@...il.com> writes:

> Avoid 64-bit integer division that 32-bit architectures don't
> implement generally. This uses ktime_to_us() and ktime_to_ms()
> instead.
>
> The time abstraction needs i64 / u32 division so C's div_s64() can be
> used but ktime_to_us() and ktime_to_ms() provide a simpler solution
> for this time abstraction problem on 32-bit architectures.
>
> 32-bit ARM is the only 32-bit architecture currently supported by
> Rust. Using the cfg attribute, only 32-bit architectures will call
> ktime_to_us() and ktime_to_ms(), while the other 64-bit architectures
> will continue to use the current code as-is to avoid the overhead.
>
> One downside of calling the C's functions is that the as_micros/millis
> methods can no longer be const fn. We stick with the simpler approach
> unless there's a compelling need for a const fn.
>
> Suggested-by: Arnd Bergmann <arnd@...db.de>
> Suggested-by: Boqun Feng <boqun.feng@...il.com>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@...il.com>

Looks good to me.


Reviewed-by: Andreas Hindborg <a.hindborg@...nel.org>


Best regards,
Andreas Hindborg



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ