From: Andrew Morton <akpm@linux-foundation.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Kuleshov <kuleshovmail@gmail.com>,
Tony Luck <tony.luck@intel.com>,
Pekka Enberg <penberg@kernel.org>, Mel Gorman <mgorman@suse.de>,
Baoquan He <bhe@redhat.com>, Tang Chen <tangchen@cn.fujitsu.com>,
Robin Holt <holt@sgi.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/memblock: validate the creation of debugfs files
Date: Mon, 17 Aug 2015 15:05:21 -0700 [thread overview]
Message-ID: <20150817150521.4f353d130a2d67e89b7ac1ad@linux-foundation.org> (raw)
In-Reply-To: <20150815160730.GB25186@kroah.com>
On Sat, 15 Aug 2015 09:07:30 -0700 Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> > > in the kernel/kprobes and etc.), besides this, the memblock API is used
> > > mostly at early stage, so we will have some output if something going wrong.
> >
> > The debugfs error-handling rules are something Greg cooked up after one
> > too many beers. I've never understood them, but maybe I continue to
> > miss the point.
>
> The "point" is that it should be easy to use, and you don't care if the
> file fails to be created because your normal code flow / functionality
> does not care if a debugfs file fails to be created.
>
> The only way a debugfs file will fail to be created is if you name
> something the same as a file is present, or you passed in the wrong
> options, or if you are out of memory, and in all of those cases, there's
> nothing a user can do about it. Yes, when writing your code the first
> time, check the error if you want to figure out your logic, but after
> that, you don't care.
>
> If debugfs is not enabled, yes, an error will be returned, but you don't
> have to care about that, because again, you don't care, and your main
> code path is just fine.
>
> So just ignore the return value of debugfs functions, except to save off
> pointers that you need to pass back in them later.
>
> > Yes, I agree that if memblock's debugfs_create_file() fails, we want to
> > know about it because something needs fixing.
>
> What can be fixed? Out of memory? Identical file name? Nothing a user
> can do about that.
wha? We have thousands and thousands of assertions in the kernel and
there's nothing the user can do about any them, apart from sending us a
bug report.
If debugfs_create_file() fails then something is messed up in the
kernel. The kernel error shouldn't just be ignored! It should be
reported and fixed.
> > But that's true of
> > all(?) debugfs_create_file callsites, so it's a bit silly to add
> > warnings to them all. Why not put the warning into
> > debugfs_create_file() itself? And add a debugfs_create_file_no_warn()
> > if there are callsites which have reason to go it alone. Or add a
> > debugfs_create_file_warn() wrapper.
>
> No, it's really not worth it. The goal of debugfs was to make an api
> that is easier to use than procfs which required a bunch of odd return
> error checks and you could never tell if the error was due to something
> real or if the procfs was not enabled in the kernel.
>
> And it's for debugging files, again, nothing that should be something
> you rely on. If you rely on debugfs files for something, well, you are
> using the wrong api (yes, I know all about the trace nightmare...)
Yeah. That's just wrong. debugfs is just kernel code. If it goes
wrong we should handle that in the usual way, so it gets fixed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2015-08-17 22:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-14 19:03 Alexander Kuleshov
2015-08-14 21:19 ` Andrew Morton
2015-08-15 7:26 ` Alexander Kuleshov
2015-08-15 7:38 ` Andrew Morton
2015-08-15 7:48 ` Alexander Kuleshov
2015-08-15 7:52 ` Andrew Morton
2015-08-15 16:07 ` Greg Kroah-Hartman
2015-08-17 22:05 ` Andrew Morton [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=20150817150521.4f353d130a2d67e89b7ac1ad@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=holt@sgi.com \
--cc=kuleshovmail@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=penberg@kernel.org \
--cc=tangchen@cn.fujitsu.com \
--cc=tony.luck@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox