2021-05-19 18:31:42

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2] b43: don't save dentries for debugfs

On 2021-05-18 09:33, Greg Kroah-Hartman wrote:
> There is no need to keep around the dentry pointers for the debugfs
> files as they will all be automatically removed when the subdir is
> removed. So save the space and logic involved in keeping them around
> by
> just getting rid of them entirely.
>
> By doing this change, we remove one of the last in-kernel user that was
> storing the result of debugfs_create_bool(), so that api can be cleaned
> up.

Question not about this specific change, but the general concept
of keeping (or not keeping) dentry pointers. In the ath drivers,
as well as in an out-of-tree driver for Android, we keep a
debugfs dentry pointer to use as a param to relay_open().

Will we still be able to have a dentry pointer for this purpose?
Or better, is there a recommended way to get a dentry pointer
NOT associated with debugfs at all (which would be ideal for
Android where debugfs is disabled).

Thanks,
Jeff

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
a Linux Foundation Collaborative Project


2021-05-19 18:39:22

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2] b43: don't save dentries for debugfs

On 2021-05-18 12:29, Jeff Johnson wrote:
> On 2021-05-18 09:33, Greg Kroah-Hartman wrote:
>> There is no need to keep around the dentry pointers for the debugfs
>> files as they will all be automatically removed when the subdir is
>> removed. So save the space and logic involved in keeping them around
>> by
>> just getting rid of them entirely.
>>
>> By doing this change, we remove one of the last in-kernel user that
>> was
>> storing the result of debugfs_create_bool(), so that api can be
>> cleaned
>> up.
>
> Question not about this specific change, but the general concept
> of keeping (or not keeping) dentry pointers. In the ath drivers,
> as well as in an out-of-tree driver for Android, we keep a
> debugfs dentry pointer to use as a param to relay_open().
>
> Will we still be able to have a dentry pointer for this purpose?
> Or better, is there a recommended way to get a dentry pointer
> NOT associated with debugfs at all (which would be ideal for
> Android where debugfs is disabled).

Answering one of my questions: The dentry passed to relay_open() comes
from debugfs_create_dir() which is expected to return a dentry.

Would still like guidance on if there is a recommended way to get a
dentry not associated with debugfs.

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
a Linux Foundation Collaborative Project

2021-05-19 19:11:27

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] b43: don't save dentries for debugfs

On Tue, May 18, 2021 at 03:00:44PM -0700, Jeff Johnson wrote:
> On 2021-05-18 12:29, Jeff Johnson wrote:
> > On 2021-05-18 09:33, Greg Kroah-Hartman wrote:
> > > There is no need to keep around the dentry pointers for the debugfs
> > > files as they will all be automatically removed when the subdir is
> > > removed. So save the space and logic involved in keeping them
> > > around by
> > > just getting rid of them entirely.
> > >
> > > By doing this change, we remove one of the last in-kernel user that
> > > was
> > > storing the result of debugfs_create_bool(), so that api can be
> > > cleaned
> > > up.
> >
> > Question not about this specific change, but the general concept
> > of keeping (or not keeping) dentry pointers. In the ath drivers,
> > as well as in an out-of-tree driver for Android, we keep a
> > debugfs dentry pointer to use as a param to relay_open().
> >
> > Will we still be able to have a dentry pointer for this purpose?
> > Or better, is there a recommended way to get a dentry pointer
> > NOT associated with debugfs at all (which would be ideal for
> > Android where debugfs is disabled).
>
> Answering one of my questions: The dentry passed to relay_open() comes
> from debugfs_create_dir() which is expected to return a dentry.
>
> Would still like guidance on if there is a recommended way to get a
> dentry not associated with debugfs.

What do you exactly mean by "not associated with debugfs"?

And why are you passing a debugfs dentry to relay_open()? That feels
really wrong and fragile.

Ideally I want to get rid of the "raw" dentry that debugfs returns to
callers, as it has caused odd problems in the past, but that's a very
long-term project...

thanks,

greg k-h

2021-05-19 20:12:23

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2] b43: don't save dentries for debugfs

On 2021-05-18 22:05, Greg Kroah-Hartman wrote:
> On Tue, May 18, 2021 at 03:00:44PM -0700, Jeff Johnson wrote:
>> On 2021-05-18 12:29, Jeff Johnson wrote:
>> Would still like guidance on if there is a recommended way to get a
>> dentry not associated with debugfs.
>
> What do you exactly mean by "not associated with debugfs"?
>
> And why are you passing a debugfs dentry to relay_open()? That feels
> really wrong and fragile.

