Re: [PATCH 2/4] rust: mm: Add task_size() method to Mm

From: Gary Guo

Date: Mon Apr 20 2026 - 13:15:55 EST


On Fri Apr 17, 2026 at 2:05 AM BST, Alvin Sun wrote:
> Add a task_size() method to the Mm struct to expose the process
> virtual address space size. This is used by the Tyr driver's VmLayout
> to determine the user VA range when VmUserSize::Auto is specified.
>
> Signed-off-by: Alvin Sun <alvin.sun@xxxxxxxxx>
> ---
> rust/kernel/mm.rs | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/rust/kernel/mm.rs b/rust/kernel/mm.rs
> index 4764d7b68f2a7..c6ba4da52688b 100644
> --- a/rust/kernel/mm.rs
> +++ b/rust/kernel/mm.rs
> @@ -149,6 +149,13 @@ pub fn mmget_not_zero(&self) -> Option<ARef<MmWithUser>> {
> None
> }
> }
> +
> + /// Returns task size for this mm_struct.
> + #[inline]
> + pub fn task_size(&self) -> u64 {

Why is this u64 instead of usize?

Best,
Gary

> + // SAFETY: self.as_raw() is a valid pointer to an mm_struct.
> + unsafe { (*self.as_raw()).__bindgen_anon_1.task_size as u64 }
> + }
> }
>
> // These methods require `mm_users` to be non-zero.