[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <681124ff.050a0220.13a0e7.2c80@mx.google.com>
Date: Tue, 29 Apr 2025 12:14:04 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Arnd Bergmann <arnd@...db.de>
Cc: FUJITA Tomonori <fujita.tomonori@...il.com>,
Andreas Hindborg <a.hindborg@...nel.org>, rust-for-linux@...r.kernel.org,
Gary Guo <gary@...yguo.net>, Alice Ryhl <aliceryhl@...gle.com>,
me@...enk.dev, daniel.almeida@...labora.com,
linux-kernel@...r.kernel.org, Netdev <netdev@...r.kernel.org>,
Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
Trevor Gross <tmgross@...ch.edu>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...sung.com>,
Anna-Maria Gleixner <anna-maria@...utronix.de>,
Frederic Weisbecker <frederic@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, John Stultz <jstultz@...gle.com>,
Stephen Boyd <sboyd@...nel.org>, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Benjamin Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Valentin Schneider <vschneid@...hat.com>, tgunders@...hat.com,
david.laight.linux@...il.com, Paolo Bonzini <pbonzini@...hat.com>,
Jocelyn Falempe <jfalempe@...hat.com>,
Russell King <linux@...linux.org.uk>,
Christian Schrefl <chrisi.schrefl@...il.com>,
Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH v15 5/6] rust: time: Add wrapper for fsleep() function
On Tue, Apr 29, 2025 at 08:33:47PM +0200, Arnd Bergmann wrote:
> On Tue, Apr 29, 2025, at 19:15, Boqun Feng wrote:
> > On Tue, Apr 29, 2025 at 06:11:02PM +0200, Arnd Bergmann wrote:
> >> On Tue, Apr 29, 2025, at 18:03, Boqun Feng wrote:
> >
> > Would it make sense if we rely on compiler optimization when it's
> > avaiable (for x86_64, arm64, riscv, etc), and only call ktime_to_ms() if
> > not? The downside of calling ktime_to_ms() are:
> >
> > * it's a call function, and cannot be inlined with LTO or INLINE_HELPER:
> >
> > https://lore.kernel.org/all/20250319205141.3528424-1-gary@garyguo.net/
> >
> > * it doesn't provide the overflow checking even if
> > CONFIG_RUST_OVERFLOW_CHECKS=y
> >
> > Thoughts?
>
> The function call overhead is tiny compared to replacing a 64-bit
> division with a constant mult/shift.
>
Just to be clear, are you essientially saying that even in C,
ktime_to_ms() is not worth inlining? Because the call overhead is tiny
compared to the function own cost?
My impression is that on x86 at least, function call is 10+ cycles, and
multiply is 3 cycles, so I would think that ktime_to_ms() itself is at
most 10 cycles. Maybe I'm out of date of the modern micro-architecture?
> What is the possible overflow that can happen here? For a constant
> division at least there is no chance of divide-by-zero. Do you mean
> truncating to 32 bit?
>
I was referring the last part of Miguel's email:
https://lore.kernel.org/rust-for-linux/CANiq72mMRpY4NC4_8v_wDpq6Z3qs99Y8gXd-7XL_3Bed58gkJg@mail.gmail.com/
Regards,
Boqun
> Arnd
Powered by blists - more mailing lists