I don't know the history but the relay documentation tells us:
"If you want a directory structure to contain your relay files,
you should create it using the host filesystem’s directory
creation function, e.g. debugfs_create_dir()..."

So my guess is that the original implementation followed that
advice. I see 5 clients of this functionality, and all 5 pass a
dentry returned from debugfs_create_dir():

drivers/gpu/drm/i915/gt/uc/intel_guc_log.c, line 384
drivers/net/wireless/ath/ath10k/spectral.c, line 534
drivers/net/wireless/ath/ath11k/spectral.c, line 902
drivers/net/wireless/ath/ath9k/common-spectral.c, line 1077
kernel/trace/blktrace.c, line 549

Jeff
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
a Linux Foundation Collaborative Project

2021-05-19 20:13:13

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] b43: don't save dentries for debugfs

On Wed, May 19, 2021 at 08:04:59AM -0700, Jeff Johnson wrote:
> On 2021-05-18 22:05, Greg Kroah-Hartman wrote:
> > On Tue, May 18, 2021 at 03:00:44PM -0700, Jeff Johnson wrote:
> > > On 2021-05-18 12:29, Jeff Johnson wrote:
> > > Would still like guidance on if there is a recommended way to get a
> > > dentry not associated with debugfs.
> >
> > What do you exactly mean by "not associated with debugfs"?
> >
> > And why are you passing a debugfs dentry to relay_open()? That feels
> > really wrong and fragile.
>
> I don't know the history but the relay documentation tells us:
> "If you want a directory structure to contain your relay files,
> you should create it using the host filesystem’s directory
> creation function, e.g. debugfs_create_dir()..."
>
> So my guess is that the original implementation followed that
> advice. I see 5 clients of this functionality, and all 5 pass a
> dentry returned from debugfs_create_dir():
>
> drivers/gpu/drm/i915/gt/uc/intel_guc_log.c, line 384
> drivers/net/wireless/ath/ath10k/spectral.c, line 534
> drivers/net/wireless/ath/ath11k/spectral.c, line 902
> drivers/net/wireless/ath/ath9k/common-spectral.c, line 1077
> kernel/trace/blktrace.c, line 549

Ah, that's just the "parent" dentry for the relayfs file. That's fine,
not a big deal, debugfs will always provide a way for you to get that if
needed.

thanks,

greg k-h

2021-05-19 20:13:53

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2] b43: don't save dentries for debugfs

On 2021-05-19 08:42, Greg Kroah-Hartman wrote:
> On Wed, May 19, 2021 at 08:04:59AM -0700, Jeff Johnson wrote:
>> On 2021-05-18 22:05, Greg Kroah-Hartman wrote:
>> > On Tue, May 18, 2021 at 03:00:44PM -0700, Jeff Johnson wrote:
>> > > On 2021-05-18 12:29, Jeff Johnson wrote:
>> > > Would still like guidance on if there is a recommended way to get a
>> > > dentry not associated with debugfs.
>> >
>> > What do you exactly mean by "not associated with debugfs"?
>> >
>> > And why are you passing a debugfs dentry to relay_open()? That feels
>> > really wrong and fragile.
>>
>> I don't know the history but the relay documentation tells us:
>> "If you want a directory structure to contain your relay files,
>> you should create it using the host filesystem’s directory
>> creation function, e.g. debugfs_create_dir()..."
>>
>> So my guess is that the original implementation followed that
>> advice. I see 5 clients of this functionality, and all 5 pass a
>> dentry returned from debugfs_create_dir():
>>
>> drivers/gpu/drm/i915/gt/uc/intel_guc_log.c, line 384
>> drivers/net/wireless/ath/ath10k/spectral.c, line 534
>> drivers/net/wireless/ath/ath11k/spectral.c, line 902
>> drivers/net/wireless/ath/ath9k/common-spectral.c, line 1077
>> kernel/trace/blktrace.c, line 549
>
> Ah, that's just the "parent" dentry for the relayfs file. That's fine,
> not a big deal, debugfs will always provide a way for you to get that
> if
> needed.

Unless debugfs is disabled, like on Android, which is the real problem
I'm
trying to solve.

Jeff
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
a Linux Foundation Collaborative Project