[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fd129e8e-cd2c-4ff9-b3b4-9bdb28582e52@proton.me>
Date: Sun, 09 Feb 2025 09:57:00 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Mitchell Levy <levymitchell0@...il.com>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, Wedson Almeida Filho <walmeida@...rosoft.com>, Martin Rodriguez Reboredo <yakoyoku@...il.com>, Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>, Waiman Long <longman@...hat.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/2] rust: lockdep: Use Pin for all LockClassKey usages
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@...ton.me>
> Suggested-by: Boqun Feng <boqun.feng@...il.com>
> Signed-off-by: Mitchell Levy <levymitchell0@...il.com>
One nit below, but it's fine.
Reviewed-by: Benno Lossin <benno.lossin@...ton.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,
Powered by blists - more mailing lists