From: Vikram Pandita <vikram.pandita@ti.com>
To: <gregkh@linuxfoundation.org>, <kay@vrfy.org>
Cc: <linux-kernel@vger.kernel.org>,
Vikram Pandita <vikram.pandita@ti.com>,
Mike Turquette <mturquette@linaro.org>,
Vimarsh Zutshi <vimarsh.zutshi@gmail.com>
Subject: [PATCH] printk: add option to print cpu id
Date: Thu, 2 Aug 2012 12:46:04 -0700 [thread overview]
Message-ID: <1343936764-6461-1-git-send-email-vikram.pandita@ti.com> (raw)
From: Vikram Pandita <vikram.pandita@ti.com>
Introduce config option to enable CPU id reporting for printk() calls.
Its sometimes very useful to have printk also print the CPU Identifier
that executed the call. This has helped to debug various SMP issues on shipping
products.
Known limitation is, if the system gets preempted between function call and
actual printk, the reported cpu-id might not be accurate. But most of the
times its seen to give a good feel of how the N cpu's in the system are
getting loaded.
Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Vimarsh Zutshi <vimarsh.zutshi@gmail.com>
---
kernel/printk.c | 20 ++++++++++++++++++++
lib/Kconfig.debug | 13 +++++++++++++
2 files changed, 33 insertions(+)
diff --git a/kernel/printk.c b/kernel/printk.c
index 6a76ab9..50feb82 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -855,6 +855,25 @@ static size_t print_time(u64 ts, char *buf)
(unsigned long)ts, rem_nsec / 1000);
}
+#if defined(CONFIG_PRINTK_CPUID)
+static bool printk_cpuid = 1;
+#else
+static bool printk_cpuid;
+#endif
+module_param_named(cpuid, printk_cpuid, bool, S_IRUGO | S_IWUSR);
+
+static size_t print_cpuid(char *buf)
+{
+
+ if (!printk_cpuid)
+ return 0;
+
+ if (!buf)
+ return 4;
+
+ return sprintf(buf, "[%1d] ", smp_processor_id());
+}
+
static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
{
size_t len = 0;
@@ -874,6 +893,7 @@ static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
}
}
+ len += print_cpuid(buf ? buf + len : NULL);
len += print_time(msg->ts_nsec, buf ? buf + len : NULL);
return len;
}
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2403a63..139b2b1 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -14,6 +14,19 @@ config PRINTK_TIME
The behavior is also controlled by the kernel command line
parameter printk.time=1. See Documentation/kernel-parameters.txt
+config PRINTK_CPUID
+ bool "Show cpu id information on printks"
+ depends on PRINTK
+ help
+ Selecting this option causes cpu identifier to be added to the
+ output of the syslog() system call and at the console.
+
+ This flag just specifies if the cpu-id should
+ be included.
+
+ The behavior is also controlled by the kernel command line
+ parameter printk.cpuid=1.
+
config DEFAULT_MESSAGE_LOGLEVEL
int "Default message log level (1-7)"
range 1 7
--
1.7.9.5
next reply other threads:[~2012-08-02 19:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-02 19:46 Vikram Pandita [this message]
2012-08-02 20:08 ` Kay Sievers
2012-08-02 23:50 ` Pandita, Vikram
2012-08-03 0:06 ` Kay Sievers
2012-08-03 2:19 ` Pandita, Vikram
2012-08-03 9:15 ` Pandita, Vikram
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=1343936764-6461-1-git-send-email-vikram.pandita@ti.com \
--to=vikram.pandita@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=vimarsh.zutshi@gmail.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
all inboxes | Powered by JetHome®