[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025051540-snowsuit-manhole-7858@gregkh>
Date: Thu, 15 May 2025 09:43:30 +0200
From: "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
To: Matthew Maurer <mmaurer@...gle.com>
Cc: Timur Tabi <ttabi@...dia.com>, "dakr@...nel.org" <dakr@...nel.org>,
"tmgross@...ch.edu" <tmgross@...ch.edu>,
"benno.lossin@...ton.me" <benno.lossin@...ton.me>,
"gary@...yguo.net" <gary@...yguo.net>,
"a.hindborg@...nel.org" <a.hindborg@...nel.org>,
"lossin@...nel.org" <lossin@...nel.org>,
"bjorn3_gh@...tonmail.com" <bjorn3_gh@...tonmail.com>,
"boqun.feng@...il.com" <boqun.feng@...il.com>,
"rafael@...nel.org" <rafael@...nel.org>,
"alex.gaynor@...il.com" <alex.gaynor@...il.com>,
"aliceryhl@...gle.com" <aliceryhl@...gle.com>,
"ojeda@...nel.org" <ojeda@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"samitolvanen@...gle.com" <samitolvanen@...gle.com>,
"rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v5 4/4] rust: samples: Add debugfs sample
On Wed, May 14, 2025 at 03:42:46PM -0700, Matthew Maurer wrote:
> On Wed, May 14, 2025 at 3:40 PM Timur Tabi <ttabi@...dia.com> wrote:
> >
> > On Wed, 2025-05-14 at 15:32 -0700, Matthew Maurer wrote:
> > > One further possibility here, which we'd need Greg to weigh in on - we
> > > could add a method to the debugfs API intended for Rust usage which
> > > specifically releases a directory or file *without* releasing any
> > > nested elements. This would mean we could get rid of all the lifetimes
> > > on directory and file handles.
> >
> > I had a conversation with Greg about this topic just the other week.
> >
> > https://lore.kernel.org/linux-doc/20250429173958.3973958-1-ttabi@nvidia.com/
> >
> > There are two versions of debugfs_remove:
> >
> > void debugfs_remove(struct dentry *dentry);
> > #define debugfs_remove_recursive debugfs_remove
> >
> > Unfortunately, the direction that we've been going is to get rid of debugfs_remove_recursive() and
> > have drivers only call debugfs_remove().
> >
> > What would solve your problem is doing the opposite: making debugfs_remove() be non-recursive and
> > require drivers to call debugfs_remove_recursive() if that's what they really want.
> >
> > Maybe we need debugfs_remove_single()?
> >
>
> Yes, having access to `debugfs_remove_single()`, if it has the
> properties I would expect (namely that the kernel objects for
> inaccessible directories continue to exist, they're just not reachable
> through the VFS) would allow this design. It's not obvious to me if
> it's the design we want, but it would enable that design.
Ick, no, we got rid of debugfs_remove() only removing a single dentry a
while ago as it was causing problems. Let's not go back to that at all.
This shouldn't be all that complex, it's supposed to be simple to use
and reason about. If you create a directory, you can "own" it until you
drop the reference and then it, and all files/subdirs will then be
removed. I like that logic much better than what we are stuck with in C
where we can create a directory but then be forced to remember to look
it up later to remove it when finished.
Ideally we can migrate the C code to be more like the rust api in the
future as that should be easier to deal with over time by driver
authors.
thanks,
greg k-h
Powered by blists - more mailing lists