Hi, On 28/05/2024 17:58, Alice Ryhl wrote:
Adds a new struct called `Page` that wraps a pointer to `struct page`. This struct is assumed to hold ownership over the page, so that Rust code can allocate and manage pages directly. + +impl Drop for Page { + fn drop(&mut self) { + // SAFETY: By the type invariants, we have ownership of the page and can free it. + unsafe { bindings::__free_pages(self.page.as_ptr(), 0) }; + } +}
What about cases where the struct page pointer is not owned or allocated by this wrapper? For example, pages returned vmalloc_to_page()? Any thoughts about exposing a provision to avoid freeing those pages during Drop?
We've been experimenting in adapting this Page wrapper in advance for page management within the Nova DRM driver.
/Abdiel