From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: page: convert to `Ownable` Date: Mon, 23 Feb 2026 06:08:51 +1000 Message-ID: In-Reply-To: <20260220-unique-ref-v15-7-893ed86b06cc@kernel.org> References: <20260220-unique-ref-v15-0-893ed86b06cc@kernel.org> <20260220-unique-ref-v15-7-893ed86b06cc@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review This converts `Page` from having its own `Drop` impl to implementing `Ownable`, and changes the internal representation from `NonNull` to `Opaque` with `#[repr(transparent)]`. > +#[repr(transparent)] > pub struct Page { > - page: NonNull, > + page: Opaque, > } This is a significant representation change. `Page` is no longer pointer-sized; it's now the size of a `struct page`. All ownership goes through `Owned` (which is pointer-sized). The transparent repr is needed for the pointer casts between `Page` and `bindings::page` to be valid. > -pub struct BorrowedPage<'a>(ManuallyDrop, PhantomData<&'a Page>); > +pub struct BorrowedPage<'a>(ManuallyDrop>, PhantomData<&'a Owned>); The `ManuallyDrop>` prevents the `Owned::drop` from freeing the page when `BorrowedPage` goes out of scope. This preserves the existing borrow semantics. > + pub fn alloc_page(flags: Flags) -> Result, AllocError> { > ... > + Ok(unsafe { Owned::from_raw(page.cast()) }) The `page.cast()` converts `NonNull` to `NonNull`. Since `Page` is `#[repr(transparent)]` over `Opaque`, the cast is layout-compatible. > +unsafe impl Ownable for Page { > + unsafe fn release(this: NonNull) { > + unsafe { bindings::__free_pages(this.cast().as_ptr(), 0) }; `this.cast()` goes from `NonNull` to `NonNull` (inferred from `__free_pages` signature). Valid due to transparent layout. No bugs found in this patch. --- Generated by Claude Code Patch Reviewer