Re: [PATCH v3 5/7] rust: percpu: Support non-zeroable types for DynamicPerCpu
From: Miguel Ojeda
Date: Thu Sep 04 2025 - 17:57:26 EST
On Thu, Sep 4, 2025 at 11:05 PM Mitchell Levy <levymitchell0@xxxxxxxxx> wrote:
>
> it *might* also be possible to use a macro and dispense with the need for
> a closure, though I'm not familiar enough with proc macros to say for
> sure. That would probably look like
>
> for_each_possible_cpu!(cpu) {
> let remote_ptr = unsafe { ptr.get_remote_ptr(cpu) };
> // ...
> }
>
> though personally I think the first one is better (simpler
> implementation without too much syntactic overhead, especially since
> closures are already used some within R4L).
Yeah, please avoid macros as much as possible. Sometimes macros do
have advantages, but if it is just to avoid a closure, then no, please
avoid it.
Similarly, unless there is a concrete advantage needed with the
function, please avoid it too -- the original `for` with the iterator
is the normal way of doing it and already used plenty in the kernel.
Thanks!
Cheers,
Miguel