Re: [PATCH v11 1/8] mm: rust: add abstraction for struct mm_struct
From: Alice Ryhl
Date: Fri Jan 17 2025 - 07:47:40 EST
On Fri, Jan 17, 2025 at 1:45 AM Balbir Singh <balbirs@xxxxxxxxxx> wrote:
>
> On 12/11/24 21:37, Alice Ryhl wrote:
> > These abstractions allow you to reference a `struct mm_struct` using
> > both mmgrab and mmget refcounts. This is done using two Rust types:
> >
> > * Mm - represents an mm_struct where you don't know anything about the
> > value of mm_users.
> > * MmWithUser - represents an mm_struct where you know at compile time
> > that mm_users is non-zero.
> >
> > This allows us to encode in the type system whether a method requires
> > that mm_users is non-zero or not. For instance, you can always call
> > `mmget_not_zero` but you can only call `mmap_read_lock` when mm_users is
> > non-zero.
> >
> > It's possible to access current->mm without a refcount increment, but
> > that is added in a later patch of this series.
> >
> > Acked-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> (for mm bits)
> > Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> > ---
>
> It might be good to add some #Examples similar to kernel/task.rs
You're probably right.
> Acked-by: Balbir Singh <balbirs@xxxxxxxxxx>
I'll pick this up for v13 since I already sent v12. Thanks!
Alice