Re: [PATCH 3/9] rust: sync: arc: relax `ForeignOwnable` for `Arc<T>`
From: Daniel Almeida
Date: Thu Sep 03 2026 - 10:14:59 EST
> On 1 Sep 2026, at 13:09, Ke Sun via B4 Relay <devnull+sunke.kylinos.cn@xxxxxxxxxx> wrote:
>
> From: Alvin Sun <alvin.sun@xxxxxxxxx>
>
> Drop the `'static` bound so that refcounted values borrowing from a
> driver registration scope can be foreign-owned by the XArray
> abstraction.
>
> Signed-off-by: Alvin Sun <alvin.sun@xxxxxxxxx>
> ---
> rust/kernel/sync/arc.rs | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> index 5ac4961b7cd20..cd6faba84ffcb 100644
> --- a/rust/kernel/sync/arc.rs
> +++ b/rust/kernel/sync/arc.rs
> @@ -363,11 +363,17 @@ pub fn into_unique_or_drop(this: Self) -> Option<Pin<UniqueArc<T>>> {
>
> // SAFETY: The pointer returned by `into_foreign` was originally allocated as an
> // `KBox<ArcInner<T>>`, so that type is what determines the alignment.
> -unsafe impl<T: 'static> ForeignOwnable for Arc<T> {
> +unsafe impl<T> ForeignOwnable for Arc<T> {
> const FOREIGN_ALIGN: usize = <KBox<ArcInner<T>> as ForeignOwnable>::FOREIGN_ALIGN;
>
> - type Borrowed<'a> = ArcBorrow<'a, T>;
> - type BorrowedMut<'a> = Self::Borrowed<'a>;
> + type Borrowed<'a>
> + = ArcBorrow<'a, T>
> + where
> + T: 'a;
> + type BorrowedMut<'a>
> + = Self::Borrowed<'a>
> + where
> + T: 'a;
>
> fn into_foreign(self) -> *mut c_void {
> ManuallyDrop::new(self).ptr.as_ptr().cast()
>
> --
> 2.43.0
>
>
Reviewed-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>