All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: "Zhu, Lingshan" <lingshan.zhu@amd.com>
Cc: "Srinivasan Shanmugam" <srinivasan.shanmugam@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	amd-gfx@lists.freedesktop.org,
	"Felix Kuehling" <felix.kuehling@amd.com>
Subject: Re: [PATCH] drm/amdkfd: Do not fail process debugfs setup on debugfs errors
Date: Fri, 10 Jul 2026 16:57:17 +0300	[thread overview]
Message-ID: <alD6PcLowqjVBnSl@stanley.mountain> (raw)
In-Reply-To: <04d7a46f-3bba-412d-bfd4-89292d11e1db@amd.com>

On Fri, Jul 10, 2026 at 09:47:32PM +0800, Zhu, Lingshan wrote:
> On 7/10/2026 7:29 PM, Srinivasan Shanmugam wrote:
> 
> > debugfs is intended for debugging only, and failures to create debugfs
> > entries should not affect normal operation.
> >
> > Remove the check for debugfs_create_dir() in kfd_debugfs_add_process().
> > If debugfs entries cannot be created, continue without them instead of
> > reporting an unnecessary error.
> >
> > Fixes: 22ab1bb3994a ("amdkfd: expose pasid of secondary contexts by debugfs")
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Cc: Zhu Lingshan <lingshan.zhu@amd.com>
> > Cc: Felix Kuehling <felix.kuehling@amd.com>
> > Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
> > ---
> >  drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c | 4 ----
> >  1 file changed, 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
> > index 02673f01b448..7c5bc9c4559a 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
> > @@ -211,10 +211,6 @@ int kfd_debugfs_add_process(struct kfd_process *p)
> >  		entry->proc_dentry = debugfs_create_dir(name,
> >  							primary_entry->proc_dentry);
> >  	}
> > -	if (IS_ERR_OR_NULL(entry->proc_dentry)) {
> > -		ret = entry->proc_dentry ? PTR_ERR(entry->proc_dentry) : -ENOMEM;
> > -		goto err_free_entry;
> > -	}
> 
> We need this check because debugfs_create_dir() may fail.
> Removing this check leads to entry leaking when fail.
> 

Debugfs functions aren't supposed to be checked.  Drivers aren't
supposed to rely on debugfs so it's not required.  If debugfs is
failing then you are pretty much screwed anyway.

I have a blog about the history of this:
https://staticthinking.wordpress.com/2023/07/24/debugfs-functions-are-not-supposed-to-be-checked/

This code is inside #if defined(CONFIG_DEBUG_FS) so the check
isn't harmful except that it sets a bad example.  Back in the day,
this used to be a source of pain for me so Greg made it hard to
write a correct check unless you have the #ifdef.  It's to
discourage checking.

regards,
dan carpenter


  reply	other threads:[~2026-07-12 15:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 11:29 [PATCH] drm/amdkfd: Do not fail process debugfs setup on debugfs errors Srinivasan Shanmugam
2026-07-10 12:34 ` Christian König
2026-07-10 13:47 ` Zhu, Lingshan
2026-07-10 13:57   ` Dan Carpenter [this message]
2026-07-10 14:08     ` Zhu, Lingshan
2026-07-10 14:12       ` Dan Carpenter
2026-07-10 14:42         ` Zhu, Lingshan
2026-07-10 14:45       ` Christian König

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=alD6PcLowqjVBnSl@stanley.mountain \
    --to=error27@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=felix.kuehling@amd.com \
    --cc=lingshan.zhu@amd.com \
    --cc=srinivasan.shanmugam@amd.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.