linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Take ARCH_KMALLOC_MINALIGN into account for build-time XArray check
@ 2025-07-15 13:46 Alice Ryhl
  2025-07-15 13:46 ` [PATCH 1/2] rust: alloc: specify the minimum alignment of each allocator Alice Ryhl
  2025-07-15 13:46 ` [PATCH 2/2] rust: alloc: take the allocator into account for FOREIGN_ALIGN Alice Ryhl
  0 siblings, 2 replies; 11+ messages in thread
From: Alice Ryhl @ 2025-07-15 13:46 UTC (permalink / raw)
  To: Lorenzo Stoakes, Liam R. Howlett, Andrew Morton, Danilo Krummrich,
	Matthew Wilcox, Tamir Duberstein, Andreas Hindborg, Miguel Ojeda
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Trevor Gross, linux-mm, rust-for-linux, linux-kernel, Alice Ryhl

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@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      | 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@google.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-07-16  9:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 13:46 [PATCH 0/2] Take ARCH_KMALLOC_MINALIGN into account for build-time XArray check Alice Ryhl
2025-07-15 13:46 ` [PATCH 1/2] rust: alloc: specify the minimum alignment of each allocator Alice Ryhl
2025-07-15 14:05   ` Danilo Krummrich
2025-07-15 14:35     ` Alice Ryhl
2025-07-15 14:39       ` Danilo Krummrich
2025-07-15 16:01   ` Benno Lossin
2025-07-15 13:46 ` [PATCH 2/2] rust: alloc: take the allocator into account for FOREIGN_ALIGN Alice Ryhl
2025-07-15 14:19   ` Danilo Krummrich
2025-07-16  9:46     ` Alice Ryhl
2025-07-15 16:00   ` Benno Lossin
2025-07-15 16:23     ` Danilo Krummrich

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).