All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Will Deacon <will@kernel.org>
Cc: Jason Baron <jbaron@akamai.com>,
	linux-kernel@vger.kernel.org, kernel-team@android.com
Subject: Re: [PATCH] dynamic_debug: allow to work if debugfs is disabled
Date: Wed, 22 Jan 2020 09:12:05 +0100	[thread overview]
Message-ID: <20200122081205.GA2227985@kroah.com> (raw)
In-Reply-To: <20200122080352.GA15354@willie-the-truck>

On Wed, Jan 22, 2020 at 08:03:53AM +0000, Will Deacon wrote:
> On Wed, Jan 22, 2020 at 08:43:43AM +0100, Greg Kroah-Hartman wrote:
> > With the realization that having debugfs enabled on "production" systems is
> > generally not a good idea, debugfs is being disabled from more and more
> > platforms over time.  However, the functionality of dynamic debugging still is
> > needed at times, and since it relies on debugfs for its user api, having
> > debugfs disabled also forces dynamic debug to be disabled.
> 
> Why is the dyndbg= command-line option not sufficient for these use-cases?

They want to enable things after booting, and changing the kernel
command line is not something you can do on many systems (i.e.
locked-down-bootloaders like embedded systems).

Also, the whole option is prevented to be booted if debugfs is not
enabled, so the command line wouldn't even work in that situation :)

> > To get around this, move the "control" file for dynamic_debug to procfs IFF
> > debugfs is disabled.  This lets people turn on debugging as needed at runtime
> > for individual driverfs and subsystems.
> 
> Hmm. If something called "dynamic_debug" is getting moved out of debugfs,
> this does raise the question as to what (if anything) should be left behind.
> I worry this is a bit of a slippery slope...

I totally agree, but dynamic_debug is independant of debugfs with the
exception of the control file itself.

> > Reported-by: many different companies
> > Cc: Jason Baron <jbaron@akamai.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  .../admin-guide/dynamic-debug-howto.rst         |  3 +++
> >  lib/Kconfig.debug                               |  2 +-
> >  lib/dynamic_debug.c                             | 17 ++++++++++++++---
> >  3 files changed, 18 insertions(+), 4 deletions(-)
> > 
> > diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
> > index 252e5ef324e5..41f43a373a6a 100644
> > --- a/Documentation/admin-guide/dynamic-debug-howto.rst
> > +++ b/Documentation/admin-guide/dynamic-debug-howto.rst
> > @@ -54,6 +54,9 @@ If you make a mistake with the syntax, the write will fail thus::
> >  				<debugfs>/dynamic_debug/control
> >    -bash: echo: write error: Invalid argument
> >  
> > +Note, for systems without 'debugfs' enabled, the control file can be
> > +also found in ``/proc/dynamic_debug/control``.
> > +
> >  Viewing Dynamic Debug Behaviour
> >  ===============================
> >  
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index 5ffe144c9794..01d4add8b963 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -98,7 +98,7 @@ config DYNAMIC_DEBUG
> >  	bool "Enable dynamic printk() support"
> >  	default n
> >  	depends on PRINTK
> > -	depends on DEBUG_FS
> > +	depends on (DEBUG_FS || PROC_FS)
> >  	help
> >  
> >  	  Compiles debug level messages into the kernel, which would noti
> 
> The help text here also needs updating, since it refers to debugfs.

Oops, missed that, thanks!

> > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> > index c60409138e13..077b2d6623ac 100644
> > --- a/lib/dynamic_debug.c
> > +++ b/lib/dynamic_debug.c
> > @@ -993,13 +993,24 @@ static __initdata int ddebug_init_success;
> >  
> >  static int __init dynamic_debug_init_debugfs(void)
> >  {
> > -	struct dentry *dir;
> > +	struct dentry *debugfs_dir;
> > +	struct proc_dir_entry *procfs_dir;
> >  
> >  	if (!ddebug_init_success)
> >  		return -ENODEV;
> >  
> > -	dir = debugfs_create_dir("dynamic_debug", NULL);
> > -	debugfs_create_file("control", 0644, dir, NULL, &ddebug_proc_fops);
> > +	/* Create the control file in debugfs if it is enabled */
> > +	if (debugfs_initialized) {
> > +		debugfs_dir = debugfs_create_dir("dynamic_debug", NULL);
> > +		debugfs_create_file("control", 0644, debugfs_dir, NULL,
> > +				    &ddebug_proc_fops);
> > +		return 0;
> > +	}
> > +
> > +	/* No debugfs so put it in procfs instead */
> > +	procfs_dir = proc_mkdir("dynamic_debug", NULL);
> > +	if (procfs_dir)
> > +		proc_create("control", 0x644, procfs_dir, &ddebug_proc_fops);
> 
> Shouldn't this be octal rather than hex? Even then, I don't understand what
> use it is being able to read but not write to this file. Perhaps make it
> 0600 for /proc ?

Argh, my fault, fingers are used to typing hex.

You can read from the file to see what the current settings are, I was
just trying to mirror the debugfs permissions.

thanks,

greg k-h

  reply	other threads:[~2020-01-22  8:12 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22  7:43 [PATCH] dynamic_debug: allow to work if debugfs is disabled Greg Kroah-Hartman
2020-01-22  8:03 ` Will Deacon
2020-01-22  8:12   ` Greg Kroah-Hartman [this message]
2020-01-22 13:53     ` [PATCH v2] " Greg Kroah-Hartman
2020-01-22 18:56       ` Jason Baron
2020-01-22 19:29         ` Greg Kroah-Hartman
2020-01-22 19:31           ` [PATCH v3] " Greg Kroah-Hartman
2020-01-22 21:43             ` Randy Dunlap
2020-01-23  8:48               ` Greg Kroah-Hartman
2020-01-23  8:50                 ` [PATCH v4] " Greg Kroah-Hartman
2020-01-23  9:36                   ` Will Deacon
2020-01-23 15:53             ` [PATCH v3] " Theodore Y. Ts'o
2020-01-23 17:55               ` Greg Kroah-Hartman
2020-01-24  6:02                 ` Theodore Y. Ts'o
2020-01-24  7:29                   ` Greg Kroah-Hartman
2020-01-25  1:42                     ` Theodore Y. Ts'o
2020-01-25 17:11                       ` Jonathan Corbet
2020-01-27 22:19                         ` Saravana Kannan
2020-02-09 11:05               ` [PATCH v5] " Greg Kroah-Hartman
2020-02-09 15:53                 ` Joe Perches
2020-02-09 17:03                   ` Greg Kroah-Hartman
2020-02-10 21:11                 ` [PATCH v6] " Greg Kroah-Hartman
2020-02-10 21:15                   ` Randy Dunlap
2020-02-12 21:58                     ` Greg Kroah-Hartman
2020-02-11 11:01                   ` Will Deacon
2020-01-25  0:03 ` [PATCH] " kbuild test robot
2020-01-25  0:03   ` kbuild test robot

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=20200122081205.GA2227985@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will@kernel.org \
    /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.