[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aBP9yvWnB66qJeRh@Mac.home>
Date: Thu, 1 May 2025 16:03:38 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Arnd Bergmann <arnd@...db.de>
Cc: FUJITA Tomonori <fujita.tomonori@...il.com>,
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 01, 2025 at 05:11:44PM +0200, Arnd Bergmann wrote:
> 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
Because Arm is the only 32bit architecture that selects CONFIG_HAVE_RUST
for non-UML cases, i.e. this is the only 32bit architecture that has
this problem. If your point is we should do this for all 32bit
architectures, then I won't disagree. Just s/CONFIG_ARM/CONFIG_32BIT
then.
Regards,
Boqun
> 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