Re: [PATCH v3 2/2] rust: page: Extend support to existing struct page mappings
From: Abdiel Janulgue
Date: Fri Nov 22 2024 - 03:10:07 EST
On 21/11/2024 22:17, Jann Horn wrote:
Does Rust also prevent safe code from invoking inc_ref() on the
returned Page reference? Normally, the AlwaysRefCounted trait means
that safe code can create an owned reference from a shared reference,
right?
While it is possible for someone to *manually* convert the Page
reference returned in page_slice_to_page() to a refcounted Page (one
could wrap it in an ARef). However, by design, page_slice_to_page()
explicitly returns just an ordinary Page reference. We could add an
invariant in page_slice_to_page() to warn against such usage just in case.
Anyway seems like the consensus from the other thread is to avoid
refcounting the rust Page abstraction. If we go with that, then that
moots this issue.
Regards,
Abdiel