[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aLoIm94aP6Er0Gn8@yury>
Date: Thu, 4 Sep 2025 17:46:03 -0400
From: Yury Norov <yury.norov@...il.com>
To: Mitchell Levy <levymitchell0@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Andrew Morton <akpm@...ux-foundation.org>,
Dennis Zhou <dennis@...nel.org>, Tejun Heo <tj@...nel.org>,
Christoph Lameter <cl@...ux.com>,
Danilo Krummrich <dakr@...nel.org>,
Benno Lossin <lossin@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Tyler Hicks <code@...icks.com>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v3 5/7] rust: percpu: Support non-zeroable types for
DynamicPerCpu
> >
> > for_each_possible_cpu(cpu) {
> > let remote_ptr = unsafe { ptr.get_remote_ptr(cpu) };
> > unsafe { (*remote_ptr).write(val.clone()); }
> > let arc = Arc::new(alloc, flags).ok()?;
> > Some(Self { alloc: arc })
> > }
> >
> > Is it possible to do the above in rust?
>
> Ah, I see.
>
> The syntax would be slightly different, probably something like
>
> use cpu::for_each_possible_cpu;
>
> for_each_possible_cpu(|&cpu| {
> let remote_ptr = unsafe { ptr.get_remote_ptr(cpu) };
> // ...
> })
>
> 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).
Sure, #1 is OK if you prefer it.
Powered by blists - more mailing lists