linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Trevor Gross <tmgross@umich.edu>
To: Alice Ryhl <aliceryhl@google.com>
Cc: a.hindborg@samsung.com, akpm@linux-foundation.org,
	alex.gaynor@gmail.com,  arnd@arndb.de, arve@android.com,
	benno.lossin@proton.me,  bjorn3_gh@protonmail.com,
	boqun.feng@gmail.com, brauner@kernel.org,  cmllamas@google.com,
	gary@garyguo.net, gregkh@linuxfoundation.org,
	 joel@joelfernandes.org, keescook@chromium.org,
	linux-kernel@vger.kernel.org,  linux-mm@kvack.org,
	maco@android.com, ojeda@kernel.org,
	 rust-for-linux@vger.kernel.org, surenb@google.com,
	tkjos@android.com,  viro@zeniv.linux.org.uk, wedsonaf@gmail.com,
	willy@infradead.org
Subject: Re: [PATCH v5 4/4] rust: add abstraction for `struct page`
Date: Tue, 16 Apr 2024 13:47:56 -0400	[thread overview]
Message-ID: <CALNs47vUXA9z8+bM4TOU-Q_NY3wbux3OA4nBVxegAWykzTd2zQ@mail.gmail.com> (raw)
In-Reply-To: <20240416095333.1108884-1-aliceryhl@google.com>

On Tue, Apr 16, 2024 at 5:53 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> >> +/// Flags for the "get free page" function that underlies all memory allocations.
> >> +pub mod flags {
> >> +    /// gfp flags.
> >
> > Uppercase acronym, maybe with a description:
> >
> >     GFP (Get Free Page) flags.
> >
> >> +    #[allow(non_camel_case_types)]
> >> +    pub type gfp_t = bindings::gfp_t;
> >
> > Why not GfpFlags, do we do this elsewhere?
> >
> >> +    /// `GFP_KERNEL` is typical for kernel-internal allocations. The caller requires `ZONE_NORMAL`
> >> +    /// or a lower zone for direct access but can direct reclaim.
> >> +    pub const GFP_KERNEL: gfp_t = bindings::GFP_KERNEL;
> >> +    /// `GFP_ZERO` returns a zeroed page on success.
> >> +    pub const __GFP_ZERO: gfp_t = bindings::__GFP_ZERO;
> >> +    /// `GFP_HIGHMEM` indicates that the allocated memory may be located in high memory.
> >> +    pub const __GFP_HIGHMEM: gfp_t = bindings::__GFP_HIGHMEM;
> >
> > It feels a bit weird to have dunder constants on the rust side that
> > aren't also `#[doc(hidden)]` or just nonpublic. Makes me think they
> > are an implementation detail or not really meant to be used - could
> > you update the docs if this is the case?
>
> All of this is going away in the next version because it will be based
> on [1], which defines the gfp flags type for us.
>
> [1]: https://lore.kernel.org/rust-for-linux/20240328013603.206764-1-wedsonaf@gmail.com/

Great, thanks for the link.

> > Could you add an example of how to use this correctly?
>
> This is a private function, you're not supposed to use it directly.
> Anyone who is modifying this file directly can look at the existing
> users for examples.

Ah you're right, missed this bit.

Thanks for the followup.

Trevor


      reply	other threads:[~2024-04-16 17:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  7:13 [PATCH v5 0/4] Memory management patches needed by Rust Binder Alice Ryhl
2024-04-15  7:13 ` [PATCH v5 1/4] rust: uaccess: add userspace pointers Alice Ryhl
2024-04-15  9:36   ` Benno Lossin
2024-04-15  9:44     ` Alice Ryhl
2024-04-15  9:51       ` Benno Lossin
2024-04-15 21:53   ` Boqun Feng
2024-04-16  9:53     ` Alice Ryhl
2024-04-21 18:08       ` David Laight
2024-04-21 18:37         ` Alice Ryhl
2024-04-21 19:48           ` David Laight
2024-04-22  6:31             ` Alice Ryhl
2024-04-16  5:05   ` Trevor Gross
2024-04-16  9:53     ` Alice Ryhl
2024-04-17 14:28   ` Gary Guo
2024-04-17 14:40     ` Alice Ryhl
2024-04-17 15:27       ` Benno Lossin
2024-04-17 15:35         ` Alice Ryhl
2024-04-15  7:13 ` [PATCH v5 2/4] uaccess: always export _copy_[from|to]_user with CONFIG_RUST Alice Ryhl
2024-04-15 23:05   ` Kees Cook
2024-04-16  9:57     ` Alice Ryhl
2024-04-15  7:13 ` [PATCH v5 3/4] rust: uaccess: add typed accessors for userspace pointers Alice Ryhl
2024-04-16  5:53   ` Trevor Gross
2024-04-16  9:53     ` Alice Ryhl
2024-04-15  7:13 ` [PATCH v5 4/4] rust: add abstraction for `struct page` Alice Ryhl
2024-04-15  8:10   ` Andreas Hindborg
2024-04-15  9:54   ` Benno Lossin
2024-04-16  5:40   ` Trevor Gross
2024-04-16  9:53     ` Alice Ryhl
2024-04-16 17:47       ` Trevor Gross [this message]

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=CALNs47vUXA9z8+bM4TOU-Q_NY3wbux3OA4nBVxegAWykzTd2zQ@mail.gmail.com \
    --to=tmgross@umich.edu \
    --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=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=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