rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] rust: two small improvements for kunit
@ 2025-02-08 13:31 Thomas Weißschuh
  2025-02-08 13:31 ` [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux Thomas Weißschuh
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-02-08 13:31 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: rust-for-linux, linux-kernel, llvm, Thomas Weißschuh

Two quality of live improvements for running kunit tests for rust/.
While today there are only the doctests, more are coming [0].

	$ ./tools/testing/kunit/kunit.py run --kunitconfig rust/ 
	[14:25:48] Configuring KUnit Kernel ...
	[14:25:48] Building KUnit Kernel ...
	Populating config with:
	$ make ARCH=um O=.kunit olddefconfig
	Building with:
	$ make all compile_commands.json ARCH=um O=.kunit --jobs=16
	[14:25:53] Starting KUnit Kernel (1/1)...
	[14:25:53] ============================================================
	Running tests with:
	$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
	[14:25:53] =========== rust_doctests_kernel (135 subtests) ============
	[14:25:53] [PASSED] rust_doctest_kernel_alloc_kbox_rs_0

	...

	[14:25:53] [PASSED] rust_doctest_kernel_workqueue_rs_3
	[14:25:53] ============== [PASSED] rust_doctests_kernel ===============
	[14:25:53] ============================================================
	[14:25:53] Testing complete. Ran 135 tests: passed: 135
	[14:25:53] Elapsed time: 5.431s total, 0.001s configuring, 5.314s building, 0.086s running

[0] https://lore.kernel.org/rust-for-linux/20241213081035.2069066-1-davidgow@google.com/

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (2):
      rust: pass correct target to bindgen on Usermode Linux
      rust: add kunitconfig

 rust/.kunitconfig | 3 +++
 rust/Makefile     | 1 +
 2 files changed, 4 insertions(+)
---
base-commit: beeb78d46249cab8b2b8359a2ce8fa5376b5ad2d
change-id: 20250208-rust-kunit-dd350e1a463c

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


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

* [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
  2025-02-08 13:31 [PATCH 0/2] rust: two small improvements for kunit Thomas Weißschuh
@ 2025-02-08 13:31 ` Thomas Weißschuh
  2025-02-10 10:55   ` David Gow
  2025-03-18  8:07   ` David Gow
  2025-02-08 13:31 ` [PATCH 2/2] rust: add kunitconfig Thomas Weißschuh
  2025-03-20 11:21 ` [PATCH 0/2] rust: two small improvements for kunit Miguel Ojeda
  2 siblings, 2 replies; 10+ messages in thread
From: Thomas Weißschuh @ 2025-02-08 13:31 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: rust-for-linux, linux-kernel, llvm, Thomas Weißschuh

Usermode Linux uses "um" as primary architecture name and the underlying
physical architecture is provided in "SUBARCH".
Resolve the target architecture flags through that underlying architecture.
This is the same pattern as used by scripts/Makefile.clang from which
the bindgen flags are derived.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 rust/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rust/Makefile b/rust/Makefile
index 8fcfd60447bc89ba2c66a4f341288db2387b0956..a94fafb91d7d743c6c1b2248479c0d723964e5c4 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -245,6 +245,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
 # Derived from `scripts/Makefile.clang`.
 BINDGEN_TARGET_x86	:= x86_64-linux-gnu
 BINDGEN_TARGET_arm64	:= aarch64-linux-gnu
+BINDGEN_TARGET_um	:= $(BINDGEN_TARGET_$(SUBARCH))
 BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
 
 # All warnings are inhibited since GCC builds are very experimental,

-- 
2.48.1


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

* [PATCH 2/2] rust: add kunitconfig
  2025-02-08 13:31 [PATCH 0/2] rust: two small improvements for kunit Thomas Weißschuh
  2025-02-08 13:31 ` [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux Thomas Weißschuh
@ 2025-02-08 13:31 ` Thomas Weißschuh
  2025-02-10 10:55   ` David Gow
  2025-03-20 11:21 ` [PATCH 0/2] rust: two small improvements for kunit Miguel Ojeda
  2 siblings, 1 reply; 10+ messages in thread
