diff options
| author | 2023-03-27 15:43:08 -0300 | |
|---|---|---|
| committer | 2023-04-22 01:46:30 +0200 | |
| commit | e32cca32c3d452a277884502b9155f3325caf80e (patch) | |
| tree | 23cb2737222c1585c8ac6a0c2e64045503f28c69 /rust/kernel/sync/lock | |
| parent | rust: sync: introduce `LockedBy` (diff) | |
| download | wireguard-linux-e32cca32c3d452a277884502b9155f3325caf80e.tar.xz wireguard-linux-e32cca32c3d452a277884502b9155f3325caf80e.zip | |
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 <yakoyoku@gmail.com>
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
Link: https://lore.kernel.org/rust-for-linux/20230412121431.41627-1-wedsonaf@gmail.com/
[ Removed the irqsave bits as discussed. ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/sync/lock')
| -rw-r--r-- | rust/kernel/sync/lock/spinlock.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/rust/kernel/sync/lock/spinlock.rs b/rust/kernel/sync/lock/spinlock.rs index a52d20fc9755..979b56464a4e 100644 --- a/rust/kernel/sync/lock/spinlock.rs +++ b/rust/kernel/sync/lock/spinlock.rs @@ -87,7 +87,8 @@ pub type SpinLock<T> = super::Lock<T, SpinLockBackend>; /// A kernel `spinlock_t` lock backend. pub struct SpinLockBackend; -// SAFETY: The underlying kernel `spinlock_t` object ensures mutual exclusion. +// SAFETY: The underlying kernel `spinlock_t` object ensures mutual exclusion. `relock` uses the +// default implementation that always calls the same locking method. unsafe impl super::Backend for SpinLockBackend { type State = bindings::spinlock_t; type GuardState = (); |
