From: Benno Lossin <benno.lossin@proton.me>
To: "Mitchell Levy" <levymitchell0@gmail.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>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Wedson Almeida Filho" <walmeida@microsoft.com>,
"Martin Rodriguez Reboredo" <yakoyoku@gmail.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
"Waiman Long" <longman@redhat.com>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] rust: lockdep: Use Pin for all LockClassKey usages
Date: Sun, 09 Feb 2025 09:57:00 +0000 [thread overview]
Message-ID: <fd129e8e-cd2c-4ff9-b3b4-9bdb28582e52@proton.me> (raw)
In-Reply-To: <20250207-rust-lockdep-v4-2-7a50a7e88656@gmail.com>
On 08.02.25 01:39, Mitchell Levy wrote:
> Reintroduce dynamically-allocated LockClassKeys such that they are
> automatically (de)registered. Require that all usages of LockClassKeys
> ensure that they are Pin'd.
>
> Currently, only `'static` LockClassKeys are supported, so Pin is
> redundant. However, it is intended that dynamically-allocated
> LockClassKeys will eventually be supported, so using Pin from the outset
> will make that change simpler.
>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1102
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Suggested-by: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Mitchell Levy <levymitchell0@gmail.com>
One nit below, but it's fine.
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
> ---
> rust/helpers/helpers.c | 1 +
> rust/helpers/sync.c | 13 ++++++++++
> rust/kernel/sync.rs | 57 ++++++++++++++++++++++++++++++++++++++---
> rust/kernel/sync/condvar.rs | 5 ++--
> rust/kernel/sync/lock.rs | 9 +++----
> rust/kernel/sync/lock/global.rs | 5 ++--
> rust/kernel/sync/poll.rs | 2 +-
> rust/kernel/workqueue.rs | 2 +-
> 8 files changed, 78 insertions(+), 16 deletions(-)
[...]
> diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs
> index eb80048e0110..6dafe338bbc7 100644
> --- a/rust/kernel/sync/lock.rs
> +++ b/rust/kernel/sync/lock.rs
> @@ -7,12 +7,9 @@
>
> use super::LockClassKey;
> use crate::{
> - init::PinInit,
> - pin_init,
> - str::CStr,
> - types::{NotThreadSafe, Opaque, ScopeGuard},
> + init::PinInit, pin_init, str::CStr, types::NotThreadSafe, types::Opaque, types::ScopeGuard,
Why does this change exist? I prefer imports to be merged.
---
Cheers,
Benno
> };
> -use core::{cell::UnsafeCell, marker::PhantomPinned};
> +use core::{cell::UnsafeCell, marker::PhantomPinned, pin::Pin};
> use macros::pin_data;
>
> pub mod mutex;
> @@ -129,7 +126,7 @@ unsafe impl<T: ?Sized + Send, B: Backend> Sync for Lock<T, B> {}
>
> impl<T, B: Backend> Lock<T, B> {
> /// Constructs a new lock initialiser.
> - pub fn new(t: T, name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self> {
> + pub fn new(t: T, name: &'static CStr, key: Pin<&'static LockClassKey>) -> impl PinInit<Self> {
> pin_init!(Self {
> data: UnsafeCell::new(t),
> _pin: PhantomPinned,
next prev parent reply other threads:[~2025-02-09 9:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-08 0:39 [PATCH v4 0/2] rust: lockdep: Fix soundness issue affecting LockClassKeys Mitchell Levy
2025-02-08 0:39 ` [PATCH v4 1/2] rust: lockdep: Remove support for dynamically allocated LockClassKeys Mitchell Levy
2025-02-08 0:39 ` [PATCH v4 2/2] rust: lockdep: Use Pin for all LockClassKey usages Mitchell Levy
2025-02-09 9:57 ` Benno Lossin [this message]
2025-02-10 5:40 ` Boqun Feng
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=fd129e8e-cd2c-4ff9-b3b4-9bdb28582e52@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=levymitchell0@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=walmeida@microsoft.com \
--cc=will@kernel.org \
--cc=yakoyoku@gmail.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