From: Thomas Weißschuh @ 2025-02-08 13:31 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: rust-for-linux, linux-kernel, llvm, Thomas Weißschuh

The kunitconfig file in a directory is used by kunit.py to enable all
necessary kernel configurations to run the tests in that subdirectory.
Add such a file for rust/.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 rust/.kunitconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rust/.kunitconfig b/rust/.kunitconfig
new file mode 100644
index 0000000000000000000000000000000000000000..9e72a5ab03c9a122348fea7c1db69e1b3fedcc00
--- /dev/null
+++ b/rust/.kunitconfig
@@ -0,0 +1,3 @@
+CONFIG_KUNIT=y
+CONFIG_RUST=y
+CONFIG_RUST_KERNEL_DOCTESTS=y

-- 
2.48.1


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

* Re: [PATCH 2/2] rust: add kunitconfig
  2025-02-08 13:31 ` [PATCH 2/2] rust: add kunitconfig Thomas Weißschuh
@ 2025-02-10 10:55   ` David Gow
  0 siblings, 0 replies; 10+ messages in thread
From: David Gow @ 2025-02-10 10:55 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	linux-kernel, llvm

On Sat, 8 Feb 2025 at 21:32, Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> The kunitconfig file in a directory is used by kunit.py to enable all
> necessary kernel configurations to run the tests in that subdirectory.
> Add such a file for rust/.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---

I could swear we already had one of these lying around: maybe it was
in an old Pull Request somewhere...

Anyway, this is great, thanks!

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David


>  rust/.kunitconfig | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/rust/.kunitconfig b/rust/.kunitconfig
> new file mode 100644
> index 0000000000000000000000000000000000000000..9e72a5ab03c9a122348fea7c1db69e1b3fedcc00
> --- /dev/null
> +++ b/rust/.kunitconfig
> @@ -0,0 +1,3 @@
> +CONFIG_KUNIT=y
> +CONFIG_RUST=y
> +CONFIG_RUST_KERNEL_DOCTESTS=y
>
> --
> 2.48.1
>
>

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

* Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
  2025-02-08 13:31 ` [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux Thomas Weißschuh
@ 2025-02-10 10:55   ` David Gow
  2025-03-18  8:07   ` David Gow
  1 sibling, 0 replies; 10+ messages in thread
From: David Gow @ 2025-02-10 10:55 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	linux-kernel, llvm, linux-um

On Sat, 8 Feb 2025 at 21:32, Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> Usermode Linux uses "um" as primary architecture name and the underlying
> physical architecture is provided in "SUBARCH".
> Resolve the target architecture flags through that underlying architecture.
> This is the same pattern as used by scripts/Makefile.clang from which
> the bindgen flags are derived.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---

(+cc linux-um, but I assume this will probably go in via the Rust tree, anyway.)

Thanks very much: this is enough to get Rust-for-Linux working with
gcc under 64-bit UML on my system.

However, this is actually a bit of a coincidence -- and there are
still some issues with 32-bit UML -- as the UML Rust flags are
currently conditionally set if CC_IS_CLANG. This is my fault (it was
to work around some bugs with older gcc), and I've sent a patch[1] to
fix it. (Though note that 32-bit UML/Rust still hits issues with
atomics in the block driver, so you'll need to disable that for now.)

Regardless, this is a significant improvement, thanks!

Reviewed-by: David Gow <davidgow@googl.ecom>

Thanks,
-- David

[1]: https://lore.kernel.org/rust-for-linux/20250210105353.2238769-2-davidgow@google.com/


>  rust/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 8fcfd60447bc89ba2c66a4f341288db2387b0956..a94fafb91d7d743c6c1b2248479c0d723964e5c4 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -245,6 +245,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
>  # Derived from `scripts/Makefile.clang`.
>  BINDGEN_TARGET_x86     := x86_64-linux-gnu
>  BINDGEN_TARGET_arm64   := aarch64-linux-gnu
> +BINDGEN_TARGET_um      := $(BINDGEN_TARGET_$(SUBARCH))
>  BINDGEN_TARGET         := $(BINDGEN_TARGET_$(SRCARCH))
>
>  # All warnings are inhibited since GCC builds are very experimental,
>
> --
> 2.48.1
>
>

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

* Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
  2025-02-08 13:31 ` [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux Thomas Weißschuh
  2025-02-10 10:55   ` David Gow
@ 2025-03-18  8:07   ` David Gow
  2025-03-18 10:10     ` Miguel Ojeda
  1 sibling, 1 reply; 10+ messages in thread
From: David Gow @ 2025-03-18  8:07 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	linux-kernel, llvm, linux-um

[-- Attachment #1: Type: text/plain, Size: 788 bytes --]

On Sat, 8 Feb 2025 at 21:32, Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> Usermode Linux uses "um" as primary architecture name and the underlying
> physical architecture is provided in "SUBARCH".
> Resolve the target architecture flags through that underlying architecture.
> This is the same pattern as used by scripts/Makefile.clang from which
> the bindgen flags are derived.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---

Is there anything holding this up for the upcoming merge window?

Miguel: I'm assuming you'd rather take this (and possibly [1] as well)
via Rust, but if it goes in via the uml tree, that'd be fine by me,
too.

Cheers,
-- David

[1]: https://lore.kernel.org/linux-um/20250210105353.2238769-2-davidgow@google.com/

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]

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

* Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
  2025-03-18  8:07   ` David Gow
@ 2025-03-18 10:10     ` Miguel Ojeda
  2025-03-18 10:14       ` Johannes Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Miguel Ojeda @ 2025-03-18 10:10 UTC (permalink / raw)
  To: David Gow, Richard Weinberger, Anton Ivanov, Johannes Berg,
	linux-um
  Cc: Thomas Weißschuh, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	linux-kernel, llvm

On Tue, Mar 18, 2025 at 9:07 AM David Gow <davidgow@google.com> wrote:
>
> Is there anything holding this up for the upcoming merge window?
>
> Miguel: I'm assuming you'd rather take this (and possibly [1] as well)
> via Rust, but if it goes in via the uml tree, that'd be fine by me,
> too.

We try to get arch maintainers involved (and everyone else, of
course), i.e. it is up to them. But I see only the list was Cc'd, not
them directly, for some reason -- doing it here.

Ideally, maintainers get involved and pick their own Rust-related
patches, but I can also do so with an Acked-by from them, which would
be nice.

If they don't say anything, then since you have tested it (and you are
a main um user due to KUnit), that should be enough, but then I would
suggest we do it after -rc1 to give them time to react.

Thanks!

Cheers,
Miguel

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

* Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
  2025-03-18 10:10     ` Miguel Ojeda
@ 2025-03-18 10:14       ` Johannes Berg
  2025-03-18 10:34         ` Miguel Ojeda
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2025-03-18 10:14 UTC (permalink / raw)
  To: Miguel Ojeda, David Gow, Richard Weinberger, Anton Ivanov,
	linux-um
  Cc: Thomas Weißschuh, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	linux-kernel, llvm

On Tue, 2025-03-18 at 11:10 +0100, Miguel Ojeda wrote:
> On Tue, Mar 18, 2025 at 9:07 AM David Gow <davidgow@google.com> wrote:
> > 
> > Is there anything holding this up for the upcoming merge window?
> > 
> > Miguel: I'm assuming you'd rather take this (and possibly [1] as well)
> > via Rust, but if it goes in via the uml tree, that'd be fine by me,
> > too.
> 
> We try to get arch maintainers involved (and everyone else, of
> course), i.e. it is up to them. But I see only the list was Cc'd, not
> them directly, for some reason -- doing it here.

The list is fine, but the patch wasn't even CC'ed there, so we don't
have it in our patchwork:
https://patchwork.ozlabs.org/project/linux-um/list/

> Ideally, maintainers get involved and pick their own Rust-related
> patches, but I can also do so with an Acked-by from them, which would
> be nice.

I was just picking up um patches, but given that it was a series, and
changes rust/ rather than arch/um/, I think it's probably better if you
do it, so:

Acked-by: Johannes Berg <johannes@sipsolutions.net>

johannes

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

* Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
  2025-03-18 10:14       ` Johannes Berg
@ 2025-03-18 10:34         ` Miguel Ojeda
  0 siblings, 0 replies; 10+ messages in thread
From: Miguel Ojeda @ 2025-03-18 10:34 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David Gow, Richard Weinberger, Anton Ivanov, linux-um,
	Thomas Weißschuh, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	linux-kernel, llvm

On Tue, Mar 18, 2025 at 11:14 AM Johannes Berg
<johannes@sipsolutions.net> wrote:
>
> The list is fine, but the patch wasn't even CC'ed there, so we don't
> have it in our patchwork:
> https://patchwork.ozlabs.org/project/linux-um/list/

Ah, right, David added it.

> I was just picking up um patches, but given that it was a series, and
> changes rust/ rather than arch/um/, I think it's probably better if you
> do it, so:
>
> Acked-by: Johannes Berg <johannes@sipsolutions.net>

Thanks for the very quick reply!

I guess they could be picked independently, but I am happy to pick both.

Cheers,
Miguel

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

* Re: [PATCH 0/2] rust: two small improvements for kunit
  2025-02-08 13:31 [PATCH 0/2] rust: two small improvements for kunit Thomas Weißschuh
  2025-02-08 13:31 ` [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux Thomas Weißschuh
  2025-02-08 13:31 ` [PATCH 2/2] rust: add kunitconfig Thomas Weißschuh
@ 2025-03-20 11:21 ` Miguel Ojeda
  2 siblings, 0 replies; 10+ messages in thread
From: Miguel Ojeda @ 2025-03-20 11:21 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	linux-kernel, llvm

On Sat, Feb 8, 2025 at 2:32 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> Two quality of live improvements for running kunit tests for rust/.
> While today there are only the doctests, more are coming [0].
>
>         $ ./tools/testing/kunit/kunit.py run --kunitconfig rust/
>         [14:25:48] Configuring KUnit Kernel ...
>         [14:25:48] Building KUnit Kernel ...
>         Populating config with:
>         $ make ARCH=um O=.kunit olddefconfig
>         Building with:
>         $ make all compile_commands.json ARCH=um O=.kunit --jobs=16
>         [14:25:53] Starting KUnit Kernel (1/1)...
>         [14:25:53] ============================================================
>         Running tests with:
>         $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
>         [14:25:53] =========== rust_doctests_kernel (135 subtests) ============
>         [14:25:53] [PASSED] rust_doctest_kernel_alloc_kbox_rs_0
>
>         ...
>
>         [14:25:53] [PASSED] rust_doctest_kernel_workqueue_rs_3
>         [14:25:53] ============== [PASSED] rust_doctests_kernel ===============
>         [14:25:53] ============================================================
>         [14:25:53] Testing complete. Ran 135 tests: passed: 135
>         [14:25:53] Elapsed time: 5.431s total, 0.001s configuring, 5.314s building, 0.086s running
>
> [0] https://lore.kernel.org/rust-for-linux/20241213081035.2069066-1-davidgow@google.com/
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Applied to `rust-next` -- thanks everyone!

    [ David says:

          (...) this is enough to get Rust-for-Linux working with gcc under
          64-bit UML on my system.

        - Miguel ]

Cheers,
Miguel

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

end of thread, other threads:[~2025-03-20 11:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-08 13:31 [PATCH 0/2] rust: two small improvements for kunit Thomas Weißschuh
2025-02-08 13:31 ` [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux Thomas Weißschuh
2025-02-10 10:55   ` David Gow
2025-03-18  8:07   ` David Gow
2025-03-18 10:10     ` Miguel Ojeda
2025-03-18 10:14       ` Johannes Berg
2025-03-18 10:34         ` Miguel Ojeda
2025-02-08 13:31 ` [PATCH 2/2] rust: add kunitconfig Thomas Weißschuh
2025-02-10 10:55   ` David Gow
2025-03-20 11:21 ` [PATCH 0/2] rust: two small improvements for kunit Miguel Ojeda

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