linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/2] rust: alloc: kvec doc example and allocator unit tests
@ 2025-07-30  3:35 Hui Zhu
  2025-07-30  3:35 ` [PATCH v6 1/2] rust: allocator: add KUnit tests for alignment guarantees Hui Zhu
  2025-07-30  3:35 ` [PATCH v6 2/2] rust: alloc: kvec: add doc example for as_slice method Hui Zhu
  0 siblings, 2 replies; 11+ messages in thread
From: Hui Zhu @ 2025-07-30  3:35 UTC (permalink / raw)
  To: Danilo Krummrich, Lorenzo Stoakes, Vlastimil Babka,
	Liam R . Howlett, Uladzislau Rezki, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, bjorn3_gh, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, rust-for-linux, linux-kernel, akpm,
	vitaly.wool
  Cc: Hui Zhu

From: Hui Zhu <zhuhui@kylinos.cn>

This patchset adds KUnit tests for allocator alignment
guarantees and improves kvec documentation.

Patch 1 adds KUnit tests for verifying alignment guarantees
in Rust kernel allocators. Tests cover Kmalloc, Vmalloc
and KVmalloc with both standard (128B) and large page-aligned
(8192B) allocations.

Patch 2 adds a practical usage example for KVec::as_slice
method, showing how to create KVec, push elements and convert
to a slice.

Both patches are co-developed with Geliang Tang. Based on [1].
Tested on x86_64 using KUnit.

Changelog:
v6:
According to the comments of Danilo, updated test for allocator.rs
and allocator rebase onto [1].
v5:
According to the comments of Danilo, change to use generic struct and
allocator Generics in allocator.rs.
v4:
According to the comments of, add the error check for push.
v3:
According to the comments of Danilo and Boqun, move KVec test to doc
example and move VBox to allocator unit tests.
v2:
According to the comments of Danilo, updated the commit to samples the
usage of VBox and KVec.

[1] https://lore.kernel.org/lkml/20250715135645.2230065-1-vitaly.wool@konsulko.se/

Hui Zhu (2):
  rust: allocator: add KUnit tests for alignment guarantees
  rust: alloc: kvec: add doc example for as_slice method

 rust/kernel/alloc/allocator.rs | 56 ++++++++++++++++++++++++++++++++++
 rust/kernel/alloc/kvec.rs      | 10 ++++++
 2 files changed, 66 insertions(+)

-- 
2.43.0


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

end of thread, other threads:[~2025-07-31  2:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30  3:35 [PATCH v6 0/2] rust: alloc: kvec doc example and allocator unit tests Hui Zhu
2025-07-30  3:35 ` [PATCH v6 1/2] rust: allocator: add KUnit tests for alignment guarantees Hui Zhu
2025-07-30  8:02   ` Alice Ryhl
2025-07-30  8:26   ` Kunwu Chan
2025-07-30  9:16   ` Miguel Ojeda
2025-07-31  2:54     ` Hui Zhu
2025-07-30  3:35 ` [PATCH v6 2/2] rust: alloc: kvec: add doc example for as_slice method Hui Zhu
2025-07-30  8:03   ` Alice Ryhl
2025-07-31  2:53     ` Hui Zhu
2025-07-30  8:27   ` Kunwu Chan
2025-07-30  8:31   ` 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).