rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Abdiel Janulgue <abdiel@redhat.com>
To: Alice Ryhl <aliceryhl@google.com>,
	Miguel Ojeda <ojeda@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>
Cc: "Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@samsung.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Trevor Gross" <tmgross@umich.edu>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	rust-for-linux@vger.kernel.org,
	"Christian Brauner" <brauner@kernel.org>,
	"Danilo Krummrich" <dakr@redhat.com>
Subject: Re: [PATCH v7 4/4] rust: add abstraction for `struct page`
Date: Mon, 10 Jun 2024 23:46:55 +0300	[thread overview]
Message-ID: <882a4ba5-b0ef-4c21-8167-e2949424912c@redhat.com> (raw)
In-Reply-To: <20240528-alice-mm-v7-4-78222c31b8f4@google.com>

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


  reply	other threads:[~2024-06-10 20:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 14:58 [PATCH v7 0/4] Memory management patches needed by Rust Binder Alice Ryhl
2024-05-28 14:58 ` [PATCH v7 1/4] rust: uaccess: add userspace pointers Alice Ryhl
2024-05-28 14:58 ` [PATCH v7 2/4] uaccess: always export _copy_[from|to]_user with CONFIG_RUST Alice Ryhl
2024-06-11 21:44   ` Andrew Morton
2024-09-22  7:08   ` Sasha Levin
2024-09-22  7:52     ` Arnd Bergmann
2024-09-22 13:16       ` Sasha Levin
2024-05-28 14:58 ` [PATCH v7 3/4] rust: uaccess: add typed accessors for userspace pointers Alice Ryhl
2024-05-28 14:58 ` [PATCH v7 4/4] rust: add abstraction for `struct page` Alice Ryhl
2024-06-10 20:46   ` Abdiel Janulgue [this message]
2024-06-11  8:51     ` Alice Ryhl
2024-07-09  8:02 ` [PATCH v7 0/4] Memory management patches needed by Rust Binder Miguel Ojeda
2024-07-09  9:46   ` Alice Ryhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=882a4ba5-b0ef-4c21-8167-e2949424912c@redhat.com \
    --to=abdiel@redhat.com \
    --cc=a.hindborg@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=arnd@arndb.de \
    --cc=arve@android.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cmllamas@google.com \
    --cc=dakr@redhat.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=joel@joelfernandes.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maco@android.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=tkjos@android.com \
    --cc=tmgross@umich.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wedsonaf@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).