[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025070320-annuity-earplugs-6eee@gregkh>
Date: Thu, 3 Jul 2025 14:45:04 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Benno Lossin <lossin@...nel.org>
Cc: Alice Ryhl <aliceryhl@...gle.com>, Danilo Krummrich <dakr@...nel.org>,
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 02:34:13PM +0200, Benno Lossin wrote:
> On Thu Jul 3, 2025 at 1:41 PM CEST, Greg Kroah-Hartman wrote:
> > On Thu, Jul 03, 2025 at 12:54:18PM +0200, Alice Ryhl wrote:
> >> On Thu, Jul 3, 2025 at 12:33 PM Benno Lossin <lossin@...nel.org> wrote:
> >> > How would your example look like with the current approach? IIUC, it
> >> > also wouldn't work, because the debugfs data can't be mutated?
> >>
> >> I would store a bunch of `File<Arc<Process>>` instances somewhere.
> >> Each one has a closure that takes the spinlock and prints the
> >> appropriate value.
>
> But you could also do that with the pin-init design?
>
> > Ok, I think we need to see some "real" examples here of the api in use
> > before figuring it out further as I'm totally confused :)
>
> Agreed :)
>
> > Yes, we need to be able to have a debugfs file callback handle a mutable
> > structure in order to lock things correctly.
>
> To me this seems orthogonal to storing the value in-place or in a
> `ForeignOwnable`.
>
> > We also need to have it be mutable so that it can MODIFY the value
> > (everyone seems to forget that debugfs allows that...)
>
> Well that changes things a lot IMO... How does the C side usually handle
> synchronization here? Does the driver decide that the structure exposed
> to debugfs is locked with eg a spinlock and then in the debugfs callback
> they just lock the same one?
It does whatever it feels like, so both are valid uses.
Sometimes a lock is involved, sometimes not. Remember this is debugfs,
the only rule for it is "there are no rules except it requires root
permissions to access".
thanks,
greg k-h
Powered by blists - more mailing lists