* [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist
@ 2025-08-18 18:08 Danilo Krummrich
2025-08-18 18:46 ` Alice Ryhl
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Danilo Krummrich @ 2025-08-18 18:08 UTC (permalink / raw)
To: lorenzo.stoakes, vbabka, Liam.Howlett, urezki, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross
Cc: rust-for-linux, linux-mm, Danilo Krummrich, Thorsten Leemhuis
For some architectures, such as X86_64, ARCH_KMALLOC_MINALIGN is not
resolvable for bindgen. E.g. due to being defined as
__alignof__(unsigned long long).
Hence, we have to create a rust helper, i.e. let the C compiler evaluate
the expression and store it in a const.
However, if for other architectures, such as arm64,
ARCH_KMALLOC_MINALIGN does evaluate to something that can be directly
processed by bindgen, we end up with multiple definitions of
ARCH_KMALLOC_MINALIGN in the generated bindings.
error[E0428]: the name `ARCH_KMALLOC_MINALIGN` is defined multiple times
--> /builddir/build/BUILD/kernel-6.17.0-build/kernel-next-20250818/linux-6.17.0-0.0.next.20250818.423.vanilla.fc44.aarch64/rust/bindings/bindings_generated.rs:134545:1
|
9622 | pub const ARCH_KMALLOC_MINALIGN: u32 = 8;
| ----------------------------------------- previous definition of the value `ARCH_KMALLOC_MINALIGN` here
...
134545 | pub const ARCH_KMALLOC_MINALIGN: usize = 8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ARCH_KMALLOC_MINALIGN` redefined here
|
= note: `ARCH_KMALLOC_MINALIGN` must be defined only once in the value namespace of this module
To fix this up, add ARCH_KMALLOC_MINALIGN to the blocklist of bindgen,
such that we always only generate the symbol from the rust helper.
Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
Closes: https://lore.kernel.org/all/8aa05f08-ef6e-4dfe-9453-beaab7b3cb98@leemhuis.info/
Fixes: 1b1a946dc2b5 ("rust: alloc: specify the minimum alignment of each allocator")
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
rust/bindgen_parameters | 1 +
1 file changed, 1 insertion(+)
diff --git a/rust/bindgen_parameters b/rust/bindgen_parameters
index 0f96af8b9a7f..02b371b98b39 100644
--- a/rust/bindgen_parameters
+++ b/rust/bindgen_parameters
@@ -34,3 +34,4 @@
# We use const helpers to aid bindgen, to avoid conflicts when constants are
# recognized, block generation of the non-helper constants.
--blocklist-item ARCH_SLAB_MINALIGN
+--blocklist-item ARCH_KMALLOC_MINALIGN
base-commit: 7e25d84f460c59322bf01dfeb1fb4745b488f714
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist
2025-08-18 18:08 [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist Danilo Krummrich
@ 2025-08-18 18:46 ` Alice Ryhl
2025-08-19 6:58 ` Thorsten Leemhuis
2025-08-19 18:02 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2025-08-18 18:46 UTC (permalink / raw)
To: Danilo Krummrich
Cc: lorenzo.stoakes, vbabka, Liam.Howlett, urezki, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, tmgross,
rust-for-linux, linux-mm, Thorsten Leemhuis
On Mon, Aug 18, 2025 at 8:09 PM Danilo Krummrich <dakr@kernel.org> wrote:
>
> For some architectures, such as X86_64, ARCH_KMALLOC_MINALIGN is not
> resolvable for bindgen. E.g. due to being defined as
> __alignof__(unsigned long long).
>
> Hence, we have to create a rust helper, i.e. let the C compiler evaluate
> the expression and store it in a const.
>
> However, if for other architectures, such as arm64,
> ARCH_KMALLOC_MINALIGN does evaluate to something that can be directly
> processed by bindgen, we end up with multiple definitions of
> ARCH_KMALLOC_MINALIGN in the generated bindings.
>
> error[E0428]: the name `ARCH_KMALLOC_MINALIGN` is defined multiple times
> --> /builddir/build/BUILD/kernel-6.17.0-build/kernel-next-20250818/linux-6.17.0-0.0.next.20250818.423.vanilla.fc44.aarch64/rust/bindings/bindings_generated.rs:134545:1
> |
> 9622 | pub const ARCH_KMALLOC_MINALIGN: u32 = 8;
> | ----------------------------------------- previous definition of the value `ARCH_KMALLOC_MINALIGN` here
> ...
> 134545 | pub const ARCH_KMALLOC_MINALIGN: usize = 8;
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ARCH_KMALLOC_MINALIGN` redefined here
> |
> = note: `ARCH_KMALLOC_MINALIGN` must be defined only once in the value namespace of this module
>
> To fix this up, add ARCH_KMALLOC_MINALIGN to the blocklist of bindgen,
> such that we always only generate the symbol from the rust helper.
>
> Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
> Closes: https://lore.kernel.org/all/8aa05f08-ef6e-4dfe-9453-beaab7b3cb98@leemhuis.info/
> Fixes: 1b1a946dc2b5 ("rust: alloc: specify the minimum alignment of each allocator")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist
2025-08-18 18:08 [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist Danilo Krummrich
2025-08-18 18:46 ` Alice Ryhl
@ 2025-08-19 6:58 ` Thorsten Leemhuis
2025-08-19 18:02 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Thorsten Leemhuis @ 2025-08-19 6:58 UTC (permalink / raw)
To: Danilo Krummrich, lorenzo.stoakes, vbabka, Liam.Howlett, urezki,
ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
a.hindborg, aliceryhl, tmgross
Cc: rust-for-linux, linux-mm
On 18.08.25 20:08, Danilo Krummrich wrote:
> For some architectures, such as X86_64, ARCH_KMALLOC_MINALIGN is not
> resolvable for bindgen. E.g. due to being defined as
> __alignof__(unsigned long long).
>
> Hence, we have to create a rust helper, i.e. let the C compiler evaluate
> the expression and store it in a const.
>
> However, if for other architectures, such as arm64,
> ARCH_KMALLOC_MINALIGN does evaluate to something that can be directly
> processed by bindgen, we end up with multiple definitions of
> ARCH_KMALLOC_MINALIGN in the generated bindings.
> [...]
Thx, applied it on today's -next and everything went smoothly:
Tested-by: Thorsten Leemhuis <linux@leemhuis.info>
Ciao, Thorsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist
2025-08-18 18:08 [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist Danilo Krummrich
2025-08-18 18:46 ` Alice Ryhl
2025-08-19 6:58 ` Thorsten Leemhuis
@ 2025-08-19 18:02 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Danilo Krummrich @ 2025-08-19 18:02 UTC (permalink / raw)
To: lorenzo.stoakes, vbabka, Liam.Howlett, urezki, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross
Cc: rust-for-linux, linux-mm, Thorsten Leemhuis
On Mon Aug 18, 2025 at 8:08 PM CEST, Danilo Krummrich wrote:
> For some architectures, such as X86_64, ARCH_KMALLOC_MINALIGN is not
> resolvable for bindgen. E.g. due to being defined as
> __alignof__(unsigned long long).
>
> Hence, we have to create a rust helper, i.e. let the C compiler evaluate
> the expression and store it in a const.
>
> However, if for other architectures, such as arm64,
> ARCH_KMALLOC_MINALIGN does evaluate to something that can be directly
> processed by bindgen, we end up with multiple definitions of
> ARCH_KMALLOC_MINALIGN in the generated bindings.
>
> error[E0428]: the name `ARCH_KMALLOC_MINALIGN` is defined multiple times
> --> /builddir/build/BUILD/kernel-6.17.0-build/kernel-next-20250818/linux-6.17.0-0.0.next.20250818.423.vanilla.fc44.aarch64/rust/bindings/bindings_generated.rs:134545:1
> |
> 9622 | pub const ARCH_KMALLOC_MINALIGN: u32 = 8;
> | ----------------------------------------- previous definition of the value `ARCH_KMALLOC_MINALIGN` here
> ...
> 134545 | pub const ARCH_KMALLOC_MINALIGN: usize = 8;
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ARCH_KMALLOC_MINALIGN` redefined here
> |
> = note: `ARCH_KMALLOC_MINALIGN` must be defined only once in the value namespace of this module
>
> To fix this up, add ARCH_KMALLOC_MINALIGN to the blocklist of bindgen,
> such that we always only generate the symbol from the rust helper.
>
> Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
> Closes: https://lore.kernel.org/all/8aa05f08-ef6e-4dfe-9453-beaab7b3cb98@leemhuis.info/
> Fixes: 1b1a946dc2b5 ("rust: alloc: specify the minimum alignment of each allocator")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Applied to alloc-next, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-19 18:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 18:08 [PATCH] rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist Danilo Krummrich
2025-08-18 18:46 ` Alice Ryhl
2025-08-19 6:58 ` Thorsten Leemhuis
2025-08-19 18:02 ` 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).