From: Tamir Duberstein <tamird@gmail.com>
To: Danilo Krummrich <dakr@kernel.org>
Cc: "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" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Matthew Wilcox" <willy@infradead.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Rob Herring (Arm)" <robh@kernel.org>,
"Maíra Canal" <mcanal@igalia.com>,
"Asahi Lina" <lina@asahilina.net>,
rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
"Fiona Behrens" <me@kloenk.dev>
Subject: Re: [PATCH v16 2/4] rust: types: add `ForeignOwnable::PointedTo`
Date: Mon, 17 Feb 2025 09:21:00 -0500 [thread overview]
Message-ID: <CAJ-ks9=TrFHiLFkRfyawNquDY2x6t3dwGi6FxnfgFLvQLYwc+A@mail.gmail.com> (raw)
In-Reply-To: <Z7NEZfuXSr3Ofh1G@cassiopeiae>
On Mon, Feb 17, 2025 at 9:15 AM Danilo Krummrich <dakr@kernel.org> wrote:
>
> On Mon, Feb 17, 2025 at 09:02:12AM -0500, Tamir Duberstein wrote:
> > > > diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
> > > > index 6c3bc14b42ad..eb25fabbff9c 100644
> > > > --- a/rust/kernel/pci.rs
> > > > +++ b/rust/kernel/pci.rs
> > > > @@ -73,6 +73,7 @@ extern "C" fn probe_callback(
> > > > match T::probe(&mut pdev, info) {
> > > > Ok(data) => {
> > > > let data = data.into_foreign();
> > > > + let data = data.cast();
> > >
> > > Same here and below, see also [2].
> >
> > You're the maintainer,
>
> This isn't true. I'm the original author, but I'm not an official maintainer of
> this code. :)
>
> > so I'll do what you ask here as well. I did it
> > this way because it avoids shadowing the git history with this change,
> > which I thought was the dominant preference.
>
> As mentioned in [2], if you do it the other way around first the "rust: types:
> add `ForeignOwnable::PointedTo`" patch and then the conversion to cast() it's
> even cleaner and less code to change.
This is true for the two instances of `as _`, but not for all the
other instances where currently there's no cast, but one is now
needed.
> >
> > > I understand you like this style and I'm not saying it's wrong or forbidden and
> > > for code that you maintain such nits are entirely up to you as far as I'm
> > > concerned.
> > >
> > > But I also don't think there is a necessity to convert things to your preference
> > > wherever you touch existing code.
> >
> > This isn't a conversion, it's a choice made specifically to avoid
> > touching code that doesn't need to be touched (in this instance).
>
> See above.
This doesn't address my point. I claim that
@@ -246,6 +248,7 @@ impl<T: MiscDevice> VtableHelper<T> {
) -> c_int {
// SAFETY: The release call of a file owns the private data.
let private = unsafe { (*file).private_data };
+ let private = private.cast();
// SAFETY: The release call of a file owns the private data.
let ptr = unsafe { <T::Ptr as ForeignOwnable>::from_foreign(private) };
is a better diff than
@@ -245,7 +245,7 @@ impl<T: MiscDevice> VtableHelper<T> {
file: *mut bindings::file,
) -> c_int {
// SAFETY: The release call of a file owns the private data.
- let private = unsafe { (*file).private_data };
+ let private = unsafe { (*file).private_data }.cast();
// SAFETY: The release call of a file owns the private data.
let ptr = unsafe { <T::Ptr as ForeignOwnable>::from_foreign(private) };
because it doesn't acquire the git blame on the existing line.
> >
> > > I already explicitly asked you not to do so in [3] and yet you did so while
> > > keeping my ACK. :(
> > >
> > > (Only saying the latter for reference, no need to send a new version of [3],
> > > otherwise I would have replied.)
> > >
> > > [2] https://lore.kernel.org/rust-for-linux/Z7MYNQgo28sr_4RS@cassiopeiae/
> > > [3] https://lore.kernel.org/rust-for-linux/20250213-aligned-alloc-v7-1-d2a2d0be164b@gmail.com/
> >
> > I will drop [2] and leave the `as _` casts in place to minimize
> > controversy here.
>
> As mentioned I think the conversion to cast() is great, just do it after this
> one and keep it a single line -- no controversy. :)
The code compiles either way, so I'll leave it untouched rather than
risk being scolded for sneaking unrelated changes.
next prev parent reply other threads:[~2025-02-17 14:21 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 13:58 [PATCH v16 0/4] rust: xarray: Add a minimal abstraction for XArray Tamir Duberstein
2025-02-07 13:58 ` [PATCH v16 1/4] rust: remove redundant `as _` casts Tamir Duberstein
2025-02-17 11:06 ` Danilo Krummrich
2025-02-07 13:58 ` [PATCH v16 2/4] rust: types: add `ForeignOwnable::PointedTo` Tamir Duberstein
2025-02-17 1:39 ` Benno Lossin
2025-02-17 1:58 ` Tamir Duberstein
2025-02-17 12:12 ` Danilo Krummrich
2025-02-17 14:02 ` Tamir Duberstein
2025-02-17 14:15 ` Danilo Krummrich
2025-02-17 14:21 ` Tamir Duberstein [this message]
2025-02-17 14:37 ` Danilo Krummrich
2025-02-17 14:47 ` Tamir Duberstein
2025-02-17 14:51 ` Danilo Krummrich
2025-02-17 15:50 ` Tamir Duberstein
2025-02-17 16:35 ` Danilo Krummrich
2025-02-17 17:03 ` Miguel Ojeda
2025-02-17 17:03 ` Miguel Ojeda
2025-02-17 17:03 ` Miguel Ojeda
2025-02-17 17:11 ` Tamir Duberstein
2025-02-17 17:24 ` Miguel Ojeda
2025-02-17 17:36 ` Miguel Ojeda
2025-02-17 17:43 ` Tamir Duberstein
2025-02-17 18:12 ` Miguel Ojeda
2025-02-17 18:24 ` Tamir Duberstein
2025-02-18 8:59 ` Andreas Hindborg
2025-02-07 13:58 ` [PATCH v16 3/4] rust: xarray: Add an abstraction for XArray Tamir Duberstein
2025-02-17 11:35 ` Danilo Krummrich
2025-02-17 13:43 ` Tamir Duberstein
2025-02-17 13:57 ` Danilo Krummrich
2025-02-07 13:58 ` [PATCH v16 4/4] MAINTAINERS: add entry for Rust XArray API Tamir Duberstein
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='CAJ-ks9=TrFHiLFkRfyawNquDY2x6t3dwGi6FxnfgFLvQLYwc+A@mail.gmail.com' \
--to=tamird@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=lina@asahilina.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mcanal@igalia.com \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=willy@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).