[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aGaN6PT-w9b2pQOr@pollux>
Date: Thu, 3 Jul 2025 16:04:24 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Benno Lossin <lossin@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Matthew Maurer <mmaurer@...gle.com>,
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>,
Trevor Gross <tmgross@...ch.edu>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
Timur Tabi <ttabi@...dia.com>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org,
Dirk Behme <dirk.behme@...bosch.com>
Subject: Re: [PATCH v8 4/6] rust: debugfs: Support arbitrary owned backing
for File
On Thu, Jul 03, 2025 at 03:34:23PM +0200, Benno Lossin wrote:
> On Thu Jul 3, 2025 at 2:29 PM CEST, Danilo Krummrich wrote:
> > So, what I'm trying to say is, I think it's a good thing if fields that are
> > protected by the same lock can't be exposed through separate files, because it
> > means that the fields only make sense in the context of each other.
>
> I think that even the pin-init API can have multiple files for different
> elements of the locked structure, you just need to nest `File`:
>
> #[pin_data]
> struct Process {
> task: ARef<Task>,
> #[pin]
> inner: File<File<SpinLock<ProcessInner>>>,
> }
>
> pub(crate) struct ProcessInner {
> threads: RBTree<i32, Arc<Thread>>,
> max_threads: u32,
> }
>
> Now you can do:
>
> pin_init!(Process {
> inner <- dir.create_file(
> "threads",
> dir.create_file("max_threads", new_spinlock!(...)),
> ),
> // ...
> })
>
> But I'd say this will at least raise eyebrows for the reviewers, which
> is good, since it catches the footgun.
Heh! I didn't even think of this trick. I agree, this should at least raise some
eyebrows. :)
Powered by blists - more mailing lists