All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit()
@ 2013-08-16 17:18 Tim Gardner
  2013-08-16 17:19 ` [PATCH 3.11-rc5 2/2] ALSA: pcm: Use snd_printd_ratelimit() Tim Gardner
  2013-08-19 13:49 ` [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit() Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Tim Gardner @ 2013-08-16 17:18 UTC (permalink / raw)
  To: alsa-devel, linux-kernel
  Cc: Tim Gardner, Jaroslav Kysela, Takashi Iwai, Pierre-Louis Bossart,
	Lars-Peter Clausen, Yacine Belkadi

Direct calls to printk_limit() will emit log noise even when CONFIG_SND_DEBUG is not
defined. Add a wrapper macro around printk_limit() that is conditionally defined by
CONFIG_SND_DEBUG.

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Yacine Belkadi <yacine.belkadi.1@gmail.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---

checkpatch is moaning about the use of printk_ratelimit(), but
printk_ratelimited() seems like overkill for a debug feature.

WARNING: Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit
#38: FILE: include/sound/core.h:382:
+#define snd_printd_ratelimit() printk_ratelimit()

 include/sound/core.h |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/sound/core.h b/include/sound/core.h
index c586617..2a14f1f 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -27,6 +27,7 @@
 #include <linux/rwsem.h>		/* struct rw_semaphore */
 #include <linux/pm.h>			/* pm_message_t */
 #include <linux/stringify.h>
+#include <linux/printk.h>
 
 /* number of supported soundcards */
 #ifdef CONFIG_SND_DYNAMIC_MINORS
@@ -376,6 +377,11 @@ void __snd_printk(unsigned int level, const char *file, int line,
 #define snd_BUG()		WARN(1, "BUG?\n")
 
 /**
+ * Suppress high rates of output when CONFIG_SND_DEBUG is enabled.
+ */
+#define snd_printd_ratelimit() printk_ratelimit()
+
+/**
  * snd_BUG_ON - debugging check macro
  * @cond: condition to evaluate
  *
@@ -398,6 +404,8 @@ static inline void _snd_printd(int level, const char *format, ...) {}
 	unlikely(__ret_warn_on); \
 })
 
+static inline bool snd_printd_ratelimit(void) { return false; }
+
 #endif /* CONFIG_SND_DEBUG */
 
 #ifdef CONFIG_SND_DEBUG_VERBOSE
-- 
1.7.9.5


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

* [PATCH 3.11-rc5 2/2] ALSA: pcm: Use snd_printd_ratelimit()
  2013-08-16 17:18 [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit() Tim Gardner
@ 2013-08-16 17:19 ` Tim Gardner
  2013-08-19 13:49 ` [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit() Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Tim Gardner @ 2013-08-16 17:19 UTC (permalink / raw)
  To: alsa-devel, linux-kernel
  Cc: Tim Gardner, Jaroslav Kysela, Takashi Iwai, Pierre-Louis Bossart,
	Lars-Peter Clausen, Yacine Belkadi

The use of snd_printd_ratelimit() supresses superfluous output from
printk_ratelimit() when CONFIG_SND_DEBUG is not defined. For example,

[   43.753692] snd_pcm_update_hw_ptr0: 26 callbacks suppressed
[   48.822131] snd_pcm_update_hw_ptr0: 25 callbacks suppressed
[   53.894953] snd_pcm_update_hw_ptr0: 25 callbacks suppressed
[   58.997761] snd_pcm_update_hw_ptr0: 25 callbacks suppressed
[   64.100952] snd_pcm_update_hw_ptr0: 25 callbacks suppressed

fills the log even when no debug output is actually produced.

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Yacine Belkadi <yacine.belkadi.1@gmail.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 sound/core/pcm_lib.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 82bb029..6e03b46 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -184,7 +184,7 @@ static void xrun(struct snd_pcm_substream *substream)
 	do {								\
 		if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {		\
 			xrun_log_show(substream);			\
-			if (printk_ratelimit()) {			\
+			if (snd_printd_ratelimit()) {			\
 				snd_printd("PCM: " fmt, ##args);	\
 			}						\
 			dump_stack_on_xrun(substream);			\
@@ -342,7 +342,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 		return -EPIPE;
 	}
 	if (pos >= runtime->buffer_size) {
-		if (printk_ratelimit()) {
+		if (snd_printd_ratelimit()) {
 			char name[16];
 			snd_pcm_debug_name(substream, name, sizeof(name));
 			xrun_log_show(substream);
-- 
1.7.9.5


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

* Re: [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit()
  2013-08-16 17:18 [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit() Tim Gardner
  2013-08-16 17:19 ` [PATCH 3.11-rc5 2/2] ALSA: pcm: Use snd_printd_ratelimit() Tim Gardner
@ 2013-08-19 13:49 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2013-08-19 13:49 UTC (permalink / raw)
  To: Tim Gardner
  Cc: alsa-devel, linux-kernel, Jaroslav Kysela, Pierre-Louis Bossart,
	Lars-Peter Clausen, Yacine Belkadi

At Fri, 16 Aug 2013 11:18:59 -0600,
Tim Gardner wrote:
> 
> Direct calls to printk_limit() will emit log noise even when CONFIG_SND_DEBUG is not
> defined. Add a wrapper macro around printk_limit() that is conditionally defined by
> CONFIG_SND_DEBUG.
> 
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.de>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Yacine Belkadi <yacine.belkadi.1@gmail.com>
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
> 
> checkpatch is moaning about the use of printk_ratelimit(), but
> printk_ratelimited() seems like overkill for a debug feature.
> 
> WARNING: Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit
> #38: FILE: include/sound/core.h:382:
> +#define snd_printd_ratelimit() printk_ratelimit()

Thanks, applied both patches now.
But it's no real bug, so I postpone this for 3.12 inclusion.


Takashi


> 
>  include/sound/core.h |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/sound/core.h b/include/sound/core.h
> index c586617..2a14f1f 100644
> --- a/include/sound/core.h
> +++ b/include/sound/core.h
> @@ -27,6 +27,7 @@
>  #include <linux/rwsem.h>		/* struct rw_semaphore */
>  #include <linux/pm.h>			/* pm_message_t */
>  #include <linux/stringify.h>
> +#include <linux/printk.h>
>  
>  /* number of supported soundcards */
>  #ifdef CONFIG_SND_DYNAMIC_MINORS
> @@ -376,6 +377,11 @@ void __snd_printk(unsigned int level, const char *file, int line,
>  #define snd_BUG()		WARN(1, "BUG?\n")
>  
>  /**
> + * Suppress high rates of output when CONFIG_SND_DEBUG is enabled.
> + */
> +#define snd_printd_ratelimit() printk_ratelimit()
> +
> +/**
>   * snd_BUG_ON - debugging check macro
>   * @cond: condition to evaluate
>   *
> @@ -398,6 +404,8 @@ static inline void _snd_printd(int level, const char *format, ...) {}
>  	unlikely(__ret_warn_on); \
>  })
>  
> +static inline bool snd_printd_ratelimit(void) { return false; }
> +
>  #endif /* CONFIG_SND_DEBUG */
>  
>  #ifdef CONFIG_SND_DEBUG_VERBOSE
> -- 
> 1.7.9.5
> 

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

end of thread, other threads:[~2013-08-19 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-16 17:18 [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit() Tim Gardner
2013-08-16 17:19 ` [PATCH 3.11-rc5 2/2] ALSA: pcm: Use snd_printd_ratelimit() Tim Gardner
2013-08-19 13:49 ` [PATCH 3.11-rc5 1/2] ALSA: pcm: Add snd_printd_ratelimit() Takashi Iwai

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.