From: "Danilo Krummrich" <dakr@kernel.org>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>
Cc: "John Hubbard" <jhubbard@nvidia.com>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>,
"Shashank Sharma" <shashanks@nvidia.com>,
"Zhi Wang" <zhiw@nvidia.com>, "David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
rust-for-linux@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] rust: sizes: add u64 variants of SZ_* constants
Date: Tue, 10 Mar 2026 17:53:10 +0100 [thread overview]
Message-ID: <DGZ9BP8JRU4V.1PYK1RR3U145T@kernel.org> (raw)
In-Reply-To: <CANiq72kiiKkK0Q5w=UKNsPXvuuHMASpRJ7KAMy=2908n_u-DUA@mail.gmail.com>
On Tue Mar 10, 2026 at 2:51 PM CET, Miguel Ojeda wrote:
> On Tue, Mar 10, 2026 at 3:31 AM John Hubbard <jhubbard@nvidia.com> wrote:
>>
>> +// CAST: every SZ_* value below fits in u64, so `as u64` is always lossless.
>
> Nit:
>
> // CAST: Every `SZ_*` value below fits in `u64`, so `as u64` is
> always lossless.
>
> One alternative could be something like `sizes::u64::SZ_1M`, but if
> you expect to mix `usize` and `u64` often then it may not be great.
I have a slight preference towards this. It also shoudn't be that bad if we need
both, as we could just keep the prefix, i.e. u64::SZ_1M.
> Regarding adding the constants or not, I am ambivalent. On one hand, I
> see the pain of repeating it; on the other hand, adding these only
> works for particular values (i.e. we still need the safe casts around
> anyway for other values).
In a lot of cases we won't need to go back and forth with those values, as all
of the DRM infrastructure works with u64. So, there'd be quite a lot of overhead
if everytime we want to initialize something in GPUVM, GPU Buddy, TTM, etc. with
one of the SZ_* constants, i.e. we'd need to repeat u64::from_safe_cast(SZ_*)
over and over again. This is the main reason why I proposed to have u64 variants
in the first place.
Technically, if they are not needed for anything else, we could also make them
GPU infrastructure, e.g. gpu::SZ_*. Additionally, we could have GPU specific
usize and isize types.
next prev parent reply other threads:[~2026-03-10 16:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 2:31 [PATCH 0/2] rust, nova-core: use u64 variants of SZ_* constants John Hubbard
2026-03-10 2:31 ` [PATCH 1/2] rust: sizes: add " John Hubbard
2026-03-10 13:51 ` Miguel Ojeda
2026-03-10 16:42 ` Daniel Almeida
2026-03-10 16:53 ` Danilo Krummrich [this message]
2026-03-10 20:20 ` Miguel Ojeda
2026-03-10 20:47 ` Danilo Krummrich
2026-03-10 20:55 ` Danilo Krummrich
2026-03-10 22:08 ` Miguel Ojeda
2026-03-10 22:13 ` John Hubbard
2026-03-10 22:19 ` John Hubbard
2026-03-11 8:01 ` Alexandre Courbot
2026-03-12 0:21 ` John Hubbard
2026-03-10 16:59 ` Danilo Krummrich
2026-03-10 2:31 ` [PATCH 2/2] gpu: nova-core: use SZ_*_U64 constants from kernel::sizes John Hubbard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DGZ9BP8JRU4V.1PYK1RR3U145T@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=shashanks@nvidia.com \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.com \
--cc=zhiw@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox