Re: [PATCH v7 4/4] rust: add abstraction for `struct page`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux