All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
@ 2023-02-24  8:09 Asahi Lina
  2023-02-24 14:01 ` Martin Rodriguez Reboredo
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Asahi Lina @ 2023-02-24  8:09 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier
  Cc: rust-for-linux, linux-kernel, linux-kbuild, asahi, Asahi Lina

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

Signed-off-by: Asahi Lina <lina@asahilina.net>
---
 rust/kernel/lib.rs     | 1 +
 scripts/Makefile.build | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index 223564f9f0cc..1118cd3e0b5f 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -17,6 +17,7 @@
 #![feature(core_ffi_c)]
 #![feature(dispatch_from_dyn)]
 #![feature(generic_associated_types)]
+#![feature(new_uninit)]
 #![feature(receiver_trait)]
 #![feature(unsize)]
 
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a0d5c6cca76d..0f637e1ca8dc 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -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


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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-24  8:09 [PATCH] rust: Enable the new_uninit feature for kernel and driver crates Asahi Lina
@ 2023-02-24 14:01 ` Martin Rodriguez Reboredo
  2023-02-25  0:45 ` Gary Guo
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Martin Rodriguez Reboredo @ 2023-02-24 14:01 UTC (permalink / raw)
  To: lina
  Cc: alex.gaynor, asahi, bjorn3_gh, boqun.feng, gary, linux-kbuild,
	linux-kernel, masahiroy, nathan, ndesaulniers, nicolas, ojeda,
	rust-for-linux, wedsonaf

On Fri, Feb 24, 2023 at 05:09:47PM +0900, Asahi Lina wrote:
> 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.

Very useful to me as some constructors in the USB bindings that I'm
writting might make use of unitialized memory.

Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>

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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-24  8:09 [PATCH] rust: Enable the new_uninit feature for kernel and driver crates Asahi Lina
  2023-02-24 14:01 ` Martin Rodriguez Reboredo
@ 2023-02-25  0:45 ` Gary Guo
  2023-02-27 13:09 ` Andreas Hindborg
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Gary Guo @ 2023-02-25  0:45 UTC (permalink / raw)
  To: Asahi Lina
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Björn Roy Baron, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Nicolas Schier, rust-for-linux, linux-kernel,
	linux-kbuild, asahi

On Fri, 24 Feb 2023 17:09:47 +0900
Asahi Lina <lina@asahilina.net> wrote:

> 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
> 
> Signed-off-by: Asahi Lina <lina@asahilina.net>

Reviewed-by: Gary Guo <gary@garyguo.net>

> ---
>  rust/kernel/lib.rs     | 1 +
>  scripts/Makefile.build | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
> index 223564f9f0cc..1118cd3e0b5f 100644
> --- a/rust/kernel/lib.rs
> +++ b/rust/kernel/lib.rs
> @@ -17,6 +17,7 @@
>  #![feature(core_ffi_c)]
>  #![feature(dispatch_from_dyn)]
>  #![feature(generic_associated_types)]
> +#![feature(new_uninit)]
>  #![feature(receiver_trait)]
>  #![feature(unsize)]
>  
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index a0d5c6cca76d..0f637e1ca8dc 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -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
> 


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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-24  8:09 [PATCH] rust: Enable the new_uninit feature for kernel and driver crates Asahi Lina
  2023-02-24 14:01 ` Martin Rodriguez Reboredo
  2023-02-25  0:45 ` Gary Guo
@ 2023-02-27 13:09 ` Andreas Hindborg
  2023-02-27 13:47   ` Asahi Lina
  2023-02-27 13:48   ` Miguel Ojeda
  2023-03-01 17:24 ` Vincenzo Palazzo
  2023-04-10  2:54 ` Miguel Ojeda
  4 siblings, 2 replies; 9+ messages in thread
From: Andreas Hindborg @ 2023-02-27 13:09 UTC (permalink / raw)
  To: Asahi Lina
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	rust-for-linux, linux-kernel, linux-kbuild, asahi


Asahi Lina <lina@asahilina.net> writes:

> 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
>
> Signed-off-by: Asahi Lina <lina@asahilina.net>
> ---
>  rust/kernel/lib.rs     | 1 +
>  scripts/Makefile.build | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
> index 223564f9f0cc..1118cd3e0b5f 100644
> --- a/rust/kernel/lib.rs
> +++ b/rust/kernel/lib.rs
> @@ -17,6 +17,7 @@
>  #![feature(core_ffi_c)]
>  #![feature(dispatch_from_dyn)]
>  #![feature(generic_associated_types)]
> +#![feature(new_uninit)]
>  #![feature(receiver_trait)]
>  #![feature(unsize)]
>  
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index a0d5c6cca76d..0f637e1ca8dc 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -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


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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-27 13:09 ` Andreas Hindborg
@ 2023-02-27 13:47   ` Asahi Lina
  2023-02-27 14:34     ` Andreas Hindborg
  2023-02-27 13:48   ` Miguel Ojeda
  1 sibling, 1 reply; 9+ messages in thread
From: Asahi Lina @ 2023-02-27 13:47 UTC (permalink / raw)
  To: Andreas Hindborg
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	rust-for-linux, linux-kernel, linux-kbuild, asahi

On 27/02/2023 22.09, Andreas Hindborg wrote:
> 
> Asahi Lina <lina@asahilina.net> writes:
> 
>> 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
>>
>> Signed-off-by: Asahi Lina <lina@asahilina.net>
>> ---
>>  rust/kernel/lib.rs     | 1 +
>>  scripts/Makefile.build | 2 +-
>>  2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
>> index 223564f9f0cc..1118cd3e0b5f 100644
>> --- a/rust/kernel/lib.rs
>> +++ b/rust/kernel/lib.rs
>> @@ -17,6 +17,7 @@
>>  #![feature(core_ffi_c)]
>>  #![feature(dispatch_from_dyn)]
>>  #![feature(generic_associated_types)]
>> +#![feature(new_uninit)]
>>  #![feature(receiver_trait)]
>>  #![feature(unsize)]
>>  
>> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
>> index a0d5c6cca76d..0f637e1ca8dc 100644
>> --- a/scripts/Makefile.build
>> +++ b/scripts/Makefile.build
>> @@ -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.

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

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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-27 13:09 ` Andreas Hindborg
  2023-02-27 13:47   ` Asahi Lina
@ 2023-02-27 13:48   ` Miguel Ojeda
  1 sibling, 0 replies; 9+ messages in thread
From: Miguel Ojeda @ 2023-02-27 13:48 UTC (permalink / raw)
  To: Andreas Hindborg
  Cc: Asahi Lina, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Boqun Feng, Gary Guo, Björn Roy Baron, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	rust-for-linux, linux-kernel, linux-kbuild, asahi

On Mon, Feb 27, 2023 at 2:15 PM Andreas Hindborg <nmi@metaspace.dk> wrote:
>
> 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

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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-27 13:47   ` Asahi Lina
@ 2023-02-27 14:34     ` Andreas Hindborg
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Hindborg @ 2023-02-27 14:34 UTC (permalink / raw)
  To: Asahi Lina
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	rust-for-linux, linux-kernel, linux-kbuild, asahi


Asahi Lina <lina@asahilina.net> writes:

> On 27/02/2023 22.09, Andreas Hindborg wrote:
>> 
>> Asahi Lina <lina@asahilina.net> writes:
>> 
>>> 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
>>>
>>> Signed-off-by: Asahi Lina <lina@asahilina.net>
>>> ---
>>>  rust/kernel/lib.rs     | 1 +
>>>  scripts/Makefile.build | 2 +-
>>>  2 files changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
>>> index 223564f9f0cc..1118cd3e0b5f 100644
>>> --- a/rust/kernel/lib.rs
>>> +++ b/rust/kernel/lib.rs
>>> @@ -17,6 +17,7 @@
>>>  #![feature(core_ffi_c)]
>>>  #![feature(dispatch_from_dyn)]
>>>  #![feature(generic_associated_types)]
>>> +#![feature(new_uninit)]
>>>  #![feature(receiver_trait)]
>>>  #![feature(unsize)]
>>>  
>>> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
>>> index a0d5c6cca76d..0f637e1ca8dc 100644
>>> --- a/scripts/Makefile.build
>>> +++ b/scripts/Makefile.build
>>> @@ -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.
>
> 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 👍

Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com>


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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-24  8:09 [PATCH] rust: Enable the new_uninit feature for kernel and driver crates Asahi Lina
                   ` (2 preceding siblings ...)
  2023-02-27 13:09 ` Andreas Hindborg
@ 2023-03-01 17:24 ` Vincenzo Palazzo
  2023-04-10  2:54 ` Miguel Ojeda
  4 siblings, 0 replies; 9+ messages in thread
From: Vincenzo Palazzo @ 2023-03-01 17:24 UTC (permalink / raw)
  To: Asahi Lina, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
	Boqun Feng, Gary Guo, Björn Roy Baron, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier
  Cc: rust-for-linux, linux-kernel, linux-kbuild, asahi

> 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
>
> Signed-off-by: Asahi Lina <lina@asahilina.net>
> ---

Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

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

* Re: [PATCH] rust: Enable the new_uninit feature for kernel and driver crates
  2023-02-24  8:09 [PATCH] rust: Enable the new_uninit feature for kernel and driver crates Asahi Lina
                   ` (3 preceding siblings ...)
  2023-03-01 17:24 ` Vincenzo Palazzo
@ 2023-04-10  2:54 ` Miguel Ojeda
  4 siblings, 0 replies; 9+ messages in thread
From: Miguel Ojeda @ 2023-04-10  2:54 UTC (permalink / raw)
  To: Asahi Lina
  Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Masahiro Yamada,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	rust-for-linux, linux-kernel, linux-kbuild, asahi

On Fri, Feb 24, 2023 at 9:10 AM Asahi Lina <lina@asahilina.net> wrote:
>
> 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

Applied to `rust-next` (reworded to use `Link` tags). Thanks!

Cheers,
Miguel

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

end of thread, other threads:[~2023-04-10  2:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24  8:09 [PATCH] rust: Enable the new_uninit feature for kernel and driver crates Asahi Lina
2023-02-24 14:01 ` Martin Rodriguez Reboredo
2023-02-25  0:45 ` Gary Guo
2023-02-27 13:09 ` Andreas Hindborg
2023-02-27 13:47   ` Asahi Lina
2023-02-27 14:34     ` Andreas Hindborg
2023-02-27 13:48   ` Miguel Ojeda
2023-03-01 17:24 ` Vincenzo Palazzo
2023-04-10  2:54 ` Miguel Ojeda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.