Gary Guo
b2516f7af9
rust: kernel: remove #[allow(clippy::new_ret_no_self)]
...
Clippy triggered a false positive on its `new_ret_no_self` lint
when using the `pin_init!` macro. Since Rust 1.67.0, that does
not happen anymore, since Clippy learnt to not warn about
`-> impl Trait<Self>` [1][2].
The kernel nowadays uses Rust 1.72.1, thus remove the `#[allow]`.
Signed-off-by: Gary Guo <[email protected] >
Reviewed-by: Alice Ryhl <[email protected] >
Reviewed-by: Benno Lossin <[email protected] >
Reviewed-by: Finn Behrens <[email protected] >
Reviewed-by: Martin Rodriguez Reboredo <[email protected] >
Link: https://github.com/rust-lang/rust-clippy/issues/7344 [1]
Link: https://github.com/rust-lang/rust-clippy/pull/9733 [2]
Link: https://lore.kernel.org/r/[email protected]
[ Reworded slightly and added a couple `Link`s. ]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-10-05 21:16:13 +02:00
Ben Gooding
db7193a5c9
rust: lock: Add intra-doc links to the Backend trait
...
Add missing intra-doc links to the Backend trait to make navigating the
documentation easier.
Suggested-by: Benno Lossin <[email protected] >
Link: https://lore.kernel.org/rust-for-linux/[email protected] /
Link: https://github.com/Rust-for-Linux/linux/issues/1001
Signed-off-by: Ben Gooding <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-08-07 11:33:33 +02:00
Wedson Almeida Filho
19096bce81
rust: sync: introduce CondVar
...
This is the traditional condition variable or monitor synchronisation
primitive. It is implemented with C's `wait_queue_head_t`.
It allows users to release a lock and go to sleep while guaranteeing
that notifications won't be missed. This is achieved by enqueuing a wait
entry before releasing the lock.
Cc: Peter Zijlstra <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Will Deacon <[email protected] >
Cc: Waiman Long <[email protected] >
Reviewed-by: Martin Rodriguez Reboredo <[email protected] >
Signed-off-by: Wedson Almeida Filho <[email protected] >
Reviewed-by: Alice Ryhl <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-04-22 01:46:45 +02:00
Wedson Almeida Filho
e32cca32c3
rust: lock: add Guard::do_unlocked
...
It releases the lock, executes some function provided by the caller,
then reacquires the lock. This is preparation for the implementation of
condvars, which will sleep after between unlocking and relocking.
We need an explicit `relock` method for primitives like `SpinLock` that
have an irqsave variant: we use the guard state to determine if the lock
was originally acquired with the regular `lock` function or
`lock_irqsave`.
Reviewed-by: Martin Rodriguez Reboredo <[email protected] >
Signed-off-by: Wedson Almeida Filho <[email protected] >
Link: https://lore.kernel.org/rust-for-linux/[email protected] /
[ Removed the irqsave bits as discussed. ]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-04-22 01:46:30 +02:00
Wedson Almeida Filho
7b1f55e3a9
rust: sync: introduce LockedBy
...
This allows us to have data protected by a lock despite not being
wrapped by it. Access is granted by providing evidence that the lock is
held by the caller.
Reviewed-by: Martin Rodriguez Reboredo <[email protected] >
Signed-off-by: Wedson Almeida Filho <[email protected] >
Reviewed-by: Benno Lossin <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-04-22 00:20:00 +02:00
Wedson Almeida Filho
c6d917a498
rust: lock: introduce SpinLock
...
This is the `spinlock_t` lock backend and allows Rust code to use the
kernel spinlock idiomatically.
Cc: Peter Zijlstra <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Will Deacon <[email protected] >
Cc: Waiman Long <[email protected] >
Reviewed-by: Martin Rodriguez Reboredo <[email protected] >
Signed-off-by: Wedson Almeida Filho <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-04-22 00:20:00 +02:00
Wedson Almeida Filho
6d20d629c6
rust: lock: introduce Mutex
...
This is the `struct mutex` lock backend and allows Rust code to use the
kernel mutex idiomatically.
Cc: Peter Zijlstra <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Will Deacon <[email protected] >
Cc: Waiman Long <[email protected] >
Reviewed-by: Martin Rodriguez Reboredo <[email protected] >
Signed-off-by: Wedson Almeida Filho <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-04-22 00:20:00 +02:00
Wedson Almeida Filho
76d4bd591e
rust: sync: introduce Lock and Guard
...
They are generic Rust implementations of a lock and a lock guard that
contain code that is common to all locks. Different backends will be
introduced in subsequent commits.
Reviewed-by: Martin Rodriguez Reboredo <[email protected] >
Suggested-by: Gary Guo <[email protected] >
Signed-off-by: Wedson Almeida Filho <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
[ Fixed typo. ]
Signed-off-by: Miguel Ojeda <[email protected] >
2023-04-22 00:19:42 +02:00