From: John Hubbard <jhubbard@nvidia.com>
To: Timur Tabi <ttabi@nvidia.com>, "dakr@kernel.org" <dakr@kernel.org>
Cc: Alexandre Courbot <acourbot@nvidia.com>,
"lossin@kernel.org" <lossin@kernel.org>,
"a.hindborg@kernel.org" <a.hindborg@kernel.org>,
"boqun.feng@gmail.com" <boqun.feng@gmail.com>,
"aliceryhl@google.com" <aliceryhl@google.com>,
Zhi Wang <zhiw@nvidia.com>, "simona@ffwll.ch" <simona@ffwll.ch>,
"alex.gaynor@gmail.com" <alex.gaynor@gmail.com>,
"ojeda@kernel.org" <ojeda@kernel.org>,
"tmgross@umich.edu" <tmgross@umich.edu>,
"nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>,
"bjorn3_gh@protonmail.com" <bjorn3_gh@protonmail.com>,
Edwin Peer <epeer@nvidia.com>,
"airlied@gmail.com" <airlied@gmail.com>,
Joel Fernandes <joelagnelf@nvidia.com>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"gary@garyguo.net" <gary@garyguo.net>,
Alistair Popple <apopple@nvidia.com>
Subject: Re: [PATCH] gpu: nova-core: bitfield: use &mut self setters instead of builder pattern
Date: Wed, 31 Dec 2025 14:47:26 -0800 [thread overview]
Message-ID: <ec3e5da4-f944-4526-a339-3da8286c36d2@nvidia.com> (raw)
In-Reply-To: <9db27bd6015ccebaa20e51450d8c42eb2864cb2e.camel@nvidia.com>
On 12/31/25 2:33 PM, Timur Tabi wrote:
> On Wed, 2025-12-31 at 13:47 -0800, John Hubbard wrote:
>> The builder-pattern setters (self -> Self) enabled method chaining like:
>>
>> reg.set_foo(x).set_sec(y).write(bar);
>>
>> This made separate operations appear as a single expression, obscuring
>> that each setter is a distinct mutation.
>
> So you're concerned about the fact that the compiler is not merging the set_foo(x) and the
> set_sec(y) into a single read-modify-write?
No, I don't care about that aspect.
>
>> These setters are infallible,
>> so the chaining provides no error-propagation benefit—it just obscures
>> what are simple, independent assignments.
>>
>> Change the bitfield!() macro to generate `&mut self` setters, so each
>> operation is a distinct statement:
>>
>> reg.set_foo(x);
>> reg.set_sec(y);
>> reg.write(bar);
>
> Are you sure about this? It just seems like you're throwing out a neat little feature of Rust and
> replacing it with something that's very C-like. This breaks compatible with all users of the regs
> macros. Seems really disruptive for what seems to me like a cosmetic change.
>
It's only a neat feature if it *does* something. In this case, it *looks*
like a neat Rust feature, but under the covers it really is just handing
around copies unnecessarily, when really, it *is* doing the C-like thing
in the end.
I object to the fake Rust-ness that's being done here. It's like putting
hubcabs on a car.
thanks,
--
John Hubbard
next prev parent reply other threads:[~2025-12-31 22:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 21:47 John Hubbard
2025-12-31 22:33 ` Timur Tabi
2025-12-31 22:47 ` John Hubbard [this message]
2026-01-01 0:15 ` Joel Fernandes
2026-01-01 0:46 ` John Hubbard
2026-01-01 2:42 ` Joel Fernandes
2026-01-01 2:52 ` John Hubbard
2026-01-01 4:05 ` Joel Fernandes
2026-01-01 4:28 ` Gary Guo
2026-01-01 10:01 ` Joel Fernandes
2026-01-01 8:42 ` kernel test robot
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=ec3e5da4-f944-4526-a339-3da8286c36d2@nvidia.com \
--to=jhubbard@nvidia.com \
--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=dakr@kernel.org \
--cc=epeer@nvidia.com \
--cc=gary@garyguo.net \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--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
all inboxes | Powered by JetHome®