linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Danilo Krummrich <dakr@kernel.org>
Cc: lorenzo.stoakes@oracle.com, vbabka@suse.cz,
	Liam.Howlett@oracle.com,  urezki@gmail.com, ojeda@kernel.org,
	alex.gaynor@gmail.com,  boqun.feng@gmail.com, gary@garyguo.net,
	bjorn3_gh@protonmail.com,  lossin@kernel.org,
	a.hindborg@kernel.org, tmgross@umich.edu,
	 rust-for-linux@vger.kernel.org, linux-mm@kvack.org,
	 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Subject: Re: [PATCH] rust: alloc: add missing trait item MIN_ALIGN to Cmalloc
Date: Sun, 24 Aug 2025 14:36:25 +0200	[thread overview]
Message-ID: <CAH5fLgjkqcyzoZD7PP2i4g4r2uqpdbDKVW5hLfm6c9ysbxkPuw@mail.gmail.com> (raw)
In-Reply-To: <20250824120656.208978-1-dakr@kernel.org>

On Sun, Aug 24, 2025 at 2:07 PM Danilo Krummrich <dakr@kernel.org> wrote:
>
> Cmalloc is missing the trait item MIN_ALIGN introduced by commit
> 1b1a946dc2b5 ("rust: alloc: specify the minimum alignment of each
> allocator"), causing the following error on the `rusttest` make target.
>
>         error[E0046]: not all trait items implemented, missing: `MIN_ALIGN`
>            --> rust/kernel/alloc/allocator_test.rs:37:1
>             |
>         37  | unsafe impl Allocator for Cmalloc {
>             | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `MIN_ALIGN` in implementation
>             |
>            ::: rust/kernel/alloc.rs:146:5
>             |
>         146 |     const MIN_ALIGN: usize;
>             |     ---------------------- `MIN_ALIGN` from trait
>
> Implement MIN_ALIGN for Cmalloc to fix this.
>
> Reported-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> Closes: https://lore.kernel.org/all/CANiq72k0FSBTB2yOjiAy9PnAuyM=-PHxL3uQQ_Cv+zwswnr_bA@mail.gmail.com/
> Fixes: 1b1a946dc2b5 ("rust: alloc: specify the minimum alignment of each allocator")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>

Thanks for taking of it. Assuming a satisfactory answer to the quesiton below:

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

> ---
>  rust/kernel/alloc/allocator_test.rs | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/rust/kernel/alloc/allocator_test.rs b/rust/kernel/alloc/allocator_test.rs
> index a3074480bd8d..0d3c78ddcd69 100644
> --- a/rust/kernel/alloc/allocator_test.rs
> +++ b/rust/kernel/alloc/allocator_test.rs
> @@ -35,6 +35,8 @@
>  // - passing a pointer to a valid memory allocation created by this `Allocator` is always OK,
>  // - `realloc` provides the guarantees as provided in the `# Guarantees` section.
>  unsafe impl Allocator for Cmalloc {
> +    const MIN_ALIGN: usize = bindings::ARCH_KMALLOC_MINALIGN;

Is this the right value for normal malloc?

Alice


  reply	other threads:[~2025-08-24 12:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-24 12:06 Danilo Krummrich
2025-08-24 12:36 ` Alice Ryhl [this message]
2025-08-24 13:04   ` Danilo Krummrich
2025-08-24 13:18     ` Danilo Krummrich
2025-08-24 13:29       ` Danilo Krummrich
2025-08-24 14:07         ` Miguel Ojeda
2025-08-24 14:41           ` Danilo Krummrich

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=CAH5fLgjkqcyzoZD7PP2i4g4r2uqpdbDKVW5hLfm6c9ysbxkPuw@mail.gmail.com \
    --to=aliceryhl@google.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lossin@kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    /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