[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DB2GKFUREH3U.15ME8JB2HJOQN@kernel.org>
Date: Thu, 03 Jul 2025 15:35:52 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Danilo Krummrich" <dakr@...nel.org>, "Greg Kroah-Hartman"
<gregkh@...uxfoundation.org>
Cc: "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 3, 2025 at 2:29 PM CEST, Danilo Krummrich wrote:
> On Thu, Jul 03, 2025 at 01:41:53PM +0200, Greg Kroah-Hartman wrote:
>> Yes, we need to be able to have a debugfs file callback handle a mutable
>> structure in order to lock things correctly. 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's possible with both approaches. Data behind a lock becomes mutable
> once you grabbed the lock. That's the same in both cases.
>
> The difference is that with the pin-init approach I propose you can't have what
> Alice sketched up. And I think it's even desirable that you can't do it.
>
> Let's me explain the difference on a simplified example, based on Alice'
> example.
>
> ForeignOwnable API
> ------------------
>
> #[pin_data]
> struct Process {
> task: ARef<Task>,
> #[pin]
> inner: SpinLock<ProcessInner>,
> }
>
> pub(crate) struct ProcessInner {
> threads: RBTree<i32, Arc<Thread>>,
> max_threads: u32,
> }
>
> Here we have to create an Arc<Process> (let's call it process) and create files
> from it.
>
> let file_threads = dir.create_file("threads", process);
> let file_max_threads = dir.create_file("max_threads", process);
>
> In the file system callback of both of these, we now have an Arc<Process>, hence
> we can access:
>
> let guard = process.inner.lock();
>
> read_or_write(guard.max_threads);
>
> and in the other file:
>
> let guard = process.inner.lock();
>
> read_or_write(guard.max_threads);
Where do you actually specify this callback? At the moment, the API asks
for `Display` and thus it can only read values?
---
Cheers,
Benno
Powered by blists - more mailing lists