[PATCH v17 06/10] rust: rename `AlwaysRefCounted` to `RefCounted`.
Andreas Hindborg
a.hindborg at kernel.org
Wed Jun 24 19:17:08 UTC 2026
Onur Özkan <work at onurozkan.dev> writes:
> On Thu, 04 Jun 2026 22:11:18 +0200
> Andreas Hindborg <a.hindborg at kernel.org> wrote:
>
>> From: Oliver Mangold <oliver.mangold at pm.me>
>>
>> There are types where it may both be reference counted in some cases and
>> owned in others. In such cases, obtaining `ARef<T>` from `&T` would be
>> unsound as it allows creation of `ARef<T>` copy from `&Owned<T>`.
>>
>> Therefore, we split `AlwaysRefCounted` into `RefCounted` (which `ARef<T>`
>> would require) and a marker trait to indicate that the type is always
>> reference counted (and not `Ownable`) so the `&T` -> `ARef<T>` conversion
>> is possible.
>>
>> - Rename `AlwaysRefCounted` to `RefCounted`.
>> - Add a new unsafe trait `AlwaysRefCounted`.
>> - Implement the new trait `AlwaysRefCounted` for the newly renamed
>> `RefCounted` implementations. This leaves functionality of existing
>> implementers of `AlwaysRefCounted` intact.
>>
>> Suggested-by: Alice Ryhl <aliceryhl at google.com>
>> Reviewed-by: Daniel Almeida <daniel.almeida at collabora.com>
>> Signed-off-by: Oliver Mangold <oliver.mangold at pm.me>
>> [ Andreas: Updated commit message and rebase on rust-6.20-7.0 ]
>> Acked-by: Igor Korotin <igor.korotin.linux at gmail.com>
>> Acked-by: Danilo Krummrich <dakr at kernel.org>
>> Acked-by: Viresh Kumar <viresh.kumar at linaro.org>
>> Reviewed-by: Gary Guo <gary at garyguo.net>
>> Co-developed-by: Andreas Hindborg <a.hindborg at kernel.org>
>> Signed-off-by: Andreas Hindborg <a.hindborg at kernel.org>
>> ---
>> rust/kernel/auxiliary.rs | 7 +++++-
>> rust/kernel/block/mq/request.rs | 15 ++++++++-----
>> rust/kernel/cred.rs | 13 +++++++++--
>> rust/kernel/device.rs | 12 ++++++++--
>> rust/kernel/device/property.rs | 11 +++++++--
>> rust/kernel/drm/device.rs | 9 ++++++--
>> rust/kernel/drm/gem/mod.rs | 16 ++++++++++----
>> rust/kernel/fs/file.rs | 16 ++++++++++----
>> rust/kernel/i2c.rs | 13 ++++++++---
>> rust/kernel/mm.rs | 15 +++++++++----
>> rust/kernel/mm/mmput_async.rs | 9 ++++++--
>> rust/kernel/opp.rs | 10 ++++++---
>> rust/kernel/owned.rs | 2 +-
>> rust/kernel/pci.rs | 10 ++++++++-
>> rust/kernel/pid_namespace.rs | 12 ++++++++--
>> rust/kernel/platform.rs | 7 +++++-
>> rust/kernel/sync/aref.rs | 49 ++++++++++++++++++++++++++---------------
>> rust/kernel/task.rs | 13 +++++++++--
>> rust/kernel/types.rs | 3 ++-
>> rust/kernel/usb.rs | 17 +++++++++++---
>> 20 files changed, 195 insertions(+), 64 deletions(-)
>>
>> diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
>> index 93c0db1f6655..49f07740f657 100644
>> --- a/rust/kernel/auxiliary.rs
>> +++ b/rust/kernel/auxiliary.rs
>> @@ -19,6 +19,7 @@
>> to_result, //
>> },
>> prelude::*,
>> + sync::aref::{AlwaysRefCounted, RefCounted},
>
> This patch has multiple horizontal use statements around.
Thanks, I'll take another pass to fix that.
Best regards,
Andreas Hindborg
More information about the Linux-security-module-archive
mailing list