Re: [PATCH v17 05/10] rust: page: convert to `Ownable`
From: Andreas Hindborg
Date: Tue Jun 23 2026 - 09:14:17 EST
Alice Ryhl <aliceryhl@xxxxxxxxxx> writes:
> On Thu, Jun 04, 2026 at 10:11:17PM +0200, Andreas Hindborg wrote:
>> From: Asahi Lina <lina@xxxxxxxxxxxxx>
>>
>> This allows Page references to be returned as borrowed references,
>> without necessarily owning the struct page.
>>
>> Signed-off-by: Asahi Lina <lina@xxxxxxxxxxxxx>
>> [ Andreas: Fix formatting and add a safety comment. ]
>> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
>> ---
>> rust/kernel/page.rs | 38 +++++++++++++++++++++++++-------------
>> 1 file changed, 25 insertions(+), 13 deletions(-)
>>
>> diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
>> index 3bdcee0e16a8..844c75e54134 100644
>> --- a/rust/kernel/page.rs
>> +++ b/rust/kernel/page.rs
>> @@ -10,6 +10,11 @@
>> bindings,
>> error::code::*,
>> error::Result,
>> + types::{
>> + Opaque,
>> + Ownable,
>> + Owned, //
>> + },
>> uaccess::UserSliceReader, //
>> };
>> use core::{
>> @@ -105,7 +110,7 @@ pub const fn page_align(addr: usize) -> Option<usize> {
>> ///
>> /// [`VBox`]: kernel::alloc::VBox
>> /// [`Vmalloc`]: kernel::alloc::allocator::Vmalloc
>> -pub struct BorrowedPage<'a>(ManuallyDrop<Page>, PhantomData<&'a Page>);
>> +pub struct BorrowedPage<'a>(ManuallyDrop<NonNull<Page>>, PhantomData<&'a Page>);
>
> BorrowedPage<'a> is no longer needed because it's just &Page.
I'll add some cleaning then.
Best regards,
Andreas Hindborg