[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH5fLgiSt3Lc5+Rmcfg7frsy2y4o9yuj6LLqp6j0oNrzHRZGGA@mail.gmail.com>
Date: Tue, 15 Oct 2024 15:21:29 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Fiona Behrens <me@...enk.dev>
Cc: Abdiel Janulgue <abdiel.janulgue@...il.com>, rust-for-linux@...r.kernel.org,
dakr@...hat.com, linux-kernel@...r.kernel.org, lyude@...hat.com,
airlied@...hat.com, miguel.ojeda.sandonis@...il.com, boqun.feng@...il.com
Subject: Re: [PATCH 1/3] rust: page: replace the page pointer wrapper with Opaque
On Fri, Oct 11, 2024 at 1:07 PM Fiona Behrens <me@...enk.dev> wrote:
>
>
>
> On 7 Oct 2024, at 22:27, Abdiel Janulgue wrote:
>
> > Replace NonNull with Opaque to make it possible to cast to a Page pointer
> > from a raw struct page pointer.
> >
> > Signed-off-by: Abdiel Janulgue <abdiel.janulgue@...il.com>
> > ---
> > rust/kernel/page.rs | 19 +++++++++++++------
> > 1 file changed, 13 insertions(+), 6 deletions(-)
> >
> > diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
> > index 208a006d587c..08ff09a25223 100644
> > --- a/rust/kernel/page.rs
> > +++ b/rust/kernel/page.rs
> > @@ -8,8 +8,9 @@
> > error::code::*,
> > error::Result,
> > uaccess::UserSliceReader,
> > + types::Opaque,
> > };
> > -use core::ptr::{self, NonNull};
> > +use core::ptr::{self};
> >
> > /// A bitwise shift for the page size.
> > pub const PAGE_SHIFT: usize = bindings::PAGE_SHIFT as usize;
> > @@ -25,8 +26,9 @@
> > /// # Invariants
> > ///
> > /// The pointer is valid, and has ownership over the page.
> > +#[repr(transparent)]
> > pub struct Page {
> > - page: NonNull<bindings::page>,
> > + page: Opaque<bindings::page>,
>
> Still not to sure where to encode pinning in the type api. Looking into the C struct I see a union that sometimes holds a list head, should this then be a pinned thing in this type?
As long as you only hand out immutable references to it, nothing
further is necessary.
Alice
Powered by blists - more mailing lists