Re: [PATCH v3 08/13] rust: init: Add functions to create array initializers

From: Boqun Feng
Date: Sun Jul 30 2023 - 23:01:25 EST


On Sat, Jul 29, 2023 at 09:10:02AM +0000, Benno Lossin wrote:
[...]
> +/// Initializes an array by initializing each element via the provided initializer.
> +///
> +/// # Examples
> +///
> +/// ```rust
> +/// use kernel::{sync::{Arc, Mutex}, init::pin_init_array_from_fn, new_mutex};
> +/// let array: Arc<[Mutex<usize>; 1_000_000_000]>=

This is nice, but (if I got my math correct) it requires ~30G memory on
a 64bit machine, and when this example got generated as a kunit test,
my poor VM took forever to finish it ;-) ;-) ;-) Maybe descrease it to,
say, 1000?

Regards,
Boqun

> +/// Arc::pin_init(pin_init_array_from_fn(|i| new_mutex!(i))).unwrap();
> +/// assert_eq!(array.len(), 1_000_000_000);
> +/// ```
[...]