From: "Danilo Krummrich" <dakr@kernel.org>
To: "Timur Tabi" <ttabi@nvidia.com>
Cc: Gary Guo <gary@garyguo.net>,
rust-for-linux@vger.kernel.org,
Joel Fernandes <joelagnelf@nvidia.com>,
Alexandre Courbot <acourbot@nvidia.com>,
nouveau@lists.freedesktop.org, Alice Ryhl <aliceryhl@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Matthew Maurer <mmaurer@google.com>
Subject: Re: [PATCH v3 2/9] rust: debugfs: add lookup contructor
Date: Thu, 18 Dec 2025 10:40:05 +0100 [thread overview]
Message-ID: <DF18RFX3IHVP.3GYNJIYAFFJU6@kernel.org> (raw)
In-Reply-To: <20251218013910.459045-3-ttabi@nvidia.com>
On Thu Dec 18, 2025 at 2:39 AM CET, Timur Tabi wrote:
> Add a new constructor for Dir that uses the debugfs_lookup() API to
> obtain a reference to an existing debugfs directory entry.
>
> The key difference from Dir::new() and Dir::subdir() is the cleanup
> semantics: when a Dir obtained via lookup() is dropped, it calls
> dput() to release the reference rather than debugfs_remove() which
> would delete the directory.
>
> To implement this cleanup distinction, the Entry class now includes
> an is_lookup boolean that specifies how the entry was created and
> therefore how it should be dropped.
I have two main comments about this.
(1) I think it would be better to wrap "lookup entries" into a new type in order
to account for the fact that they do not behave like regular entries. I.e. when
a "lookup entry" is dropped, it does not cause the entry to disappear from the
file system. Analogously, when the regular entry is dropped it disappears from
the file system regardless of whether a "lookup entry" still has a reference
count.
(2) The commit message lacks the motiviation for adding this functionality,
which is only for the purpose of a workaround of an unrelated limitation with
accessing the fields of a module structure (which Gary already works on a
solution for).
I understand it might take a while until the solution Gary works on is ready and
I'm perfectly fine with a temporary workaround. But, this workaround has to be
on nova-core only and not introduce a feature in core code that in the near
future becomes dead code.
If we have a use-case for lookup() elsewhere, I'd like to see it first. But if
we don't I prefer not to add this feature as a pure workaround for something
else.
In fact, I think that debugfs_lookup() rarely is the correct solution and more
often indicates some kind of (design) issue, like in this case.
- Danilo
WARNING: multiple messages have this Message-ID (diff)
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Timur Tabi" <ttabi@nvidia.com>
Cc: "Gary Guo" <gary@garyguo.net>, <rust-for-linux@vger.kernel.org>,
"John Hubbard" <jhubbard@nvidia.com>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Lyude Paul" <lyude@redhat.com>, <nouveau@lists.freedesktop.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Matthew Maurer" <mmaurer@google.com>
Subject: Re: [PATCH v3 2/9] rust: debugfs: add lookup contructor
Date: Thu, 18 Dec 2025 10:40:05 +0100 [thread overview]
Message-ID: <DF18RFX3IHVP.3GYNJIYAFFJU6@kernel.org> (raw)
In-Reply-To: <20251218013910.459045-3-ttabi@nvidia.com>
On Thu Dec 18, 2025 at 2:39 AM CET, Timur Tabi wrote:
> Add a new constructor for Dir that uses the debugfs_lookup() API to
> obtain a reference to an existing debugfs directory entry.
>
> The key difference from Dir::new() and Dir::subdir() is the cleanup
> semantics: when a Dir obtained via lookup() is dropped, it calls
> dput() to release the reference rather than debugfs_remove() which
> would delete the directory.
>
> To implement this cleanup distinction, the Entry class now includes
> an is_lookup boolean that specifies how the entry was created and
> therefore how it should be dropped.
I have two main comments about this.
(1) I think it would be better to wrap "lookup entries" into a new type in order
to account for the fact that they do not behave like regular entries. I.e. when
a "lookup entry" is dropped, it does not cause the entry to disappear from the
file system. Analogously, when the regular entry is dropped it disappears from
the file system regardless of whether a "lookup entry" still has a reference
count.
(2) The commit message lacks the motiviation for adding this functionality,
which is only for the purpose of a workaround of an unrelated limitation with
accessing the fields of a module structure (which Gary already works on a
solution for).
I understand it might take a while until the solution Gary works on is ready and
I'm perfectly fine with a temporary workaround. But, this workaround has to be
on nova-core only and not introduce a feature in core code that in the near
future becomes dead code.
If we have a use-case for lookup() elsewhere, I'd like to see it first. But if
we don't I prefer not to add this feature as a pure workaround for something
else.
In fact, I think that debugfs_lookup() rarely is the correct solution and more
often indicates some kind of (design) issue, like in this case.
- Danilo
next prev parent reply other threads:[~2025-12-18 14:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 1:39 [PATCH v3 0/9] gpu: nova-core: expose the logging buffers via debugfs Timur Tabi
2025-12-18 1:39 ` [PATCH v3 1/9] rust: pci: add PCI device name method Timur Tabi
2025-12-18 8:05 ` Alice Ryhl
2025-12-18 8:05 ` Alice Ryhl
2025-12-18 8:55 ` Danilo Krummrich
2025-12-18 8:55 ` Danilo Krummrich
2025-12-18 10:09 ` Miguel Ojeda
2025-12-18 10:09 ` Miguel Ojeda
2025-12-18 1:39 ` [PATCH v3 2/9] rust: debugfs: add lookup contructor Timur Tabi
2025-12-18 9:40 ` Danilo Krummrich [this message]
2025-12-18 9:40 ` Danilo Krummrich
2025-12-18 18:00 ` Matthew Maurer
2025-12-18 18:00 ` Matthew Maurer
2025-12-18 1:39 ` [PATCH v3 3/9] rust: debugfs: add Dir::empty() for no-op directory handle Timur Tabi
2025-12-18 1:39 ` [PATCH v3 4/9] rust: debugfs: fix Dir::scope() to not borrow self for returned lifetime Timur Tabi
2025-12-18 17:55 ` Matthew Maurer
2025-12-18 17:55 ` Matthew Maurer
2025-12-18 1:39 ` [PATCH v3 5/9] gpu: nova-core: Replace module_pci_driver! with explicit module init Timur Tabi
2025-12-18 9:01 ` Danilo Krummrich
2025-12-18 9:01 ` Danilo Krummrich
2025-12-18 1:39 ` [PATCH v3 6/9] gpu: nova-core: create debugfs root when driver loads Timur Tabi
2025-12-18 10:10 ` Danilo Krummrich
2025-12-18 10:10 ` Danilo Krummrich
2025-12-18 1:39 ` [PATCH v3 7/9] gpu: nova-core: implement BinaryWriter for LogBuffer Timur Tabi
2025-12-18 10:18 ` Danilo Krummrich
2025-12-18 10:18 ` Danilo Krummrich
2025-12-18 11:14 ` Alexandre Courbot
2025-12-18 1:39 ` [PATCH v3 8/9] gpu: nova-core: use pin projection in method boot() Timur Tabi
2025-12-18 1:39 ` [PATCH v3 9/9] gpu: nova-core: create GSP-RM logging buffers debugfs entries Timur Tabi
2025-12-21 10:05 ` kernel test robot
2025-12-18 8:07 ` [PATCH v3 0/9] gpu: nova-core: expose the logging buffers via debugfs Alice Ryhl
2025-12-18 8:07 ` Alice Ryhl
2025-12-18 8:44 ` Danilo Krummrich
2025-12-18 8:44 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DF18RFX3IHVP.3GYNJIYAFFJU6@kernel.org \
--to=dakr@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=joelagnelf@nvidia.com \
--cc=mmaurer@google.com \
--cc=nouveau@lists.freedesktop.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=ttabi@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.