Skip to content

Take ARCH_KMALLOC_MINALIGN into account for build-time XArray check

Alice Ryhl linux-mm linux-next lkml rust-for-linux 2 versions – Applied

Status from this message: Applied to alloc-next, thanks!

Get series with b4
b4 am [email protected] change-id 20250715-align-min-allocator-b31aee53cbda

Versions newest first

  1. v2 Latest2 patches 13 repliesApplied
  2. v12 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- 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/[email protected]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2rust: alloc: specify the minimum alignment of each allocatorrust/kernel/alloc.rs rust/kernel/alloc/allocator.rs+16 -06 replies
2/2rust: alloc: take the allocator into account for FOREIGN_ALIGNrust/kernel/alloc/kbox.rs rust/kernel/sync/arc.rs+12 -70 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchBenno LossinAndreas HindborgLiam R. Howlett
SeriesR-b A-b
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 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.

Intended to land through alloc-next under the RUST [ALLOC] entry.

---
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/[email protected]

---
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,

Signature · 1 line
Alice Ryhl <[email protected]>