public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Jason Baron <jbaron@redhat.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	greg@kroah.com, nick@nick-andrew.net, randy.dunlap@oracle.com
Subject: Re: [PATCH 2/8] dynamic debug - core infrastructure
Date: Fri, 13 Jun 2008 15:30:18 -0700	[thread overview]
Message-ID: <1213396218.5463.48.camel@localhost> (raw)
In-Reply-To: <20080613190039.GC8813@redhat.com>

On Fri, 2008-06-13 at 15:00 -0400, Jason Baron wrote:
> This is the core patch that implements a new dynamic debug
> infrastructure.

Some general and specific comments.

> +int dynamic_printk_enabled[NR_CPUS];

I don't understand why you use NR_CPUS.

Also, I think the major use cases are 1 or 2 modules enabled,
no modules enabled, or all modules enabled, so the hashing of
module names is particularly not useful.

Any pr_debug or dev_dbg is in a slow path.

I think a list and a direct comparison to KBUILD_MODNAME
would be simpler and as fast as necessary.

> +         To set the level or flag value for type 'level' or 'flag': 
> +
> +               $echo "set level=<#> <module_name>" > dynamic_printk/modules
> +

I think that set level=<#> should also work for "all"

Perhaps a simpler interface would be to use
	enable <module> <level>
where <level> not specified is 0.

> +int unregister_debug_module(char *mod_name)
> +{
> +	struct debug_name *element;
> +	struct debug_name *parent = NULL;
> +	int ret = 0;
> +	int i;
> +
> +	down(&debug_list_mutex);
> +	element = find_debug_module(mod_name);
> +	if (!element) {
> +		ret = -EINVAL;
> +		goto out;
> +	}

[]

> +out:
> +	up(&debug_list_mutex);
> +	return 0;
> +}

Because the return values aren't used,
the functions might as well be declared void

You should probably add a sprinkling of "const"
to the argument lists.

+extern void dynamic_printk(char *, char *, ...);

+	dynamic_printk(KBUILD_MODNAME,                     \
+			KERN_DEBUG KBUILD_MODNAME ": " fmt,\

Instead of prefixing every fmt with KBUILD_MODNAME ": ",
why not change this to something like:

extern void dynamic_printk(const char *level, const char *module,
			   const char *fmt, ...);

and just do the printk in 2 parts?

	if (module_enabled) {
		printk("%s%s: ", level, module);
		vprintk(fmt, args);
	}

If not that, why should dynamic_printk prefix a KBUILD_MODNAME
at all?  Why not just check if the module is enabled, then
output what the code specifies?

trivial:  The dynamic versions of the dev_dbg and pr_debug macros
don't return the number of chars output, but always return 0.



  reply	other threads:[~2008-06-13 22:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-13 19:00 [PATCH 2/8] dynamic debug - core infrastructure Jason Baron
2008-06-13 22:30 ` Joe Perches [this message]
2008-06-16 19:15   ` Jason Baron
2008-06-18 16:08 ` Greg KH
2008-06-20 15:38   ` Jason Baron
2008-06-21  8:17     ` Greg KH
2008-06-18 20:52 ` Pavel Machek

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=1213396218.5463.48.camel@localhost \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=greg@kroah.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick@nick-andrew.net \
    --cc=randy.dunlap@oracle.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