All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: alsa-devel@alsa-project.org, Jie Yang <yang.jie@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <liam.r.girdwood@linux.intel.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH 2/5] sound: soc: skylake: no need to check return value of debugfs_create functions
Date: Sun, 23 Jun 2019 17:55:35 +0200	[thread overview]
Message-ID: <20190623155535.GB17284@kroah.com> (raw)
In-Reply-To: <398523ac-5ef8-2f13-ff2c-9837a7d6518c@intel.com>

On Sun, Jun 23, 2019 at 05:18:39PM +0200, Cezary Rojewski wrote:
> 
> On 2019-06-23 06:57, Greg Kroah-Hartman wrote:
> > On Sat, Jun 22, 2019 at 09:57:07PM +0200, Cezary Rojewski wrote:
> > > 
> > > On 2019-06-14 11:47, Greg Kroah-Hartman 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.
> > > > 
> > > 
> > > This change heavily impacts user space and development kits used by us
> > > internally, and our clients. That is, if anything goes wrong during debugfs
> > > initialization process.
> > 
> > As Takashi said, and as I said numerous times, how can anything go wrong
> > during debugfs file creation that does not also cause the rest of your
> > system to just crash. >
> > userspace should NEVER care about a debugfs file being present or not.
> > If it does, then you should not be using debugfs as it is never
> > guaranteed to be present on a system (and is locked down and removed on
> > many shipping systems for good reason.)
> > 
> > For development, it's wonderful, but it truely is just a debugging aid.
> > 
> > > Currently, apps may safely assume entire debugfs tree is up and running once
> > > audio stack gets enumerated successfully. With your patch this is no longer
> > > the case and user space is forced to verify status of all debugfs files and/
> > > or directories manually.
> > 
> > What apps rely on debugfs for audio?  We need to fix those.
> > 
> 
> Takashi,
> Thanks for reply. I hope you don't mind me replying here and not explicitly
> on your post. My message would be exactly the same as the one you see below.
> 
> 
> Greg,
> Forgive me for not clarifying: by userspace of course I meant any
> development/ debug related app which we use exhaustively.
> 
> Look at this from different perspective: I'm "just" a user of debugfs
> interface. I call a function and given its declaration I receive either 0 on
> success or != 0 on failure. Definition of said function may change in time
> and -ENOMEM might not be the only possible outcome, but that I leave to
> other developers and as long as behavior remains the same, changes are
> welcome.

Again, you should not even care if a debugfs call succeeds or not.

> Moreover, if we're compiling with CONFIG_DEBUGFS=1, driver may choose to
> collapse during probe if any of debugfs objects fail to initialize: in this
> case one can say CONFIG_DEBUGFS adds yet another condition for enumeration
> to be considered successful.

It should never matter to your code.

Debugfs was written to be much simpler and easier to use than procfs.
It goes against the "normal" defensive mode of kernel programming in
that you should not care if it works or not, your code should just keep
on working no matter what.

> > Again, my goal with these changes is two things:
> >    - no kernel operation should ever modify its behavior if debugfs is
> >      enabled, or working, at all.
> >    - no normal userspace code should ever care if debugfs is working
> > 
> > debugfs is for debugging things, that is all.  If you have system
> > functionality relying on files in debugfs, they need to be moved to a
> > system functionality that is always going to be present for your users
> > (i.e. sysfs, configfs, tracefs, etc.)
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> With mindset "may or may not succeed" one might as well resign from debugfs
> entirely and move to sysfs and other fs you'd mentioned.

That's fine, but do not put debugging stuff in sysfs please.  There are
strict rules on what you can and can not do in sysfs and other
filesystems.  Debugfs has no such rules except that no userspace code
should ever care about it.

> And why would he otherwise, when the only way to verify debugfs object
> state is either log parsing (filtering errors) or file-exists check.
> 
> My app should not be guessing, instead, it should know upfront with what its
> working with.

What app digs around in debugfs that any user should care about?  The
goal is to never have any functionality in there that the system
requires in order to work properly.

Again, we have found places where this is not the case, and it is being
fixed to remove that dependancy.

debugfs is "fire and forget" and used for debugging stuff only.  No
working system should care at all about it.

thanks,

greg k-h

  reply	other threads:[~2019-06-23 16:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14  9:47 [PATCH 1/5] sound: SoC: sof: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-14  9:47 ` [PATCH 2/5] sound: soc: skylake: " Greg Kroah-Hartman
2019-06-22 19:57   ` Cezary Rojewski
2019-06-22 20:39     ` Takashi Iwai
     [not found]       ` <20190624105334.GJ5316@sirena.org.uk>
2019-06-24 13:15         ` Takashi Iwai
2019-06-24 13:33           ` Mark Brown
2019-06-27  0:23             ` Greg Kroah-Hartman
2019-06-23  4:57     ` Greg Kroah-Hartman
2019-06-23 15:18       ` Cezary Rojewski
2019-06-23 15:55         ` Greg Kroah-Hartman [this message]
2019-06-14  9:47 ` [PATCH 3/5] sound: soc: codecs: wm_adsp: " Greg Kroah-Hartman
2019-06-14 10:24   ` Richard Fitzgerald
2019-06-14 15:43   ` Applied "ASoC: wm_adsp: no need to check return value of debugfs_create functions" to the asoc tree Mark Brown
2019-06-14  9:47 ` [PATCH 4/5] sound: soc: fsl: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-14 15:43   ` Applied "ASoC: fsl: no need to check return value of debugfs_create functions" to the asoc tree Mark Brown
2019-06-14  9:47 ` [PATCH 5/5] sound: soc: core: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-14 15:34   ` Mark Brown
2019-06-14 16:13     ` Greg Kroah-Hartman
2019-06-14 17:41       ` Mark Brown
2019-06-14 14:59 ` [PATCH 1/5] sound: SoC: sof: " Mark Brown
2019-06-14 15:28   ` Greg Kroah-Hartman
2019-06-14 15:14 ` Mark Brown
2019-06-14 15:27   ` Greg Kroah-Hartman
2019-06-14 16:37     ` Mark Brown

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=20190623155535.GB17284@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=yang.jie@linux.intel.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.