[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250715-align-min-allocator-v1-0-3e1b2a5516c0@google.com>
Date: Tue, 15 Jul 2025 13:46:33 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, "Liam R. Howlett" <Liam.Howlett@...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>
Cc: 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, Alice Ryhl <aliceryhl@...gle.com>
Subject: [PATCH 0/2] Take ARCH_KMALLOC_MINALIGN into account for build-time
XArray check
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.
This series is based on top of rust-next.
Signed-off-by: Alice Ryhl <aliceryhl@...gle.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 | 15 +++++++++++----
rust/kernel/sync/arc.rs | 6 +++---
4 files changed, 30 insertions(+), 7 deletions(-)
---
base-commit: a68a6bef0e75fb9e5aea1399d8538f4e3584dab1
change-id: 20250715-align-min-allocator-b31aee53cbda
Best regards,
--
Alice Ryhl <aliceryhl@...gle.com>
Powered by blists - more mailing lists