[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8734frg5ae.fsf@kernel.org>
Date: Wed, 05 Mar 2025 11:06:49 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Benno Lossin" <benno.lossin@...ton.me>
Cc: "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>, "Alice
Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
"Danilo Krummrich" <dakr@...nel.org>, <linux-kernel@...r.kernel.org>,
<rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH 05/22] rust: pin-init: change examples to the user-space
version
"Benno Lossin" <benno.lossin@...ton.me> writes:
> Replace the examples in the documentation by the ones from the
> user-space version and introduce the standalone examples from the
> user-space version such as the `CMutex<T>` type.
>
> The `CMutex<T>` example from the pinned-init repository [1] is used in
> several documentation examples in the user-space version instead of the
> kernel `Mutex<T>` type (as it's not available). In order to split off
> the pin-init crate, all examples need to be free of kernel-specific
> types.
>
> Link: https://github.com/rust-for-Linux/pinned-init [1]
> Signed-off-by: Benno Lossin <benno.lossin@...ton.me>
> ---
> rust/pin-init/examples/big_struct_in_place.rs | 39 ++
> rust/pin-init/examples/error.rs | 27 ++
> rust/pin-init/examples/linked_list.rs | 161 ++++++++
> rust/pin-init/examples/mutex.rs | 209 ++++++++++
> rust/pin-init/examples/pthread_mutex.rs | 178 +++++++++
> rust/pin-init/examples/static_init.rs | 122 ++++++
Do I need to review all these data structures and algorithms?
[...]
> @@ -76,28 +84,34 @@
> //! above method only works for types where you can access the fields.
> //!
> //! ```rust,ignore
> -//! # use kernel::sync::{new_mutex, Arc, Mutex};
> -//! let mtx: Result<Arc<Mutex<usize>>> =
> -//! Arc::pin_init(new_mutex!(42, "example::mtx"), GFP_KERNEL);
> +//! # #![feature(allocator_api)]
> +//! # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
> +//! # use pin_init::*;
> +//! # use std::sync::Arc;
> +//! # use core::pin::Pin;
> +//! let mtx: Result<Pin<Arc<Mutex<usize>>>, _> = Arc::pin_init(CMutex::new(42));
> //! ```
Should this be `CMutex<_>` on the lhs?
Best regards,
Andreas Hindborg
Powered by blists - more mailing lists