linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Subject: Re: [PATCH] coresight: cpu-debug: no need to check return value of debugfs_create functions
Date: Wed, 19 Jun 2019 17:27:05 +0200	[thread overview]
Message-ID: <20190619152705.GD29425@kroah.com> (raw)
In-Reply-To: <CANLsYkwjKDP2QOLgeTj=z90jXFjT9d3JXB0TxJU=v12MCi1PFA@mail.gmail.com>

On Tue, Jun 18, 2019 at 01:26:12PM -0600, Mathieu Poirier wrote:
> On Tue, 18 Jun 2019 at 11:46, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Tue, Jun 18, 2019 at 11:23:25AM -0600, Mathieu Poirier wrote:
> > > Hi Greg,
> > >
> > > On Tue, 18 Jun 2019 at 09:52, Greg Kroah-Hartman
> > > <gregkh@linuxfoundation.org> wrote:
> > > >
> > > > When calling debugfs functions, there is no need to ever check the
> > > > return value.  The function can work or not, but the code logic should
> > > > never do something different based on this.
> > >
> > > Looking around in the kernel there is no shortage of instances where
> > > the return value of debugfs functions are checked and the logic
> > > altered based on these values.  But there are also just as many that
> > > don't...  It also seems counter intuitive to ignore the return value
> > > of any function, something that in most case is guaranteed to raise
> > > admonition.
> >
> > In my tree, those instances are almost all gone.  I've also posted over
> > 100+ patches in the past few weeks to clean this up.
> >
> > > That being said I am sure there is a good reason to support your
> > > position - would you mind expanding a little so that I can follow?
> >
> > No kernel code should ever care if debugfs works or not.  No user code
> > should ever require it for normal operation either.  debugfs was written
> > to be simple and easy to use, no need to check any return values at all.
> >
> > Any return value of a debugfs call can be fed back into another call
> > with no issues at all.
> >
> > Also, due to some debugfs core changes a few kernel releases ago, the
> > checks:
> >         if (!debug_debugfs_dir) {
> > ...
> >         if (!file) {
> > can never trigger as debugfs_create_dir() or debugfs_create_file() can
> > never return NULL (and in the past, it almost never would either).  So
> 
> That is the rational I was looking for.
> 
> > as it is, that code isn't correct anyway (my fault, I know, hey, I'm
> > trying to fix it!)
> >
> > I'm trying to make things simple, and easy, and impossible to get wrong.
> > I know it goes against the normal "robust" kernel development mentality,
> > but there is no need to ever care about debugfs at all.
> >
> > The reason I started all of this is that we have found places where
> > userspace, and the kernel, was depending on the proper operation of
> > debugfs.  In one horrid example, a device would not display the batter
> > level if debugfs was disabled.  In another case, the kernel was actually
> > relying on a debugfs call to fail in order to handle some logic the
> > subsystem should have been doing on its own.  All of that has now been
> > cleaned up, and I am working on making debugfs just not return any
> > values at all to prevent this type of mess happening again.
> >
> > And hey, I am removing code, here's my current tree as a diff from
> > what is not already merged into linux-next:
> >          301 files changed, 1394 insertions(+), 4637 deletions(-)
> > that's always a good thing :)
> >
> > Hopefully this helps explain things better.
> 
> It does - thanks for taking the time to write all this.
> 
> Do you want me to take the patch through my tree (only to see it
> coming back to you later this week) or you'll add it directly to
> yours?  In the latter case:
> 
> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org>

I can just take it directly, thanks!

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2019-06-19 15:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 15:52 [PATCH] coresight: cpu-debug: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-18 17:23 ` Mathieu Poirier
2019-06-18 17:46   ` Greg Kroah-Hartman
2019-06-18 17:52     ` Greg Kroah-Hartman
2019-06-18 19:26     ` Mathieu Poirier
2019-06-19 15:27       ` Greg Kroah-Hartman [this message]

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=20190619152705.GD29425@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=suzuki.poulose@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).