[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <cbbeca76-7a7a-425b-9cdd-8da778b6d8a1@app.fastmail.com>
Date: Thu, 01 May 2025 17:11:44 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Boqun Feng" <boqun.feng@...il.com>,
"FUJITA Tomonori" <fujita.tomonori@...il.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
"Andreas Hindborg" <a.hindborg@...sung.com>,
"Frederic Weisbecker" <frederic@...nel.org>, "Lyude Paul" <lyude@...hat.com>,
"Thomas Gleixner" <tglx@...utronix.de>,
"Anna-Maria Gleixner" <anna-maria@...utronix.de>,
"John Stultz" <jstultz@...gle.com>, "Stephen Boyd" <sboyd@...nel.org>,
"Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>,
"Gary Guo" <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
"Benno Lossin" <benno.lossin@...ton.me>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>,
"Christian Schrefl" <chrisi.schrefl@...il.com>,
"Russell King" <linux@...linux.org.uk>
Subject: Re: [PATCH v1] rust: time: Avoid 64-bit integer division
On Thu, May 1, 2025, at 15:20, Boqun Feng wrote:
> On Thu, May 01, 2025 at 06:12:02AM -0700, Boqun Feng wrote:
>> On Thu, May 01, 2025 at 10:07:17PM +0900, FUJITA Tomonori wrote:
>> > 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.
What is Arm specific here? I'm not aware of the compiler doing anything
different from the other 32-bit architectures, though most are missing
an optimized __arch_xprod_64() and fall back to slightly worse code
from the asm-generic version.
> Copy-paste errors:
>
> unsafe { bindings::ktime_to_ms(ns) }
>
>> }
>>
>> #[cfg(not(CONFIG_ARM))]
>> fn ns_to_ms(ns: i64) -> i64 {
>> self.as_nanos() / NSEC_PER_MSEC
>
> ns / NSEC_PER_MSEC
I'm sure this is still broken on all 32-bit targets.
Arnd
Powered by blists - more mailing lists