From: Boqun Feng <boqun.feng@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Daniel Almeida" <daniel.almeida@collabora.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@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>,
"Trevor Gross" <tmgross@umich.edu>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: irq: add support for request_irq()
Date: Wed, 15 Jan 2025 08:00:22 -0800 [thread overview]
Message-ID: <Z4fblpj57QgW_-5M@boqun-archlinux> (raw)
In-Reply-To: <CAH5fLgj6Wnrn6Ois+MbX16j2szRsBEgqVyArcGwhjEK52JnD3Q@mail.gmail.com>
On Wed, Jan 15, 2025 at 03:42:44PM +0100, Alice Ryhl wrote:
> On Wed, Jan 15, 2025 at 3:39 PM Boqun Feng <boqun.feng@gmail.com> wrote:
> >
> > On Wed, Jan 15, 2025 at 09:27:39AM +0100, Alice Ryhl wrote:
> > > On Wed, Jan 15, 2025 at 1:47 AM Boqun Feng <boqun.feng@gmail.com> wrote:
> > > >
> > > > On Tue, Jan 14, 2025 at 03:57:57PM -0300, Daniel Almeida wrote:
> > > > >
> > > > > >
> > > > > > It's not the pin_init! stuff, but the Opaque stuff. If it fails, then
> > > > > > it runs the destructor of Opaque<T>, which does *not* run the
> > > > > > destructor of T.
> > > > > >
> > > > > > Alice
> > > > >
> > > > > This is pretty unintuitive if you take into account trivial examples like
> > > > >
> > > > > ```
> > > > > struct Foo(T)
> > > > > ```
> > > > >
> > > > > Where dropping Foo drops T.
> > > > >
> > > > > Is there any reason why dropping Opaque<T> doesn’t behave similarly?
> > > > >
> > > >
> > > > Because `Opaque` implies the value may not be initialized, it's similar
> > > > to `MaybeUninit`.
> > > >
> > > > Do you really need the `Opaque` here? C code won't touch `handler` if
> > > > I'm not missing anything.
> > >
> > > The irq callback is given access to handler, so it could touch it at any time.
> > >
> >
> > You're right it could, but would it? C code doesn't know the concrete
> > type of the handler, so what it usually does is just passing the
> > pointers to the Rust code (again).
> >
> > A similar case the `func` field in `ClosureWork`: it doesn't need to be
> > `Opaque`, although workqueue callback may access it.
> >
> > Am I missing something here? Daniel, why this has to be `Opaque`? Could
> > you explain?
>
> It needs to be !Unpin, otherwise it's not safe for Rust to access the
> pointer. ClosureWork is not the same because there are no *other*
Could you elaborate it, maybe with an example? I asked because the data
wrapped by `handler` can only be exposed as an immutable reference to
safe Rust code, so how could Rust code access unsafely? The pointers are
always not noalias in Rust PoV. Thanks!
Regards,
Boqun
> references to it than the workqueue.
>
> Alice
next prev parent reply other threads:[~2025-01-15 16:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 14:20 [PATCH] rust: irq: add support for request_irq() Daniel Almeida
2024-10-24 15:05 ` Miguel Ojeda
2024-10-24 15:08 ` Daniel Almeida
2024-10-27 5:30 ` kernel test robot
2024-10-28 15:29 ` Alice Ryhl
2024-11-04 20:10 ` Daniel Almeida
2024-11-06 11:17 ` Alice Ryhl
2024-10-29 11:59 ` Alice Ryhl
2024-11-04 19:19 ` Daniel Almeida
2025-01-13 14:42 ` Alice Ryhl
2025-01-14 18:34 ` Daniel Almeida
2025-01-14 18:36 ` Alice Ryhl
2025-01-14 18:57 ` Daniel Almeida
2025-01-15 0:45 ` Boqun Feng
2025-01-15 8:27 ` Alice Ryhl
2025-01-15 14:39 ` Boqun Feng
2025-01-15 14:42 ` Alice Ryhl
2025-01-15 16:00 ` Boqun Feng [this message]
2025-01-15 15:37 ` Daniel Almeida
2025-01-15 11:38 ` Gary Guo
2025-01-15 12:31 ` Daniel Almeida
2025-01-16 8:29 ` Alice Ryhl
2025-01-19 17:50 ` Boqun Feng
2025-01-15 11:42 ` Gary Guo
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=Z4fblpj57QgW_-5M@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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