[PATCH v12 03/10] ref_tracker: add a top level debugfs directory for ref_tracker

Jeff Layton jlayton at kernel.org
Mon Jun 9 18:10:52 UTC 2025


On Wed, 2025-06-04 at 12:12 +0300, Jani Nikula wrote:
> On Thu, 29 May 2025, Jeff Layton <jlayton at kernel.org> wrote:
> > Add a new "ref_tracker" directory in debugfs. Each individual refcount
> > tracker can register files under there to display info about
> > currently-held references.
> > 
> > Reviewed-by: Andrew Lunn <andrew at lunn.ch>
> > Signed-off-by: Jeff Layton <jlayton at kernel.org>
> > ---
> >  lib/ref_tracker.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
> > index de71439e12a3bab6456910986fa611dfbdd97980..d374e5273e1497cac0d70c02c282baa2c3ab63fe 100644
> > --- a/lib/ref_tracker.c
> > +++ b/lib/ref_tracker.c
> > @@ -273,3 +273,16 @@ int ref_tracker_free(struct ref_tracker_dir *dir,
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL_GPL(ref_tracker_free);
> > +
> > +#ifdef CONFIG_DEBUG_FS
> > +#include <linux/debugfs.h>
> > +
> > +static struct dentry *ref_tracker_debug_dir = (struct dentry *)-ENOENT;
> 
> Nitpick, please prefer ERR_PTR(-ENOENT) over casting inline.
> 
> 
Sorry I didn't respond to this earlier. I'd prefer that too, but when I
try that, I get:

lib/ref_tracker.c:327:47: error: initializer element is not constant
  327 | static struct dentry *ref_tracker_debug_dir = ERR_PTR(-ENOENT);
      |                                               ^~~~~~~


> 
> > +
> > +static int __init ref_tracker_debugfs_init(void)
> > +{
> > +	ref_tracker_debug_dir = debugfs_create_dir("ref_tracker", NULL);
> > +	return 0;
> > +}
> > +late_initcall(ref_tracker_debugfs_init);
> > +#endif /* CONFIG_DEBUG_FS */

-- 
Jeff Layton <jlayton at kernel.org>


More information about the dri-devel mailing list