LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch 3/4] make pr_debug() dynamic - sysctl support
@ 2008-02-07 21:12 Jason Baron
  2008-02-08  0:10 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Baron @ 2008-02-07 21:12 UTC (permalink / raw)
  To: mathieu.desnoyers; +Cc: akpm, mingo, fche, linux-kernel


-add /proc/sys/debug/pr_debug, to toggle pr_debug() on/off

Signed-off-by: Jason Baron <jbaron@redhat.com>
---

 kernel/sysctl.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)


diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 7cb1ac3..73508d7 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -155,6 +155,11 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp
 static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
 			       void __user *buffer, size_t *lenp, loff_t *ppos);
 #endif
+#ifdef CONFIG_PR_DEBUG_DYNAMIC
+static int proc_pr_debug_handler(struct ctl_table *table, int write,
+				 struct file *filp, void __user *buffer,
+				 size_t *lenp, loff_t *ppos);
+#endif
 
 static struct ctl_table root_table[];
 static struct ctl_table_root sysctl_table_root;
@@ -1312,6 +1317,16 @@ static struct ctl_table debug_table[] = {
 		.proc_handler	= proc_dointvec
 	},
 #endif
+#ifdef CONFIG_PR_DEBUG_DYNAMIC
+	{
+		.ctl_name       = CTL_UNNUMBERED,
+		.procname       = "pr_debug",
+		.data           = NULL,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = &proc_pr_debug_handler
+	},
+#endif
 	{ .ctl_name = 0 }
 };
 
@@ -2499,6 +2514,32 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp
 	return 0;
 }
 
+#ifdef CONFIG_PR_DEBUG_DYNAMIC
+
+static int proc_pr_debug_handler(struct ctl_table *table, int write,
+				 struct file *filp, void __user *buffer,
+				 size_t *lenp, loff_t *ppos)
+{
+	int tmp, r;
+
+	if (!write)
+		tmp = imv_read(pr_debug_on);
+	r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
+				lenp, ppos, NULL, NULL);
+	if (r)
+		return r;
+
+	if (write) {
+		if (tmp)
+			imv_set(pr_debug_on, 1);
+		else
+			imv_set(pr_debug_on, 0);
+	}
+	return 0;
+}
+
+#endif
+
 #else /* CONFIG_PROC_FS */
 
 int proc_dostring(struct ctl_table *table, int write, struct file *filp,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch 3/4] make pr_debug() dynamic - sysctl support
  2008-02-07 21:12 [patch 3/4] make pr_debug() dynamic - sysctl support Jason Baron
@ 2008-02-08  0:10 ` Stephen Hemminger
  2008-02-08 15:49   ` Jason Baron
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2008-02-08  0:10 UTC (permalink / raw)
  To: linux-kernel

On Thu, 7 Feb 2008 16:12:29 -0500
Jason Baron <jbaron@redhat.com> wrote:

> 
> -add /proc/sys/debug/pr_debug, to toggle pr_debug() on/off
> 
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> ---
> 
>  kernel/sysctl.c |   41 +++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 41 insertions(+), 0 deletions(-)
> 
> 
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 7cb1ac3..73508d7 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -155,6 +155,11 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp
>  static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
>  			       void __user *buffer, size_t *lenp, loff_t *ppos);
>  #endif
> +#ifdef CONFIG_PR_DEBUG_DYNAMIC
> +static int proc_pr_debug_handler(struct ctl_table *table, int write,
> +				 struct file *filp, void __user *buffer,
> +				 size_t *lenp, loff_t *ppos);
> +#endif
>  
>  static struct ctl_table root_table[];
>  static struct ctl_table_root sysctl_table_root;
> @@ -1312,6 +1317,16 @@ static struct ctl_table debug_table[] = {
>  		.proc_handler	= proc_dointvec
>  	},
>  #endif
> +#ifdef CONFIG_PR_DEBUG_DYNAMIC
> +	{
> +		.ctl_name       = CTL_UNNUMBERED,
> +		.procname       = "pr_debug",
> +		.data           = NULL,
> +		.maxlen         = sizeof(int),
> +		.mode           = 0644,
> +		.proc_handler   = &proc_pr_debug_handler
> +	},
> +#endif
>  	{ .ctl_name = 0 }
>  };
>  
> @@ -2499,6 +2514,32 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PR_DEBUG_DYNAMIC
> +
> +static int proc_pr_debug_handler(struct ctl_table *table, int write,
> +				 struct file *filp, void __user *buffer,
> +				 size_t *lenp, loff_t *ppos)
> +{
> +	int tmp, r;
> +
> +	if (!write)
> +		tmp = imv_read(pr_debug_on);
> +	r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
> +				lenp, ppos, NULL, NULL);
> +	if (r)
> +		return r;
> +
> +	if (write) {
> +		if (tmp)
> +			imv_set(pr_debug_on, 1);
> +		else
> +			imv_set(pr_debug_on, 0);
> +	}
> +	return 0;
> +}
> +
> +#endif
> +
>  #else /* CONFIG_PROC_FS */
>  
>  int proc_dostring(struct ctl_table *table, int write, struct file *filp,

Please no, there are many pr_debug calls that are only intended for debugging that
particular subsystem, not a global enable/disable. It also adds to kernel bloat.

-- 
Stephen Hemminger <stephen.hemminger@vyatta.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch 3/4] make pr_debug() dynamic - sysctl support
  2008-02-08  0:10 ` Stephen Hemminger
@ 2008-02-08 15:49   ` Jason Baron
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Baron @ 2008-02-08 15:49 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-kernel

