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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250501.220717.849589327730222635.fujita.tomonori@gmail.com>
Date: Thu, 01 May 2025 22:07:17 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: boqun.feng@...il.com
Cc: fujita.tomonori@...il.com, rust-for-linux@...r.kernel.org,
 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, arnd@...db.de, linux@...linux.org.uk
Subject: Re: [PATCH v1] rust: time: Avoid 64-bit integer division

On Thu, 1 May 2025 05:26:54 -0700
Boqun Feng <boqun.feng@...il.com> wrote:

> On Thu, May 01, 2025 at 10:58:18AM +0900, FUJITA Tomonori wrote:
>> Avoid 64-bit integer division that 32-bit architectures don't
>> implement generally. This uses ktime_to_ms() and ktime_to_us()
>> instead.
>> 
>> The timer abstraction needs i64 / u32 division so C's div_s64() can be
>> used but ktime_to_ms() and ktime_to_us() provide a simpler solution
>> for this timer abstraction problem. On some architectures, there is
>> room to optimize the implementation of them, but such optimization can
>> be done if and when it becomes necessary.
>> 
> 
> Nacked-by: Boqun Feng <boqun.feng@...il.com>
> 
> As I said a few times, we should rely on compiler's optimization when
> available, i.e. it's a problem that ARM compiler doesn't have this
> optimization, don't punish other architecture of no reason.

Did you mean that we should do something like the following?

pub fn as_millis(self) -> i64 {
    #[cfg(CONFIG_ARM)]
    {
        // SAFETY: It is always safe to call `ktime_to_ms()` with any value.
        unsafe { bindings::ktime_to_ms(self.nanos) }
    }
    #[cfg(not(CONFIG_ARM))]
    {
        self.as_nanos() / NSEC_PER_MSEC
    }
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