summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-04-06 20:19:56 +0200
committerKay Sievers <kay@vrfy.org>2012-04-06 20:21:29 +0200
commitd4fcf66bc72e532e4dba02f7c62bc5da31d85601 (patch)
tree87d37e200659795cf71f987f02cd26d4a3351113
parentf260f8f17e9dcd610b119c725846c838943e197a (diff)
downloadpatches-d4fcf66bc72e532e4dba02f7c62bc5da31d85601.tar.gz
split dev_printk and /dev/kmsg patch
-rw-r--r--printk-dev_printk.patch78
-rw-r--r--printk-devkmsg.patch77
-rw-r--r--printk-records.patch63
-rw-r--r--series1
4 files changed, 81 insertions, 138 deletions
diff --git a/printk-dev_printk.patch b/printk-dev_printk.patch
new file mode 100644
index 0000000..155097d
--- /dev/null
+++ b/printk-dev_printk.patch
@@ -0,0 +1,78 @@
+---
+ drivers/base/core.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 49 insertions(+), 3 deletions(-)
+
+--- a/drivers/base/core.c
++++ b/drivers/base/core.c
+@@ -25,6 +25,7 @@
+ #include <linux/mutex.h>
+ #include <linux/async.h>
+ #include <linux/pm_runtime.h>
++#include <linux/netdevice.h>
+
+ #include "base.h"
+ #include "power/power.h"
+@@ -1843,15 +1844,60 @@ void device_shutdown(void)
+ */
+
+ #ifdef CONFIG_PRINTK
+-
+ int __dev_printk(const char *level, const struct device *dev,
+ struct va_format *vaf)
+ {
++ char dict[128];
++ size_t dictlen = 0;
++ const char *subsys;
++
+ if (!dev)
+ return printk("%s(NULL device *): %pV", level, vaf);
+
+- return printk("%s%s %s: %pV",
+- level, dev_driver_string(dev), dev_name(dev), vaf);
++ if (dev->class)
++ subsys = dev->class->name;
++ else if (dev->bus)
++ subsys = dev->bus->name;
++ else
++ subsys = "(NULL subsystem)";
++
++ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
++ "SUBSYSTEM=%s", subsys);
++
++ /*
++ * Add device identifier DEVICE=:
++ * b12:8 block dev_t
++ * c127:3 char dev_t
++ * n8 netdev ifindex
++ * +sound:card0 subsystem:devname
++ */
++ if (MAJOR(dev->devt)) {
++ char c;
++
++ if (strcmp(subsys, "block") == 0)
++ c = 'b';
++ else
++ c = 'c';
++ dictlen++;
++ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
++ "DEVICE=%c%u:%u",
++ c, MAJOR(dev->devt), MINOR(dev->devt));
++ } else if (strcmp(subsys, "net") == 0) {
++ struct net_device *net = to_net_dev(dev);
++
++ dictlen++;
++ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
++ "DEVICE=n%u", net->ifindex);
++ } else {
++ dictlen++;
++ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
++ "DEVICE=+%s:%s", subsys, dev_name(dev));
++ }
++
++ return printk_emit(0, level[1] - '0',
++ dict, dictlen,
++ "%s %s: %pV",
++ dev_driver_string(dev), dev_name(dev), vaf);
+ }
+ EXPORT_SYMBOL(__dev_printk);
+
diff --git a/printk-devkmsg.patch b/printk-devkmsg.patch
index a7fa795..3528585 100644
--- a/printk-devkmsg.patch
+++ b/printk-devkmsg.patch
@@ -1,84 +1,9 @@
---
- drivers/base/core.c | 52 +++++++-
drivers/char/mem.c | 61 ---------
include/linux/printk.h | 2
kernel/printk.c | 313 +++++++++++++++++++++++++++++++++++++++++++++++++
- 4 files changed, 365 insertions(+), 63 deletions(-)
+ 3 files changed, 316 insertions(+), 60 deletions(-)
---- a/drivers/base/core.c
-+++ b/drivers/base/core.c
-@@ -25,6 +25,7 @@
- #include <linux/mutex.h>
- #include <linux/async.h>
- #include <linux/pm_runtime.h>
-+#include <linux/netdevice.h>
-
- #include "base.h"
- #include "power/power.h"
-@@ -1843,15 +1844,60 @@ void device_shutdown(void)
- */
-
- #ifdef CONFIG_PRINTK
--
- int __dev_printk(const char *level, const struct device *dev,
- struct va_format *vaf)
- {
-+ char dict[128];
-+ size_t dictlen = 0;
-+ const char *subsys;
-+
- if (!dev)
- return printk("%s(NULL device *): %pV", level, vaf);
-
-- return printk("%s%s %s: %pV",
-- level, dev_driver_string(dev), dev_name(dev), vaf);
-+ if (dev->class)
-+ subsys = dev->class->name;
-+ else if (dev->bus)
-+ subsys = dev->bus->name;
-+ else
-+ subsys = "(NULL subsystem)";
-+
-+ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
-+ "SUBSYSTEM=%s", subsys);
-+
-+ /*
-+ * Add device identifier DEVICE=:
-+ * b12:8 block dev_t
-+ * c127:3 char dev_t
-+ * n8 netdev ifindex
-+ * +sound:card0 subsystem:devname
-+ */
-+ if (MAJOR(dev->devt)) {
-+ char c;
-+
-+ if (strcmp(subsys, "block") == 0)
-+ c = 'b';
-+ else
-+ c = 'c';
-+ dictlen++;
-+ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
-+ "DEVICE=%c%u:%u",
-+ c, MAJOR(dev->devt), MINOR(dev->devt));
-+ } else if (strcmp(subsys, "net") == 0) {
-+ struct net_device *net = to_net_dev(dev);
-+
-+ dictlen++;
-+ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
-+ "DEVICE=n%u", net->ifindex);
-+ } else {
-+ dictlen++;
-+ dictlen += snprintf(dict + dictlen, sizeof(dict) - dictlen,
-+ "DEVICE=+%s:%s", subsys, dev_name(dev));
-+ }
-+
-+ return printk_emit(0, level[1] - '0',
-+ dict, dictlen,
-+ "%s %s: %pV",
-+ dev_driver_string(dev), dev_name(dev), vaf);
- }
- EXPORT_SYMBOL(__dev_printk);
-
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -807,65 +807,6 @@ static const struct file_operations oldm
diff --git a/printk-records.patch b/printk-records.patch
index 50c0f50..9caaf8e 100644
--- a/printk-records.patch
+++ b/printk-records.patch
@@ -1,29 +1,5 @@
From: Kay Sievers <kay@vrfy.org>
-Subject: printk: support structured and multi-facility log messages
-
-Kernel log messages are the primary source of information about the overall
-state of the system and connected devices. Traditional kernel messages are
-mostly human language, targeted at a human reading them. This part of the
-picture works very well since a very long time.
-
-However, most machines run unattended almost all of their time, and
-software, and not humans, need to process the kernel messages. Having
-a machine making sense out of human language messages is inefficient,
-unreliable, and sometimes plain impossible to get right. With human
-language messages all useful information about their context,
-available at the time of creation of the messages, is just thrown
-away. Later, software consumers of the messages will need to apply
-magic to reconstruct what the context might have been, to be able to
-interpret the messages.
-
-This patch extends printk() to be able to attach arbitrary key/value
-pairs to logged messages, to carry machine-readable data which
-describes the context of the log message at time of its
-creation. Users of the log can retrieve, along with the human-readable
-message, a key/value dictionary to reliably identify specific devices,
-drivers, subsystems, classes and types of messages.
-
-Various features of this patch:
+Subject: printk: convert byte-buffer to variable-length record buffer
- Record-based stream instead of the traditional byte stream
buffer. All records carry a 64 bit timestamp, the syslog facility
@@ -60,43 +36,6 @@ Various features of this patch:
proper ordering (and interleaving) and to allow the consumers of the
log to reliably correlate the events from different facilities.
-- Output of dev_printk() is reliably machine-readable now. In addition
- to the printed plain text message, it creates a log dictionary with the
- following properties:
- SUBSYSTEM= - the driver-core subsytem name
- DEVICE=
- b12:8 - block dev_t
- c127:3 - char dev_t
- n8 - netdev ifindex
- +sound:card0 - subsystem:devname
-
-- Support for multiple concurrent readers of /dev/kmsg, with read(),
- seek(), poll() support. Output of message sequence numbers, to allow
- userspace log consumers to reliably reconnect and reconstruct their
- state at any given time. After open("/dev/kmsg"), read() always
- returns *all* buffered records. If only future messages should be
- read, SEEK_END can be used. In case records get overwritten while
- /dev/kmsg is held open, or records get faster overwritten than they
- are read, the next read() will return -EPIPE and the current reading
- position gets updated to the next available record. The passed
- sequence numbers allow the log consumer to calculate the amount of
- lost messages.
-
- [root@mop ~]# cat /dev/kmsg
- 5,0,0;Linux version 3.4.0-rc1+ (kay@mop) (gcc version 4.7.0 20120315 ...
- 6,159,423091;ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
- 7,160,424069;pci_root PNP0A03:00: host bridge window [io 0x0000-0x0cf7] (ignored)
- SUBSYSTEM=acpi
- DEVICE=+acpi:PNP0A03:00
- 6,339,5140900;NET: Registered protocol family 10
- 30,340,5690716;udevd[80]: starting version 181
- 6,341,6081421;FDC 0 is a S82078B
- 6,345,6154686;microcode: CPU0 sig=0x623, pf=0x0, revision=0x0
- 7,346,6156968;sr 1:0:0:0: Attached scsi CD-ROM sr0
- SUBSYSTEM=scsi
- DEVICE=+scsi:1:0:0:0
- 6,347,6289375;microcode: CPU1 sig=0x623, pf=0x0, revision=0x0
-
Tested-by: William Douglas <william.douglas@intel.com>
Signed-off-by: Kay Sievers <kay@vrfy.org>
---
diff --git a/series b/series
index 1bf71d3..b235040 100644
--- a/series
+++ b/series
@@ -1,3 +1,4 @@
printk-records.patch
printk-devkmsg.patch
+printk-dev_printk.patch
kern-cont.patch