On Mon, 17 Nov 2025 10:07:57 +0000
Oliver Mangold <[email protected]> wrote:

> `AlwaysRefCounted` will become a marker trait to indicate that it is
> allowed to obtain an `ARef<T>` from a `&T`, which cannot be allowed for
> types which are also Ownable.

The message needs a rationale for making the change rather than relying
on the reader to deduce so.

For example:

        There are types where it may both be referenced counted in some
        cases and owned in other. 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.

Best,
Gary

> 
> Signed-off-by: Oliver Mangold <[email protected]>
> Co-developed-by: Andreas Hindborg <[email protected]>
> Signed-off-by: Andreas Hindborg <[email protected]>
> Suggested-by: Alice Ryhl <[email protected]>
> ---
>  rust/kernel/auxiliary.rs        |  7 +++++-
>  rust/kernel/block/mq/request.rs | 15 +++++++------
>  rust/kernel/cred.rs             | 13 ++++++++++--
>  rust/kernel/device.rs           | 13 ++++++++----
>  rust/kernel/device/property.rs  |  7 +++++-
>  rust/kernel/drm/device.rs       | 10 ++++++---
>  rust/kernel/drm/gem/mod.rs      | 10 ++++++---
>  rust/kernel/fs/file.rs          | 16 ++++++++++----
>  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        | 47 
> ++++++++++++++++++++++++++---------------
>  rust/kernel/task.rs             | 10 ++++++---
>  rust/kernel/types.rs            |  2 +-
>  18 files changed, 154 insertions(+), 61 deletions(-)

Reply via email to