rust: Enable the new_uninit feature for kernel and driver crates
PATCH 1/1 rust: Enable the new_uninit feature for kernel and driver crates
The unstable new_uninit feature enables various library APIs to create uninitialized containers, such as Box::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.
Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using place!() or a future replacement macro which may itself live in kernel) in driver crates.
See [1] [2] [3] for background information.
[1] https://github.com/Rust-for-Linux/linux/issues/879
[2] https://github.com/Rust-for-Linux/linux/issues/2
[3] https://github.com/rust-lang/rust/issues/63291
--- rust/kernel/lib.rs | 1 + scripts/Makefile.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
rust/kernel/lib.rs +1 -0
@@ -17,6 +17,7 @@#![feature(core_ffi_c)] #![feature(dispatch_from_dyn)] #![feature(generic_associated_types)] +#![feature(new_uninit)] #![feature(receiver_trait)] #![feature(unsize)]
scripts/Makefile.build +1 -1
@@ -277,7 +277,7 @@ $(obj)/%.lst: $(src)/%.c FORCE # Compile Rust sources (.rs) # --------------------------------------------------------------------------- -rust_allowed_features := core_ffi_c +rust_allowed_features := core_ffi_c,new_uninit rust_common_cmd = \ RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \
---
base-commit: 83f978b63fa7ad474ca22d7e2772c5988101c9bd
change-id: 20230224-rust-new_uninit-a575d34987c3
Thank you,
~~ Lina
Quoted 8 lines · Asahi Lina
The unstable
new_uninitfeature enables various library APIs to create uninitialized containers, such asBox::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using
place!()or a future replacement macro which may itself live inkernel) in driver crates.
Very useful to me as some constructors in the USB bindings that I'm writting might make use of unitialized memory.
Quoted 9 lines · On Fri, 24 Feb 2023 17:09:47 +0900 Asahi Lina <[email protected]> wrote:
The unstable
new_uninitfeature enables various library APIs to create uninitialized containers, such asBox::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using
place!()or a future replacement macro which may itself live inkernel) in driver crates.
Quoted 7 lines
See [1] [2] [3] for background information.
[1] https://github.com/Rust-for-Linux/linux/issues/879
[2] https://github.com/Rust-for-Linux/linux/issues/2
[3] https://github.com/rust-lang/rust/issues/63291Signed-off-by Asahi Lina <[email protected]>
Quoted 38 lines
--- rust/kernel/lib.rs | 1 + scripts/Makefile.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)rust/kernel/lib.rs +1
-0@@ -17,6 +17,7 @@#![feature(core_ffi_c)] #![feature(dispatch_from_dyn)] #![feature(generic_associated_types)] +#![feature(new_uninit)] #![feature(receiver_trait)] #![feature(unsize)] scripts/Makefile.build +1
-2@@ -277,7 +277,7 @@ $(obj)/%.lst: $(src)/%.c FORCE # Compile Rust sources (.rs) # --------------------------------------------------------------------------- -rust_allowed_features := core_ffi_c +rust_allowed_features := core_ffi_c,new_uninit rust_common_cmd = \ RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \ ---base-commit:
83f978b63fa7ad474ca22d7e2772c5988101c9bd
change-id: 20230224-rust-new_uninit-a575d34987c3Thank you,
~~ Lina
Quoted 38 lines · Asahi Lina
The unstable
new_uninitfeature enables various library APIs to create uninitialized containers, such asBox::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using
place!()or a future replacement macro which may itself live inkernel) in driver crates.See [1] [2] [3] for background information.
[1] https://github.com/Rust-for-Linux/linux/issues/879
[2] https://github.com/Rust-for-Linux/linux/issues/2
[3] https://github.com/rust-lang/rust/issues/63291Signed-off-by Asahi Lina <[email protected]>--- rust/kernel/lib.rs | 1 + scripts/Makefile.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)rust/kernel/lib.rs +1
-0@@ -17,6 +17,7 @@#![feature(core_ffi_c)] #![feature(dispatch_from_dyn)] #![feature(generic_associated_types)] +#![feature(new_uninit)] #![feature(receiver_trait)] #![feature(unsize)] scripts/Makefile.build +0
-0
scripts/Makefile.build $(obj)/%.lst: $(src)/%.c FORCE · line 280
Quoted 5 lines
scripts/Makefile.build +1
-1@@ -277,7 +277,7 @@ $(obj)/%.lst: $(src)/%.c FORCE # Compile Rust sources (.rs) # --------------------------------------------------------------------------- -rust_allowed_features := core_ffi_c +rust_allowed_features := core_ffi_c,new_uninit
What is the purpose of adding the feature here? The kernel crate seems to compile fine without this.
BR Andreas
Quoted 44 lines · Andreas Hindborg
Quoted 41 lines · Asahi Lina
The unstable
new_uninitfeature enables various library APIs to create uninitialized containers, such asBox::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using
place!()or a future replacement macro which may itself live inkernel) in driver crates.See [1] [2] [3] for background information.
[1] https://github.com/Rust-for-Linux/linux/issues/879
[2] https://github.com/Rust-for-Linux/linux/issues/2
[3] https://github.com/rust-lang/rust/issues/63291Signed-off-by Asahi Lina <[email protected]>--- rust/kernel/lib.rs | 1 + scripts/Makefile.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)rust/kernel/lib.rs +1
-0@@ -17,6 +17,7 @@#![feature(core_ffi_c)] #![feature(dispatch_from_dyn)] #![feature(generic_associated_types)] +#![feature(new_uninit)] #![feature(receiver_trait)] #![feature(unsize)] scripts/Makefile.build +0
-0@@ -277,7 +277,7 @@ $(obj)/%.lst: $(src)/%.c FORCE # Compile Rust sources (.rs) # ---------------------------------------------------------------------------
Quoted 5 lines
scripts/Makefile.build $(obj)/%.lst: $(src)/%.c FORCE · line 280
Quoted 2 lines
scripts/Makefile.build +1
-1-rust_allowed_features := core_ffi_c +rust_allowed_features := core_ffi_c,new_uninitWhat is the purpose of adding the feature here? The kernel crate seems to compile fine without this.
It's for the upcoming DRM abstractions, as I mentioned in the commit message. There's so many dependencies that I'm trying to get as much as I can early to avoid having to review very big patchsets down the line ^^
~~ Lina
Andreas Hindborg
Reviewed-byQuoted 51 lines · Asahi Lina
Quoted 44 lines · Andreas Hindborg
Quoted 41 lines · Asahi Lina
The unstable
new_uninitfeature enables various library APIs to create uninitialized containers, such asBox::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using
place!()or a future replacement macro which may itself live inkernel) in driver crates.See [1] [2] [3] for background information.
[1] https://github.com/Rust-for-Linux/linux/issues/879
[2] https://github.com/Rust-for-Linux/linux/issues/2
[3] https://github.com/rust-lang/rust/issues/63291Signed-off-by Asahi Lina <[email protected]>--- rust/kernel/lib.rs | 1 + scripts/Makefile.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)rust/kernel/lib.rs +1
-0@@ -17,6 +17,7 @@#![feature(core_ffi_c)] #![feature(dispatch_from_dyn)] #![feature(generic_associated_types)] +#![feature(new_uninit)] #![feature(receiver_trait)] #![feature(unsize)] scripts/Makefile.build +0
-0@@ -277,7 +277,7 @@ $(obj)/%.lst: $(src)/%.c FORCE # Compile Rust sources (.rs) # ---------------------------------------------------------------------------Quoted 5 lines
scripts/Makefile.build $(obj)/%.lst: $(src)/%.c FORCE · line 280
Quoted 2 lines
scripts/Makefile.build +1
-1-rust_allowed_features := core_ffi_c +rust_allowed_features := core_ffi_c,new_uninitWhat is the purpose of adding the feature here? The kernel crate seems to compile fine without this.
Quoted 3 lines
It's for the upcoming DRM abstractions, as I mentioned in the commit message. There's so many dependencies that I'm trying to get as much as I can early to avoid having to review very big patchsets down the line ^^
I got confused on the different makefile rules used to build kernel crate vs module crates. Looks good 👍
Quoted 3 lines · Andreas Hindborg
What is the purpose of adding the feature here? The kernel crate seems to compile fine without this.
rust_allowed_features is the list of features that crates outside rust/ can use (e.g. drivers).
The goal is to control which unstable features are used outside the kernel crate and to avoid mistakenly relying on them.
Cheers,
Miguel
Quoted 9 lines
The unstable
new_uninitfeature enables various library APIs to create uninitialized containers, such asBox::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using
place!()or a future replacement macro which may itself live inkernel) in driver crates.
Quoted 8 lines
See [1] [2] [3] for background information.
[1] https://github.com/Rust-for-Linux/linux/issues/879
[2] https://github.com/Rust-for-Linux/linux/issues/2
[3] https://github.com/rust-lang/rust/issues/63291Signed-off-by Asahi Lina <[email protected]>---
Miguel Ojeda
AppliedQuoted 10 lines · Asahi Lina
The unstable
new_uninitfeature enables various library APIs to create uninitialized containers, such asBox::assume_init(). This is necessary to build abstractions that directly initialize memory at the target location, instead of doing copies through the stack.Will be used by the DRM scheduler abstraction in the kernel crate, and by field-wise initialization (e.g. using
place!()or a future replacement macro which may itself live inkernel) in driver crates.
Quoted 5 lines
See [1] [2] [3] for background information.
[1] https://github.com/Rust-for-Linux/linux/issues/879
[2] https://github.com/Rust-for-Linux/linux/issues/2
[3] https://github.com/rust-lang/rust/issues/63291
Applied to rust-next (reworded to use Link tags). Thanks!
Cheers,
Miguel