On Thu, Feb 07, 2008 at 04:10:52PM -0800, Stephen Hemminger wrote:
> Jason Baron <jbaron@redhat.com> wrote:
> 
> > 
> > -add /proc/sys/debug/pr_debug, to toggle pr_debug() on/off
> > 
> > Signed-off-by: Jason Baron <jbaron@redhat.com>
> > ---
> > 
> >  kernel/sysctl.c |   41 +++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 41 insertions(+), 0 deletions(-)
> > 
> > 
> > diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> > index 7cb1ac3..73508d7 100644
> > --- a/kernel/sysctl.c
> > +++ b/kernel/sysctl.c
> > @@ -155,6 +155,11 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp
> >  static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
> >  			       void __user *buffer, size_t *lenp, loff_t *ppos);
> >  #endif
> > +#ifdef CONFIG_PR_DEBUG_DYNAMIC
> > +static int proc_pr_debug_handler(struct ctl_table *table, int write,
> > +				 struct file *filp, void __user *buffer,
> > +				 size_t *lenp, loff_t *ppos);
> > +#endif
> >  
> >  static struct ctl_table root_table[];
> >  static struct ctl_table_root sysctl_table_root;
> > @@ -1312,6 +1317,16 @@ static struct ctl_table debug_table[] = {
> >  		.proc_handler	= proc_dointvec
> >  	},
> >  #endif
> > +#ifdef CONFIG_PR_DEBUG_DYNAMIC
> > +	{
> > +		.ctl_name       = CTL_UNNUMBERED,
> > +		.procname       = "pr_debug",
> > +		.data           = NULL,
> > +		.maxlen         = sizeof(int),
> > +		.mode           = 0644,
> > +		.proc_handler   = &proc_pr_debug_handler
> > +	},
> > +#endif
> >  	{ .ctl_name = 0 }
> >  };
> >  
> > @@ -2499,6 +2514,32 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp
> >  	return 0;
> >  }
> >  
> > +#ifdef CONFIG_PR_DEBUG_DYNAMIC
> > +
> > +static int proc_pr_debug_handler(struct ctl_table *table, int write,
> > +				 struct file *filp, void __user *buffer,
> > +				 size_t *lenp, loff_t *ppos)
> > +{
> > +	int tmp, r;
> > +
> > +	if (!write)
> > +		tmp = imv_read(pr_debug_on);
> > +	r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
> > +				lenp, ppos, NULL, NULL);
> > +	if (r)
> > +		return r;
> > +
> > +	if (write) {
> > +		if (tmp)
> > +			imv_set(pr_debug_on, 1);
> > +		else
> > +			imv_set(pr_debug_on, 0);
> > +	}
> > +	return 0;
> > +}
> > +
> > +#endif
> > +
> >  #else /* CONFIG_PROC_FS */
> >  
> >  int proc_dostring(struct ctl_table *table, int write, struct file *filp,
> 
> Please no, there are many pr_debug calls that are only intended for debugging that
> particular subsystem, not a global enable/disable. It also adds to kernel bloat.
> 

Yes, but you are going to have to re-compile your kernel to get at them...the
ability to turn on/off pr_debug() calls, at runtime, seems like a powerful
runtime diagnostic tool...the CONFIG_PR_DEBUG_DYNAMIC can default to 'n',
instead of being automactically set as I've proposed. In terms of bloat, the
vmlinux file goes from 53649330 to 53985478, < %1 increase.

thanks,

-Jason


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-08 15:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-07 21:12 [patch 3/4] make pr_debug() dynamic - sysctl support Jason Baron
2008-02-08  0:10 ` Stephen Hemminger
2008-02-08 15:49   ` Jason Baron

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).