[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d3vt33v5jkhv7xp2yvl65sc2n6uiytrojgyj63voz7oilxxvr2@c6niknhbfiep>
Date: Tue, 12 Aug 2025 13:41:37 -0400
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Danilo Krummrich <dakr@...nel.org>,
Matthew Wilcox <willy@...radead.org>,
Tamir Duberstein <tamird@...il.com>,
Andreas Hindborg <a.hindborg@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
linux-mm@...ck.org, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 0/2] Take ARCH_KMALLOC_MINALIGN into account for
build-time XArray check
* Alice Ryhl <aliceryhl@...gle.com> [250811 08:32]:
> The Rust bindings for XArray include a build-time check to ensure that
> you can only use the XArray with pointers that are 4-byte aligned.
> Because of that, there is currently a build failure if you attempt to
> create an XArray<KBox<T>> where T is a 1-byte or 2-byte aligned type.
> However, this error is incorrect as KBox<_> is guaranteed to be a
> pointer that comes from kmalloc, and kmalloc always produces pointers
> that are at least 4-byte aligned.
>
> To fix this, we augment the compile-time logic that computes the
> alignment of KBox<_> to take the minimum alignment of its allocator into
> account.
>
> Intended to land through alloc-next under the RUST [ALLOC] entry.
>
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
Acked-by: Liam R. Howlett <Liam.Howlett@...cle.com>
> ---
> Changes in v2:
> - Reword guarantee on `const MIN_ALIGN`.
> - Change formatting of if/else in kbox.rs.
> - Rebase on v6.17-rc1.
> - Link to v1: https://lore.kernel.org/r/20250715-align-min-allocator-v1-0-3e1b2a5516c0@google.com
>
> ---
> Alice Ryhl (2):
> rust: alloc: specify the minimum alignment of each allocator
> rust: alloc: take the allocator into account for FOREIGN_ALIGN
>
> rust/kernel/alloc.rs | 8 ++++++++
> rust/kernel/alloc/allocator.rs | 8 ++++++++
> rust/kernel/alloc/kbox.rs | 13 +++++++++----
> rust/kernel/sync/arc.rs | 6 +++---
> 4 files changed, 28 insertions(+), 7 deletions(-)
> ---
> base-commit: 062b3e4a1f880f104a8d4b90b767788786aa7b78
> change-id: 20250715-align-min-allocator-b31aee53cbda
>
> Best regards,
> --
> Alice Ryhl <aliceryhl@...gle.com>
>
Powered by blists - more mailing lists