[PATCH v17 11/16] rust: sync: Expose lock::Backend

Lyude Paul posted 16 patches 2 weeks, 2 days ago
[PATCH v17 11/16] rust: sync: Expose lock::Backend
Posted by Lyude Paul 2 weeks, 2 days ago
Due to the addition of sync::lock::Backend::Context, lock guards can be
returned with a different Backend than their respective lock. Since we'll
be adding a trait bound for Backend to GlobalGuard in order to support
this, users will need to be able to directly refer to Backend so that they
can use it in trait bounds.

So, let's make this easier for users and expose Backend in sync.

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 rust/kernel/sync.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
index 48a7cae86c50c..ce31154198cea 100644
--- a/rust/kernel/sync.rs
+++ b/rust/kernel/sync.rs
@@ -30,6 +30,7 @@
 pub use lock::spinlock::{
     new_spinlock, new_spinlock_irq, SpinLock, SpinLockGuard, SpinLockIrq, SpinLockIrqGuard,
 };
+pub use lock::Backend;
 pub use locked_by::LockedBy;
 pub use refcount::Refcount;
 pub use set_once::SetOnce;
-- 
2.52.0
Re: [PATCH v17 11/16] rust: sync: Expose lock::Backend
Posted by Benno Lossin 2 weeks ago
On Wed Jan 21, 2026 at 11:39 PM CET, Lyude Paul wrote:
> Due to the addition of sync::lock::Backend::Context, lock guards can be
> returned with a different Backend than their respective lock. Since we'll
> be adding a trait bound for Backend to GlobalGuard in order to support
> this, users will need to be able to directly refer to Backend so that they
> can use it in trait bounds.
>
> So, let's make this easier for users and expose Backend in sync.
>
> Signed-off-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Benno Lossin <lossin@kernel.org>

Cheers,
Benno

> ---
>  rust/kernel/sync.rs | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
> index 48a7cae86c50c..ce31154198cea 100644
> --- a/rust/kernel/sync.rs
> +++ b/rust/kernel/sync.rs
> @@ -30,6 +30,7 @@
>  pub use lock::spinlock::{
>      new_spinlock, new_spinlock_irq, SpinLock, SpinLockGuard, SpinLockIrq, SpinLockIrqGuard,
>  };
> +pub use lock::Backend;
>  pub use locked_by::LockedBy;
>  pub use refcount::Refcount;
>  pub use set_once::SetOnce;