Re: [PATCH 2/6] rust: page: Convert to Ownable

From: Andreas Hindborg
Date: Wed Feb 19 2025 - 04:07:41 EST


"Asahi Lina" <lina@xxxxxxxxxxxxx> writes:

> This allows Page references to be returned as borrowed references,
> without necessarily owning the struct page.
>
> Signed-off-by: Asahi Lina <lina@xxxxxxxxxxxxx>
> ---
> rust/kernel/page.rs | 30 ++++++++++++++++--------------
> 1 file changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
> index fdac6c375fe46e1ba589f1640afeae3e001e39ae..0b6cbe02522ab6e6e1810288ad23af4e4aa587d8 100644
> --- a/rust/kernel/page.rs
> +++ b/rust/kernel/page.rs
> @@ -7,6 +7,7 @@
> bindings,
> error::code::*,
> error::Result,
> + types::{Opaque, Ownable, Owned},
> uaccess::UserSliceReader,
> };
> use core::ptr::{self, NonNull};
> @@ -30,13 +31,10 @@ pub const fn page_align(addr: usize) -> usize {
> (addr + (PAGE_SIZE - 1)) & PAGE_MASK
> }
>
> -/// A pointer to a page that owns the page allocation.
> -///
> -/// # Invariants
> -///
> -/// The pointer is valid, and has ownership over the page.
> +/// An object representing a memory page in the kernel (`struct page`).

Can you link to the header file containing `struct page`?

.. memory page in the kernel ([`struct page`]).

[`struct page`]: srctree/include/linux/mm_types.h

Otherwise looks good 👍


Best regards,
Andreas Hindborg