[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230429012119.421536-1-ojeda@kernel.org>
Date: Sat, 29 Apr 2023 03:21:19 +0200
From: Miguel Ojeda <ojeda@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Miguel Ojeda <ojeda@...nel.org>,
Wedson Almeida Filho <wedsonaf@...il.com>,
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>,
Benno Lossin <benno.lossin@...ton.me>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [GIT PULL] Rust for 6.4
Hi Linus,
One more set of core features for the Rust support.
The youngest commits have been in linux-next for 5 rounds; the older
half for 2 weeks.
No conflicts expected. No changes to the C side.
Please pull for v6.4 -- thanks!
Cheers,
Miguel
The following changes since commit 09a9639e56c01c7a00d6c0ca63f4c7c41abe075d:
Linux 6.3-rc6 (2023-04-09 11:15:57 -0700)
are available in the Git repository at:
https://github.com/Rust-for-Linux/linux tags/rust-6.4
for you to fetch changes up to ea76e08f4d901a450619831a255e9e0a4c0ed162:
rust: ioctl: Add ioctl number manipulation functions (2023-04-22 01:46:45 +0200)
----------------------------------------------------------------
Rust changes for v6.4
More additions to the Rust core. Importantly, this adds the pin-init
API, which will be used by other abstractions, such as the
synchronization ones added here too:
- pin-init API: a solution for the safe pinned initialization problem.
This allows to reduce the need for 'unsafe' code in the kernel when
dealing with data structures that require a stable address. Commit
90e53c5e70a6 ("rust: add pin-init API core") contains a nice
introduction -- here is an example of how it looks like:
#[pin_data]
struct Example {
#[pin]
value: Mutex<u32>,
#[pin]
value_changed: CondVar,
}
impl Example {
fn new() -> impl PinInit<Self> {
pin_init!(Self {
value <- new_mutex!(0),
value_changed <- new_condvar!(),
})
}
}
// In a `Box`.
let b = Box::pin_init(Example::new())?;
// In the stack.
stack_pin_init!(let s = Example::new());
- 'sync' module: new types 'LockClassKey' ('struct lock_class_key'),
'Lock', 'Guard', 'Mutex' ('struct mutex'), 'SpinLock'
('spinlock_t'), 'LockedBy' and 'CondVar' (uses 'wait_queue_head_t'),
plus macros such as 'static_lock_class!' and 'new_spinlock!'.
In particular, 'Lock' and 'Guard' are generic implementations that
contain code that is common to all locks. Then, different backends
(the new 'Backend' trait) are implemented and used to define types
like 'Mutex':
type Mutex<T> = Lock<T, MutexBackend>;
In addition, new methods 'assume_init()', 'init_with()' and
'pin_init_with()' for 'UniqueArc<MaybeUninit<T>>' and 'downcast()'
for 'Arc<dyn Any + Send + Sync>'; as well as 'Debug' and 'Display'
implementations for 'Arc' and 'UniqueArc'. Reduced stack usage of
'UniqueArc::try_new_uninit()', too.
- 'types' module: new trait 'AlwaysRefCounted' and new type 'ARef'
(an owned reference to an always-reference-counted object, meant to
be used in wrappers for C types that have their own ref counting
functions).
Moreover, new associated functions 'raw_get()' and 'ffi_init()'
for 'Opaque'.
- New 'task' module with a new type 'Task' ('struct task_struct'), and
a new macro 'current!' to safely get a reference to the current one.
- New 'ioctl' module with new '_IOC*' const functions (equivalent to
the C macros).
- New 'uapi' crate, intended to be accessible by drivers directly.
- 'macros' crate: new 'quote!' macro (similar to the one provided in
userspace by the 'quote' crate); and the 'module!' macro now allows
specifying multiple module aliases.
- 'error' module: new associated functions for the 'Error' type,
such as 'from_errno()' and new functions such as 'to_result()'.
- 'alloc' crate: more fallible 'Vec' methods: 'try_resize` and
'try_extend_from_slice' and the infrastructure (imported from
the Rust standard library) they need.
----------------------------------------------------------------
Asahi Lina (11):
rust: Enable the new_uninit feature for kernel and driver crates
rust: Import upstream `alloc::vec::set_len_on_drop` module
rust: Import upstream `alloc::vec::spec_extend` module
rust: Add SPDX headers to alloc::vec::{spec_extend, set_len_on_drop}
rust: macros: Allow specifying multiple module aliases
rust: sync: arc: Implement Arc<dyn Any + Send + Sync>::downcast()
rust: sync: arc: Add UniqueArc<MaybeUninit<T>::assume_init()
rust: error: Rename to_kernel_errno() -> to_errno()
rust: error: Add Error::to_ptr()
rust: uapi: Add UAPI crate
rust: ioctl: Add ioctl number manipulation functions
Benno Lossin (14):
rust: enable the `pin_macro` feature
rust: sync: change error type of constructor functions
rust: types: add `Opaque::raw_get`
rust: add pin-init API core
rust: init: add initialization macros
rust: init/sync: add `InPlaceInit` trait to pin-initialize smart pointers
rust: init: add `PinnedDrop` trait and macros
rust: init: add `stack_pin_init!` macro
rust: init: add `Zeroable` trait and `init::zeroed` function
rust: prelude: add `pin-init` API items to prelude
rust: types: add `Opaque::ffi_init`
rust: sync: reduce stack usage of `UniqueArc::try_new_uninit`
rust: sync: add functions for initializing `UniqueArc<MaybeUninit<T>>`
rust: init: broaden the blanket impl of `Init`
Boqun Feng (2):
rust: sync: impl {Debug,Display} for {Unique,}Arc
samples: rust: print: Add sample code for Arc printing
Gary Guo (1):
rust: macros: add `quote!` macro
Miguel Ojeda (3):
rust: alloc: vec: Add some try_* methods we need
rust: error: Add Error::from_errno{_unchecked}()
MAINTAINERS: add Benno Lossin as Rust reviewer
Sven Van Asbroeck (1):
rust: error: Add a helper to convert a C ERR_PTR to a `Result`
Wedson Almeida Filho (12):
rust: error: Add to_result() helper
rust: error: Add from_result() helper
rust: sync: introduce `LockClassKey`
rust: sync: introduce `Lock` and `Guard`
rust: lock: introduce `Mutex`
rust: lock: introduce `SpinLock`
rust: introduce `ARef`
rust: add basic `Task`
rust: introduce `current`
rust: sync: introduce `LockedBy`
rust: lock: add `Guard::do_unlocked`
rust: sync: introduce `CondVar`
MAINTAINERS | 1 +
rust/.gitignore | 1 +
rust/Makefile | 28 +-
rust/alloc/vec/mod.rs | 137 +++-
rust/alloc/vec/set_len_on_drop.rs | 30 +
rust/alloc/vec/spec_extend.rs | 174 +++++
rust/bindings/bindings_helper.h | 2 +
rust/helpers.c | 82 +++
rust/kernel/error.rs | 137 +++-
rust/kernel/init.rs | 1427 ++++++++++++++++++++++++++++++++++++
rust/kernel/init/__internal.rs | 235 ++++++
rust/kernel/init/macros.rs | 971 ++++++++++++++++++++++++
rust/kernel/ioctl.rs | 72 ++
rust/kernel/lib.rs | 10 +
rust/kernel/prelude.rs | 8 +-
rust/kernel/sync.rs | 50 ++
rust/kernel/sync/arc.rs | 108 ++-
rust/kernel/sync/arc/std_vendor.rs | 28 +
rust/kernel/sync/condvar.rs | 174 +++++
rust/kernel/sync/lock.rs | 191 +++++
rust/kernel/sync/lock/mutex.rs | 118 +++
rust/kernel/sync/lock/spinlock.rs | 117 +++
rust/kernel/sync/locked_by.rs | 156 ++++
rust/kernel/task.rs | 155 ++++
rust/kernel/types.rs | 135 ++++
rust/macros/helpers.rs | 10 +-
rust/macros/lib.rs | 80 ++
rust/macros/module.rs | 32 +-
rust/macros/pin_data.rs | 79 ++
rust/macros/pinned_drop.rs | 49 ++
rust/macros/quote.rs | 143 ++++
rust/uapi/lib.rs | 27 +
rust/uapi/uapi_helper.h | 9 +
samples/rust/rust_print.rs | 26 +
scripts/Makefile.build | 2 +-
35 files changed, 4980 insertions(+), 24 deletions(-)
create mode 100644 rust/alloc/vec/set_len_on_drop.rs
create mode 100644 rust/alloc/vec/spec_extend.rs
create mode 100644 rust/kernel/init.rs
create mode 100644 rust/kernel/init/__internal.rs
create mode 100644 rust/kernel/init/macros.rs
create mode 100644 rust/kernel/ioctl.rs
create mode 100644 rust/kernel/sync/arc/std_vendor.rs
create mode 100644 rust/kernel/sync/condvar.rs
create mode 100644 rust/kernel/sync/lock.rs
create mode 100644 rust/kernel/sync/lock/mutex.rs
create mode 100644 rust/kernel/sync/lock/spinlock.rs
create mode 100644 rust/kernel/sync/locked_by.rs
create mode 100644 rust/kernel/task.rs
create mode 100644 rust/macros/pin_data.rs
create mode 100644 rust/macros/pinned_drop.rs
create mode 100644 rust/macros/quote.rs
create mode 100644 rust/uapi/lib.rs
create mode 100644 rust/uapi/uapi_helper.h
Powered by blists - more mailing lists