From: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
To: linux-kernel@vger.kernel.org
Cc: yrl.pp-manager.tt@hitachi.com, akpm@linux-foundation.org,
gregkh@linuxfoundation.org, kay@vrfy.org, davem@davemloft.net,
Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kay Sievers <kay@vrfy.org>,
"David S. Miller" <davem@davemloft.net>
Subject: [RFC PATCH 1/5] printk: make printk a macro
Date: Wed, 03 Jul 2013 10:46:16 +0900 [thread overview]
Message-ID: <20130703014616.18745.16576.stgit@localhost.localdomain> (raw)
In-Reply-To: <20130703014616.18745.34699.stgit@localhost.localdomain>
To allow building up metadata transparently for each printk(), make
printk() a macro while keeping printk()'s API. Then, printk() calls
_printk() which implements the original printk() function.
printk() is used from assembly sources, but they don't include printk.h
and don't use this new printk() macro. This is addressed by assigning
the printk symbol to _printk in the linker script.
Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kay Sievers <kay@vrfy.org>
Cc: "David S. Miller" <davem@davemloft.net>
---
include/asm-generic/vmlinux.lds.h | 1 +
include/linux/printk.h | 4 +++-
kernel/printk.c | 12 ++++++++----
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index eb58d2d..0380add 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -416,6 +416,7 @@
*(.text.hot) \
*(.text) \
*(.ref.text) \
+ VMLINUX_SYMBOL(printk) = VMLINUX_SYMBOL(_printk); \
DEV_KEEP(init.text) \
DEV_KEEP(exit.text) \
CPU_KEEP(init.text) \
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 22c7052..c7a8c6b 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -121,7 +121,9 @@ asmlinkage int printk_emit(int facility, int level,
const char *fmt, ...);
asmlinkage __printf(1, 2) __cold
-int printk(const char *fmt, ...);
+int _printk(const char *fmt, ...);
+
+#define printk(fmt, args...) _printk(fmt, ## args)
/*
* Special printk facility for scheduler use only, _DO_NOT_USE_ !
diff --git a/kernel/printk.c b/kernel/printk.c
index 8212c1a..1ec264e 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1658,10 +1658,14 @@ asmlinkage int printk_emit(int facility, int level,
EXPORT_SYMBOL(printk_emit);
/**
- * printk - print a kernel message
+ * _printk - print a kernel message
* @fmt: format string
*
- * This is printk(). It can be called from any context. We want it to work.
+ * Now, printk() is a macro defined in include/linux/printk.h, and this
+ * function is its body. It can be called from any context, but please
+ * use printk() macro. Directly calling _printk() is not recommended.
+ * In assembly sources, you can call printk as in the past because the
+ * linker program links the printk symbol in assembly sources to _printk.
*
* We try to grab the console_lock. If we succeed, it's easy - we log the
* output and call the console drivers. If we fail to get the semaphore, we
@@ -1678,7 +1682,7 @@ EXPORT_SYMBOL(printk_emit);
*
* See the vsnprintf() documentation for format string extensions over C99.
*/
-asmlinkage int printk(const char *fmt, ...)
+asmlinkage int _printk(const char *fmt, ...)
{
va_list args;
int r;
@@ -1697,7 +1701,7 @@ asmlinkage int printk(const char *fmt, ...)
return r;
}
-EXPORT_SYMBOL(printk);
+EXPORT_SYMBOL(_printk);
#else /* CONFIG_PRINTK */
next prev parent reply other threads:[~2013-07-03 2:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 1:46 [RFC PATCH 0/5] Add a hash value for each line in /dev/kmsg Hidehiro Kawai
2013-07-03 1:46 ` Hidehiro Kawai [this message]
2013-07-03 1:46 ` [RFC PATCH 2/5] printk: add message hash values in /dev/kmsg output Hidehiro Kawai
2013-07-03 1:46 ` [RFC PATCH 5/5] printk: Add msghash support for dev_printk Hidehiro Kawai
2013-07-03 1:46 ` [RFC PATCH 4/5] msghash: Add userland msghash tool Hidehiro Kawai
2013-07-03 1:46 ` [RFC PATCH 3/5] tools/include: Add jhash.h Hidehiro Kawai
2013-07-26 12:43 ` [RFC PATCH 0/5] Add a hash value for each line in /dev/kmsg Kay Sievers
2013-07-29 11:54 ` Hidehiro Kawai
2013-07-29 12:46 ` Kay Sievers
2013-07-30 6:43 ` Hidehiro Kawai
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=20130703014616.18745.16576.stgit@localhost.localdomain \
--to=hidehiro.kawai.ez@hitachi.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yrl.pp-manager.tt@hitachi.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