[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DADAXGJLZ4LP.27P0GIQB2DKD0@nvidia.com>
Date: Wed, 04 Jun 2025 08:54:06 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Benno Lossin" <lossin@...nel.org>, "Danilo Krummrich" <dakr@...nel.org>
Cc: "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
<alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
<gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <benno.lossin@...ton.me>,
"Andreas Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl"
<aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "David Airlie"
<airlied@...il.com>, "Simona Vetter" <simona@...ll.ch>, "Maarten Lankhorst"
<maarten.lankhorst@...ux.intel.com>, "Maxime Ripard" <mripard@...nel.org>,
"Thomas Zimmermann" <tzimmermann@...e.de>, "John Hubbard"
<jhubbard@...dia.com>, "Ben Skeggs" <bskeggs@...dia.com>, "Joel Fernandes"
<joelagnelf@...dia.com>, "Timur Tabi" <ttabi@...dia.com>, "Alistair Popple"
<apopple@...dia.com>, <linux-kernel@...r.kernel.org>,
<rust-for-linux@...r.kernel.org>, <nouveau@...ts.freedesktop.org>,
<dri-devel@...ts.freedesktop.org>
Subject: Re: [PATCH v4 04/20] rust: add new `num` module with useful integer
operations
On Wed Jun 4, 2025 at 7:53 AM JST, Benno Lossin wrote:
> On Mon Jun 2, 2025 at 11:39 AM CEST, Danilo Krummrich wrote:
>> On Thu, May 29, 2025 at 09:27:33AM +0200, Benno Lossin wrote:
>>> That's also fair, but we lose the constness of `next_multiple_of`, so
>>> you can't use `align_up` in a const function. That might confuse people
>>> and then they write their own const helper function... I'd prefer we use
>>> all functions that are available in the stdlib.
>>
>> Considering that, what's the suggestion for this trait?
>>
>> I don't think we should have a trait with align_down() and fls() only and
>> otherwise use next_multiple_of(), i.e. mix things up.
>
> Agreed.
>
>> I think we should either align with the Rust nomenclature - whatever this means
>> for fls() - or implement the trait with all three methods.
>
> The longterm perspective would be to choose the Rust one. But I'd also
> understand if people want the kernel's own terms used. Still I prefer
> the Rust ones :)
My understanding is that so far we have tried to match the names of C
counterparts as much as possible when reimplementing stuff. I don't
think this particular module warrants an exception, which could cause
confusion to folks coming from the C part of the kernel.
Powered by blists - more mailing lists