From: Jason Baron <jbaron@redhat.com>
To: mathieu.desnoyers@polymtl.ca
Cc: akpm@linux-foundation.org, mingo@elte.hu, fche@redhat.com,
linux-kernel@vger.kernel.org
Subject: [patch 1/4] make pr_debug() dynamic
Date: Thu, 7 Feb 2008 16:09:33 -0500 [thread overview]
Message-ID: <20080207210929.GC14732@redhat.com> (raw)
-make pr_debug() dynamic so it can be switched on/off. The off state
is implemented on top of the immediate infrastructure, so as to promote
more dynamic printing and debugging. depends on CONFIG_HAVE_IMMEDIATE
and CONFIG_PRINTK
Signed-off-by: Jason Baron <jbaron@redhat.com>
---
include/linux/kernel.h | 10 ++++++++++
init/Kconfig | 5 +++++
kernel/printk.c | 17 +++++++++++++++++
3 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index ff356b2..d69430a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -14,6 +14,7 @@
#include <linux/compiler.h>
#include <linux/bitops.h>
#include <linux/log2.h>
+#include <linux/immediate.h>
#include <asm/byteorder.h>
#include <asm/bug.h>
@@ -276,6 +277,14 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#define pr_info(fmt, arg...) \
printk(KERN_INFO fmt, ##arg)
+#ifdef CONFIG_PR_DEBUG_DYNAMIC
+DECLARE_IMV(char, pr_debug_on);
+#define pr_debug(fmt, ...) \
+ do { \
+ if (unlikely(imv_read(pr_debug_on))) \
+ printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
+ } while (0)
+#else
#ifdef DEBUG
/* If you are writing a driver, please use dev_dbg instead */
#define pr_debug(fmt, arg...) \
@@ -286,6 +295,7 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
return 0;
}
#endif
+#endif
/*
* Display an IP address in readable format.
diff --git a/init/Kconfig b/init/Kconfig
index 3918c2d..0bed605 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -539,6 +539,11 @@ config PRINTK
very difficult to diagnose system problems, saying N here is
strongly discouraged.
+config PR_DEBUG_DYNAMIC
+ bool
+ depends on PRINTK && HAVE_IMMEDIATE
+ default y
+
config BUG
bool "BUG() support" if EMBEDDED
default y
diff --git a/kernel/printk.c b/kernel/printk.c
index 29ae1e9..1bc4fdb 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -33,6 +33,7 @@
#include <linux/bootmem.h>
#include <linux/syscalls.h>
#include <linux/jiffies.h>
+#include <linux/immediate.h>
#include <asm/uaccess.h>
@@ -1334,3 +1335,19 @@ bool printk_timed_ratelimit(unsigned long *caller_jiffies,
return false;
}
EXPORT_SYMBOL(printk_timed_ratelimit);
+
+#ifdef CONFIG_PR_DEBUG_DYNAMIC
+
+DEFINE_IMV(char, pr_debug_on) = 0;
+EXPORT_IMV_SYMBOL_GPL(pr_debug_on);
+
+static int __init pr_debug_setup(char *str)
+{
+ if (str)
+ return -ENOENT;
+ imv_set(pr_debug_on, 1);
+ return 0;
+}
+early_param("pr_debug", pr_debug_setup);
+
+#endif
reply other threads:[~2008-02-07 21:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080207210929.GC14732@redhat.com \
--to=jbaron@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=fche@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
/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.