Skip to contentSkip to conversation

loglevel=pci:8,acpi:8,apic=8 support v6

PATCH In review Yinghai Lu 9 participants 32 messages Sep 17, 2008 – Sep 18, 2008

Subsystems (5)
Documentation x86 ACPI PCI +1 more subsystems
lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

cover loglevel=pci:8,acpi:8,apic=8 support v6

KERN_PCI
KERN_ACPI
v4: fix some checkpatch error and warning
v5: add default with DEFINE_LOGLEVE_SETUP_DEF
KERN_APIC
v6: set the default only one time

usage:

	in .h to have
		#define KERN_PCI "<pci>"
	in .c to have
		DEFINE_LOGLEVEL_SETUP(pci, KERN_PCI, "pci:");
	then could use
		printk(KERN_DEBUG KERN_PCI fmt, ...);
	and command line
		loglevel=3,pci:8

you can add different printk to different files of one subsys if you like not just one susbsys one tag, and don't need to update kernel.h to add more tags

YH

author
#1 lore raw

PATCH 1/6 add DEFINE_LOGLEVEL_SETUP v7

so could make subsys easy to add loglevel and xxx_printk
v2: make it more genric, so subsys user only need to two line macro
v3: add back nameStr, so could find out iommu: and iommu_gart: and etc
v4: use printk intead of pci_printk
v5: fix checkpatch error and warning
v6: add DEFINE_LOGLEVEL_SETUP_DEF to take default
v7: call tag_loglevel_setup only one time, so could take several loglevel like
loglevel=4 loglevel=acpi:8 loglevel=pci:8 loglevel=apic:8 is the same as loglevel=4,acpi:8,pci:8,apic:8

usage:
in .h to have
#define KERN_PCI "<pci>"
in .c to have
DEFINE_LOGLEVEL_SETUP(pci, KERN_PCI, "pci:");
then could use
printk(KERN_DEBUG KERN_PCI fmt, ...);
and command line
loglevel=pci:8

you can add different printk to different files of one subsys if you like

---
 arch/x86/kernel/vmlinux_32.lds.S  |    1 
 arch/x86/kernel/vmlinux_64.lds.S  |    2 
 include/asm-generic/vmlinux.lds.h |    8 +++
 include/linux/init.h              |   22 ++++++++++
 include/linux/kernel.h            |    9 ++++
 init/main.c                       |   77 +++++++++++++++++++++++++++++++++++++-
 kernel/printk.c                   |   28 +++++++++++--
 7 files changed, 142 insertions(+), 5 deletions(-)
arch/x86/kernel/vmlinux_32.lds.S +1 -0
Index: linux-2.6/arch/x86/kernel/vmlinux_32.lds.S
===================================================================
@@ -145,6 +145,7 @@ SECTIONS
 	*(.x86_cpu_dev.init)
 	__x86_cpu_dev_end = .;
   }
+  LOGLEVEL_SETUP_INIT(8)
   DYN_ARRAY_INIT(8)
   SECURITY_INIT
   . = ALIGN(4);
arch/x86/kernel/vmlinux_64.lds.S +2 -0
Index: linux-2.6/arch/x86/kernel/vmlinux_64.lds.S
===================================================================
@@ -174,6 +174,8 @@ SECTIONS
   }
   __x86_cpu_dev_end = .;
 
+  LOGLEVEL_SETUP_INIT(8)
+
   DYN_ARRAY_INIT(8)
 
   SECURITY_INIT
include/asm-generic/vmlinux.lds.h +8 -0
Index: linux-2.6/include/asm-generic/vmlinux.lds.h
===================================================================
@@ -222,6 +222,14 @@
  * All archs are supposed to use RO_DATA() */
 #define RODATA RO_DATA(4096)
 
+#define LOGLEVEL_SETUP_INIT(align)					\
+	. = ALIGN((align));						\
+	.loglevel_setup.init : AT(ADDR(.loglevel_setup.init) - LOAD_OFFSET) { \
+		VMLINUX_SYMBOL(__loglevel_setup_start) = .;		\
+		*(.loglevel_setup.init)					\
+		VMLINUX_SYMBOL(__loglevel_setup_end) = .;		\
+	}
+
 #define DYN_ARRAY_INIT(align)							\
 	. = ALIGN((align));						\
 	.dyn_array.init : AT(ADDR(.dyn_array.init) - LOAD_OFFSET) {	\
include/linux/init.h +22 -0
Index: linux-2.6/include/linux/init.h
===================================================================
@@ -251,6 +251,28 @@ struct obs_kernel_param {
 /* Relies on boot_command_line being set */
 void __init parse_early_param(void);
 
+struct loglevel_setup {
+	char *name;
+	char *tag;
+	int level;
+};
+
+extern struct loglevel_setup *__loglevel_setup_start[], *__loglevel_setup_end[];
+
+#define DEFINE_LOGLEVEL_SETUP_DEF(nameX, tagX, nameStr, levelX)		\
+	static struct loglevel_setup __loglevel_setup_##nameX __initdata = \
+	{							\
+		.tag = tagX,					\
+		.name = nameStr,				\
+		.level = levelX,				\
+	};							\
+	static struct loglevel_setup *__loglevel_setup_ptr_##nameX __used \
+	__attribute__((__section__(".loglevel_setup.init"))) =	\
+		&__loglevel_setup_##nameX
+
+#define DEFINE_LOGLEVEL_SETUP(nameX, tagX, nameStr)		\
+	DEFINE_LOGLEVEL_SETUP_DEF(nameX, tagX, nameStr, 0)		\
+
 struct dyn_array {
 	void **name;
 	unsigned long size;
include/linux/kernel.h +9 -0
Index: linux-2.6/include/linux/kernel.h
===================================================================
@@ -104,6 +104,15 @@ extern int console_printk[];
 #define minimum_console_loglevel (console_printk[2])
 #define default_console_loglevel (console_printk[3])
 
+struct tag_console_loglevel {
+	char tag[32];
+	char name[32];
+	int level;
+};
+
+extern struct tag_console_loglevel tag_level[];
+extern int tag_level_nr;
+
 struct completion;
 struct pt_regs;
 struct user;
init/main.c +72 -1

87 lines not on this page · raw message

kernel/printk.c +24 -4
Index: linux-2.6/kernel/printk.c
===================================================================
@@ -457,9 +457,9 @@ early_param("ignore_loglevel", ignore_lo
  * Write out chars from start to end - 1 inclusive
  */
 static void _call_console_drivers(unsigned start,
-				unsigned end, int msg_log_level)
+				unsigned end, int msg_log_level, int level)
 {
-	if ((msg_log_level < console_loglevel || ignore_loglevel) &&
+	if ((msg_log_level < level || ignore_loglevel) &&
 			console_drivers && start != end) {
 		if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
 			/* wrapped write */
@@ -481,21 +481,40 @@ static void call_console_drivers(unsigne
 {
 	unsigned cur_index, start_print;
 	static int msg_level = -1;
+	int level = console_loglevel;
 
 	BUG_ON(((int)(start - end)) > 0);
 
 	cur_index = start;
 	start_print = start;
 	while (cur_index != end) {
+		int i;
+
 		if (msg_level < 0 && ((end - cur_index) > 2) &&
 				LOG_BUF(cur_index + 0) == '<' &&
 				LOG_BUF(cur_index + 1) >= '0' &&
 				LOG_BUF(cur_index + 1) <= '7' &&
 				LOG_BUF(cur_index + 2) == '>') {
 			msg_level = LOG_BUF(cur_index + 1) - '0';
+			level = console_loglevel;
 			cur_index += 3;
 			start_print = cur_index;
 		}
+		/* handle tag here */
+		for (i = 0; i < tag_level_nr; i++) {
+			struct tag_console_loglevel *tl;
+			int len;
+
+			tl = &tag_level[i];
+			len = strlen(tl->tag);
+			if ((end - cur_index) > (len - 1) &&
+			    !strncmp(&LOG_BUF(cur_index), tl->tag, len)) {
+				level = tl->level;
+				cur_index += len;
+				start_print = cur_index;
+				break;
+			}
+		}
 		while (cur_index != end) {
 			char c = LOG_BUF(cur_index);
 
@@ -510,14 +529,15 @@ static void call_console_drivers(unsigne
 					 */
 					msg_level = default_message_loglevel;
 				}
-				_call_console_drivers(start_print, cur_index, msg_level);
+				_call_console_drivers(start_print, cur_index,
+							msg_level, level);
 				msg_level = -1;
 				start_print = cur_index;
 				break;
 			}
 		}
 	}
-	_call_console_drivers(start_print, end, msg_level);
+	_call_console_drivers(start_print, end, msg_level, level);
 }
 
 static void emit_log_char(char c)
author
#2 lore raw

PATCH 2/6 pci: add KERN_PCI

In reply to Yinghai Lu

use DEFINE_LOGLEVEL_SETUP to set loglevel for pci

---
 drivers/pci/pci.c   |    2 ++
 include/linux/pci.h |    2 ++
 2 files changed, 4 insertions(+)
drivers/pci/pci.c +2 -0
Index: linux-2.6/drivers/pci/pci.c
===================================================================
@@ -1953,6 +1953,8 @@ static int __devinit pci_setup(char *str
 }
 early_param("pci", pci_setup);
 
+DEFINE_LOGLEVEL_SETUP(pci, KERN_PCI, "pci:");
+
 device_initcall_sync(pci_init);
 
 EXPORT_SYMBOL(pci_reenable_device);
include/linux/pci.h +2 -0
Index: linux-2.6/include/linux/pci.h
===================================================================
@@ -55,6 +55,8 @@
 /* Include the ID list */
 #include <linux/pci_ids.h>
 
+#define KERN_PCI "<pci>"
+
 /* pci_slot represents a physical slot */
 struct pci_slot {
 	struct pci_bus *bus;		/* The bus this slot is on */
author
#3 lore raw

PATCH 3/6 pci: using printk(KERN_PCI v3

In reply to Yinghai Lu

v2: use printk(KERN_DEBUG KERN_PCI ...
v3: fix checkpatch error and warning

---
 drivers/pci/probe.c |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/pci/probe.c +17 -11
Index: linux-2.6/drivers/pci/probe.c
===================================================================
@@ -304,7 +304,8 @@ static int __pci_read_base(struct pci_de
 		} else {
 			res->start = l64;
 			res->end = l64 + sz64;
-			printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
+			printk(KERN_DEBUG KERN_PCI
+				 "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
 				 pci_name(dev), pos, res->start, res->end);
 		}
 	} else {
@@ -315,9 +316,10 @@ static int __pci_read_base(struct pci_de
 
 		res->start = l;
 		res->end = l + sz;
-		printk(KERN_DEBUG "PCI: %s reg %x %s: [%llx, %llx]\n", pci_name(dev),
-			 pos, (res->flags & IORESOURCE_IO) ? "io port":"32bit mmio",
-			 res->start, res->end);
+		printk(KERN_DEBUG KERN_PCI "PCI: %s reg %x %s: [%llx, %llx]\n",
+			pci_name(dev), pos,
+			(res->flags & IORESOURCE_IO) ? "io port" : "32bit mmio",
+			res->start, res->end);
 	}
 
  out:
@@ -388,8 +390,9 @@ void __devinit pci_read_bridge_bases(str
 			res->start = base;
 		if (!res->end)
 			res->end = limit + 0xfff;
-		printk(KERN_DEBUG "PCI: bridge %s io port: [%llx, %llx]\n",
-				 pci_name(dev), res->start, res->end);
+		printk(KERN_DEBUG KERN_PCI
+			 "PCI: bridge %s io port: [%llx, %llx]\n",
+			 pci_name(dev), res->start, res->end);
 	}
 
 	res = child->resource[1];
@@ -401,8 +404,9 @@ void __devinit pci_read_bridge_bases(str
 		res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM;
 		res->start = base;
 		res->end = limit + 0xfffff;
-		printk(KERN_DEBUG "PCI: bridge %s 32bit mmio: [%llx, %llx]\n",
-				 pci_name(dev), res->start, res->end);
+		printk(KERN_DEBUG KERN_PCI
+			 "PCI: bridge %s 32bit mmio: [%llx, %llx]\n",
+			 pci_name(dev), res->start, res->end);
 	}
 
 	res = child->resource[2];
@@ -438,9 +442,11 @@ void __devinit pci_read_bridge_bases(str
 		res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH;
 		res->start = base;
 		res->end = limit + 0xfffff;
-		printk(KERN_DEBUG "PCI: bridge %s %sbit mmio pref: [%llx, %llx]\n",
-				 pci_name(dev), (res->flags & PCI_PREF_RANGE_TYPE_64)?"64":"32",
-				 res->start, res->end);
+		printk(KERN_DEBUG KERN_PCI
+			 "PCI: bridge %s %sbit mmio pref: [%llx, %llx]\n",
+			 pci_name(dev),
+			 (res->flags & PCI_PREF_RANGE_TYPE_64) ? "64" : "32",
+			 res->start, res->end);
 	}
 }
 
#4 lore raw

Re: [PATCH 3/6] pci: using printk(KERN_PCI v3

drivers/pci/probe.c static int __pci_read_base(struct pci_de · line 308

Quoted 3 lines · Yinghai Lu
drivers/pci/probe.c +2 -1
-			printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
+			printk(KERN_DEBUG KERN_PCI
+				 "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",

i think we should aim to make the common usage of this facility as easy and short as possible. That means that i think the right line is:

+ printk(KERN_PCI
+ "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",

as that is the shortest form. KERN_PCI should imply whatever common-sense default. It should still make sense to specify KERN_FOO KERN_PCI, to override that default.

Ingo

author
#5 lore raw

Re: [PATCH 3/6] pci: using printk(KERN_PCI v3

Quoted 13 lines · Ingo Molnar

drivers/pci/probe.c static int __pci_read_base(struct pci_de · line 308

Quoted 3 lines · Yinghai Lu
drivers/pci/probe.c +2 -1
-                     printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
+                     printk(KERN_DEBUG KERN_PCI
+                              "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",

i think we should aim to make the common usage of this facility as easy and short as possible. That means that i think the right line is:

(quoted diff) +2 -0
+                       printk(KERN_PCI
+                                "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
Quoted 3 lines

as that is the shortest form. KERN_PCI should imply whatever common-sense default. It should still make sense to specify KERN_FOO KERN_PCI, to override that default.

vprintk will add default before that like
like print(KERN_INFO KERN_PCI ....)

YH

#6 lore raw

Re: [PATCH 3/6] pci: using printk(KERN_PCI v3

Quoted 14 lines · Yinghai Lu
Quoted 13 lines · Ingo Molnar

drivers/pci/probe.c static int __pci_read_base(struct pci_de · line 308

Quoted 3 lines · Yinghai Lu
drivers/pci/probe.c +2 -1
-                     printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
+                     printk(KERN_DEBUG KERN_PCI
+                              "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",

i think we should aim to make the common usage of this facility as easy and short as possible. That means that i think the right line is:

(quoted diff) +2 -0
+                       printk(KERN_PCI
+                                "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
Quoted 6 lines
Quoted 3 lines

as that is the shortest form. KERN_PCI should imply whatever common-sense default. It should still make sense to specify KERN_FOO KERN_PCI, to override that default.

vprintk will add default before that like
like print(KERN_INFO KERN_PCI ....)

What about a pci_dbg() macro similiar to dev_dbg()? Same could be used for ACPI, acpi_dbg().

-Robert

Quoted 8 lines

YH
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 3 lines
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]
author
#7 lore raw

Re: [PATCH 3/6] pci: using printk(KERN_PCI v3

Quoted 19 lines · Robert Richter
Quoted 18 lines · Yinghai Lu
Quoted 16 lines · Ingo Molnar

drivers/pci/probe.c static int __pci_read_base(struct pci_de · line 308

Quoted 3 lines · Yinghai Lu
drivers/pci/probe.c +2 -1
-                     printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
+                     printk(KERN_DEBUG KERN_PCI
+                              "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",

i think we should aim to make the common usage of this facility as easy and short as possible. That means that i think the right line is:

(quoted diff) +2 -0
+                       printk(KERN_PCI
+                                "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",

as that is the shortest form. KERN_PCI should imply whatever common-sense default. It should still make sense to specify KERN_FOO KERN_PCI, to override that default.

Quoted 6 lines
Quoted 2 lines

vprintk will add default before that like
like print(KERN_INFO KERN_PCI ....)

What about a pci_dbg() macro similiar to dev_dbg()? Same could be used for ACPI, acpi_dbg().

according to different users ...

YH

#8 lore raw

Re: [PATCH 3/6] pci: using printk(KERN_PCI v3

In reply to Yinghai Lu
Quoted 14 lines · Yinghai Lu

v2: use printk(KERN_DEBUG KERN_PCI ...
v3: fix checkpatch error and warning

---
 drivers/pci/probe.c |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

Index: linux-2.6/drivers/pci/probe.c
===================================================================

drivers/pci/probe.c static int __pci_read_base(struct pci_de · line 309

Quoted 7 lines
drivers/pci/probe.c +2 -1
@@ -304,7 +304,8 @@ static int __pci_read_base(struct pci_de
 		} else {
 			res->start = l64;
 			res->end = l64 + sz64;
-			printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
+			printk(KERN_DEBUG KERN_PCI
+				 "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
 				 pci_name(dev), pos, res->start, res->end);

I really don't understand the point of this series. I think the user experience is too confusing.

But if you're going to change printks like the one above, please at least make it use dev_printk() like most of the rest of the PCI core.

author
#9 lore raw

Re: [PATCH 3/6] pci: using printk(KERN_PCI v3

Quoted 26 lines · Bjorn Helgaas
Quoted 14 lines · Yinghai Lu

v2: use printk(KERN_DEBUG KERN_PCI ...
v3: fix checkpatch error and warning

---
 drivers/pci/probe.c |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

Index: linux-2.6/drivers/pci/probe.c
===================================================================

drivers/pci/probe.c static int __pci_read_base(struct pci_de · line 309

Quoted 7 lines
drivers/pci/probe.c +2 -1
@@ -304,7 +304,8 @@ static int __pci_read_base(struct pci_de
              } else {
                      res->start = l64;
                      res->end = l64 + sz64;
-                     printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
+                     printk(KERN_DEBUG KERN_PCI
+                              "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n",
                               pci_name(dev), pos, res->start, res->end);

I really don't understand the point of this series. I think the user experience is too confusing.

Quoted 3 lines

But if you're going to change printks like the one above, please at least make it use dev_printk() like most of the rest of the PCI core.

will look at dev_printk...

YH

author
#10 lore raw

PATCH 4/6 acpi: add KERN_ACPI v3

In reply to Yinghai Lu

use DEFINE_LOGLEVEL_SETUP to set loglevel for acpi
v2: use <acpi, "acpi:"> instead
v3: use KERN_ACPI

---
 drivers/acpi/osl.c   |    2 ++
 include/linux/acpi.h |    1 +
 2 files changed, 3 insertions(+)
drivers/acpi/osl.c +2 -0
Index: linux-2.6/drivers/acpi/osl.c
===================================================================
@@ -75,6 +75,8 @@ EXPORT_SYMBOL(acpi_in_debugger);
 extern char line_buf[80];
 #endif				/*ENABLE_DEBUGGER */
 
+DEFINE_LOGLEVEL_SETUP(acpi, KERN_ACPI, "acpi:");
+
 static unsigned int acpi_irq_irq;
 static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
include/linux/acpi.h +1 -0
Index: linux-2.6/include/linux/acpi.h
===================================================================
@@ -43,6 +43,7 @@
 #include <asm/acpi.h>
 #include <linux/dmi.h>
 
+#define KERN_ACPI "<acpi>"
 
 enum acpi_irq_model_id {
 	ACPI_IRQ_MODEL_PIC = 0,
author
#11 lore raw

PATCH 5/6 apci: dump slit with printk(KERN_ACPI...)

In reply to Yinghai Lu
---
 drivers/acpi/numa.c |    9 +++++++++
 1 file changed, 9 insertions(+)
drivers/acpi/numa.c +9 -0
Index: linux-2.6/drivers/acpi/numa.c
===================================================================
@@ -150,6 +150,15 @@ static __init int slit_valid(struct acpi
 {
 	int i, j;
 	int d = slit->locality_count;
+	printk(KERN_DEBUG KERN_ACPI "ACPI: SLIT: nodes = %d\n", d);
+	for (i = 0; i < d; i++) {
+		printk(KERN_DEBUG KERN_ACPI "  ");
+		for (j = 0; j < d; j++)  {
+			u8 val = slit->entry[d*i + j];
+			printk(KERN_CONT KERN_ACPI " %d", val);
+		}
+		printk(KERN_CONT KERN_ACPI "\n");
+	}
 	for (i = 0; i < d; i++) {
 		for (j = 0; j < d; j++)  {
 			u8 val = slit->entry[d*i + j];
#12 lore raw

Re: [PATCH 5/6] apci: dump slit with printk(KERN_ACPI...)

Quoted 13 lines · Yinghai Lu
---
 drivers/acpi/numa.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6/drivers/acpi/numa.c
===================================================================

drivers/acpi/numa.c +0 -0
@@ -150,6 +150,15 @@ static __init int slit_valid(struct acpi
 {
 	int i, j;

drivers/acpi/numa.c static __init int slit_valid(struct acpi · line 161

Quoted 10 lines
drivers/acpi/numa.c +9 -0
 	int d = slit->locality_count;
+	printk(KERN_DEBUG KERN_ACPI "ACPI: SLIT: nodes = %d\n", d);
+	for (i = 0; i < d; i++) {
+		printk(KERN_DEBUG KERN_ACPI "  ");
+		for (j = 0; j < d; j++)  {
+			u8 val = slit->entry[d*i + j];
+			printk(KERN_CONT KERN_ACPI " %d", val);
+		}
+		printk(KERN_CONT KERN_ACPI "\n");
+	}

It will produce something like this:
<7><acpi>ACPI: SLIT: nodes = %d\n
<7><acpi> <acpi> %d<acpi> %d<acpi> %d<acpi> %d<acpi>\n

bit wrong... ;)

Marcin

author
#13 lore raw

Re: [PATCH 5/6] apci: dump slit with printk(KERN_ACPI...)

Quoted 29 lines · Marcin Slusarz
Quoted 13 lines · Yinghai Lu
---
 drivers/acpi/numa.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6/drivers/acpi/numa.c
===================================================================

drivers/acpi/numa.c +0 -0
@@ -150,6 +150,15 @@ static __init int slit_valid(struct acpi
 {
      int i, j;

drivers/acpi/numa.c static __init int slit_valid(struct acpi · line 161

Quoted 10 lines
drivers/acpi/numa.c +9 -0
      int d = slit->locality_count;
+     printk(KERN_DEBUG KERN_ACPI "ACPI: SLIT: nodes = %d\n", d);
+     for (i = 0; i < d; i++) {
+             printk(KERN_DEBUG KERN_ACPI "  ");
+             for (j = 0; j < d; j++)  {
+                     u8 val = slit->entry[d*i + j];
+                     printk(KERN_CONT KERN_ACPI " %d", val);
+             }
+             printk(KERN_CONT KERN_ACPI "\n");
+     }

It will produce something like this:
<7><acpi>ACPI: SLIT: nodes = %d\n
<7><acpi> <acpi> %d<acpi> %d<acpi> %d<acpi> %d<acpi>\n

Quoted 1 line

bit wrong... ;)

did you check v6...?

YH

#14 lore raw

Re: [PATCH 5/6] apci: dump slit with printk(KERN_ACPI...)

Quoted 31 lines · Yinghai Lu
Quoted 29 lines · Marcin Slusarz
Quoted 13 lines · Yinghai Lu
---
 drivers/acpi/numa.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6/drivers/acpi/numa.c
===================================================================

drivers/acpi/numa.c +0 -0
@@ -150,6 +150,15 @@ static __init int slit_valid(struct acpi
 {
      int i, j;

drivers/acpi/numa.c static __init int slit_valid(struct acpi · line 161

Quoted 10 lines
drivers/acpi/numa.c +9 -0
      int d = slit->locality_count;
+     printk(KERN_DEBUG KERN_ACPI "ACPI: SLIT: nodes = %d\n", d);
+     for (i = 0; i < d; i++) {
+             printk(KERN_DEBUG KERN_ACPI "  ");
+             for (j = 0; j < d; j++)  {
+                     u8 val = slit->entry[d*i + j];
+                     printk(KERN_CONT KERN_ACPI " %d", val);
+             }
+             printk(KERN_CONT KERN_ACPI "\n");
+     }

It will produce something like this:
<7><acpi>ACPI: SLIT: nodes = %d\n
<7><acpi> <acpi> %d<acpi> %d<acpi> %d<acpi> %d<acpi>\n

Quoted 3 lines
Quoted 1 line

bit wrong... ;)

did you check v6...?

No, I didn't test it.
Sorry for the noise.

Marcin

author
#15 lore raw

PATCH 6/6 x86: add KERN_APIC

In reply to Yinghai Lu

and kill apic_printk
using loglevel=apic:8 intead

---
 Documentation/kernel-parameters.txt         |    6 
 arch/x86/kernel/apic.c                      |  108 +++++-------
 arch/x86/kernel/io_apic.c                   |  235 +++++++++++++---------------
 arch/x86/kernel/mpparse.c                   |   10 -
 arch/x86/kernel/smpboot.c                   |   11 -
 include/asm-x86/apic.h                      |   20 --
 include/asm-x86/es7000/wakecpu.h            |    6 
 include/asm-x86/mach-default/mach_wakecpu.h |    6 
 8 files changed, 178 insertions(+), 224 deletions(-)
Documentation/kernel-parameters.txt +0 -6
Index: linux-2.6/Documentation/kernel-parameters.txt
===================================================================
@@ -306,12 +306,6 @@ and is between 256 and 4096 characters.
 			not play well with APC CPU idle - disable it if you have
 			APC and your system crashes randomly.
 
-	apic=		[APIC,i386] Advanced Programmable Interrupt Controller
-			Change the output verbosity whilst booting
-			Format: { quiet (default) | verbose | debug }
-			Change the amount of debugging information output
-			when initialising the APIC and IO-APIC components.
-
 	apm=		[APM] Advanced Power Management
 			See header of arch/x86/kernel/apm_32.c.
 
arch/x86/kernel/apic.c +49 -59

368 lines not on this page · raw message

arch/x86/kernel/io_apic.c +111 -124

638 lines not on this page · raw message

arch/x86/kernel/mpparse.c +5 -5
Index: linux-2.6/arch/x86/kernel/mpparse.c
===================================================================
@@ -83,7 +83,7 @@ static void __init MP_bus_info(struct mp
 	if (x86_quirks->mpc_oem_bus_info)
 		x86_quirks->mpc_oem_bus_info(m, str);
 	else
-		apic_printk(APIC_VERBOSE, "Bus #%d is %s\n", m->mpc_busid, str);
+		printk(APIC_VERBOSE "Bus #%d is %s\n", m->mpc_busid, str);
 
 #if MAX_MP_BUSSES < 256
 	if (m->mpc_busid >= MAX_MP_BUSSES) {
@@ -154,7 +154,7 @@ static void __init MP_ioapic_info(struct
 
 static void print_MP_intsrc_info(struct mpc_config_intsrc *m)
 {
-	apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x,"
+	printk(APIC_VERBOSE "Int: type %d, pol %d, trig %d, bus %02x,"
 		" IRQ %02x, APIC ID %x, APIC INT %02x\n",
 		m->mpc_irqtype, m->mpc_irqflag & 3,
 		(m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
@@ -163,7 +163,7 @@ static void print_MP_intsrc_info(struct
 
 static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq)
 {
-	apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x,"
+	printk(APIC_VERBOSE "Int: type %d, pol %d, trig %d, bus %02x,"
 		" IRQ %02x, APIC ID %x, APIC INT %02x\n",
 		mp_irq->mp_irqtype, mp_irq->mp_irqflag & 3,
 		(mp_irq->mp_irqflag >> 2) & 3, mp_irq->mp_srcbus,
@@ -235,7 +235,7 @@ static void __init MP_intsrc_info(struct
 
 static void __init MP_lintsrc_info(struct mpc_config_lintsrc *m)
 {
-	apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x,"
+	printk(APIC_VERBOSE "Lint: type %d, pol %d, trig %d, bus %02x,"
 		" IRQ %02x, APIC ID %x, APIC LINT %02x\n",
 		m->mpc_irqtype, m->mpc_irqflag & 3,
 		(m->mpc_irqflag >> 2) & 3, m->mpc_srcbusid,
@@ -697,7 +697,7 @@ static int __init smp_scan_config(unsign
 	unsigned int *bp = phys_to_virt(base);
 	struct intel_mp_floating *mpf;
 
-	apic_printk(APIC_VERBOSE, "Scan SMP from %p for %ld bytes.\n",
+	printk(APIC_VERBOSE "Scan SMP from %p for %ld bytes.\n",
 			bp, length);
 	BUILD_BUG_ON(sizeof(*mpf) != 16);
 
arch/x86/kernel/smpboot.c +6 -5
Index: linux-2.6/arch/x86/kernel/smpboot.c
===================================================================
@@ -542,17 +542,18 @@ static inline void __inquire_remote_apic
 	int timeout;
 	u32 status;
 
-	printk(KERN_INFO "Inquiring remote APIC 0x%x...\n", apicid);
+	printk(APIC_DEBUG "Inquiring remote APIC 0x%x...\n", apicid);
 
 	for (i = 0; i < ARRAY_SIZE(regs); i++) {
-		printk(KERN_INFO "... APIC 0x%x %s: ", apicid, names[i]);
+		printk(APIC_DEBUG "... APIC 0x%x %s: ",
+			 apicid, names[i]);
 
 		/*
 		 * Wait for idle.
 		 */
 		status = safe_apic_wait_icr_idle();
 		if (status)
-			printk(KERN_CONT
+			printk(KERN_CONT KERN_APIC
 			       "a previous APIC delivery may have failed\n");
 
 		apic_icr_write(APIC_DM_REMRD | regs[i], apicid);
@@ -566,10 +567,10 @@ static inline void __inquire_remote_apic
 		switch (status) {
 		case APIC_ICR_RR_VALID:
 			status = apic_read(APIC_RRR);
-			printk(KERN_CONT "%08x\n", status);
+			printk(KERN_CONT KERN_APIC "%08x\n", status);
 			break;
 		default:
-			printk(KERN_CONT "failed\n");
+			printk(KERN_CONT KERN_APIC "failed\n");
 		}
 	}
 }
include/asm-x86/apic.h +5 -15
Index: linux-2.6/include/asm-x86/apic.h
===================================================================
@@ -14,24 +14,14 @@
 
 #define ARCH_APICTIMER_STOPS_ON_C3	1
 
-/*
- * Debugging macros
- */
-#define APIC_QUIET   0
-#define APIC_VERBOSE 1
-#define APIC_DEBUG   2
+#define KERN_APIC "<apic>"
 
 /*
- * Define the default level of output to be very little
- * This can be turned up by using apic=verbose for more
- * information and apic=debug for _lots_ of information.
- * apic_verbosity is defined in apic.c
+ * Debugging macros
  */
-#define apic_printk(v, s, a...) do {       \
-		if ((v) <= apic_verbosity) \
-			printk(s, ##a);    \
-	} while (0)
-
+#define APIC_QUIET   KERN_WARNING KERN_APIC
+#define APIC_VERBOSE KERN_INFO KERN_APIC
+#define APIC_DEBUG   KERN_DEBUG KERN_APIC
 
 extern void generic_apic_probe(void);
 
include/asm-x86/es7000/wakecpu.h +1 -5
Index: linux-2.6/include/asm-x86/es7000/wakecpu.h
===================================================================
@@ -50,10 +50,6 @@ static inline void restore_NMI_vector(un
 {
 }
 
-#if APIC_DEBUG
- #define inquire_remote_apic(apicid) __inquire_remote_apic(apicid)
-#else
- #define inquire_remote_apic(apicid) {}
-#endif
+#define inquire_remote_apic(apicid) __inquire_remote_apic(apicid)
 
 #endif /* __ASM_MACH_WAKECPU_H */
include/asm-x86/mach-default/mach_wakecpu.h +1 -5
Index: linux-2.6/include/asm-x86/mach-default/mach_wakecpu.h
===================================================================
@@ -33,10 +33,6 @@ static inline void restore_NMI_vector(un
 {
 }
 
-#if APIC_DEBUG
- #define inquire_remote_apic(apicid) __inquire_remote_apic(apicid)
-#else
- #define inquire_remote_apic(apicid) {}
-#endif
+#define inquire_remote_apic(apicid) __inquire_remote_apic(apicid)
 
 #endif /* ASM_X86__MACH_DEFAULT__MACH_WAKECPU_H */
#16 lore raw

Re: [PATCH 6/6] x86: add KERN_APIC

Quoted 2 lines · Yinghai Lu

and kill apic_printk
using loglevel=apic:8 instead

yes, that aspect is very nice.

arch/x86/kernel/apic.c static int __init calibrate_by_pmtimer(l · line 566

Quoted 4 lines
arch/x86/kernel/apic.c +2 -1
+DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 6);
 
-		printk(KERN_WARNING "APIC calibration not consistent "
+		printk(KERN_WARNING KERN_APIC "APIC calibration not consistent "

here too the question arises: what should the semantics of the 'mixing' of such subsystem printk tags with the classic priority tags be. I think in this particular case we dont want the KERN_APIC tag, as that would prevent this failure message to be printed by default. I.e. this line should remain:

arch/x86/kernel/apic.c static int __init calibrate_by_pmtimer(l · line 566

Quoted 1 line
arch/x86/kernel/apic.c +0 -1
-		printk(KERN_WARNING "APIC calibration not consistent "

to make sure this warning always shows up in the logs. Agreed?

Ingo

author
#17 lore raw

Re: [PATCH 6/6] x86: add KERN_APIC

Quoted 19 lines · Ingo Molnar
Quoted 2 lines · Yinghai Lu

and kill apic_printk
using loglevel=apic:8 instead

yes, that aspect is very nice.

arch/x86/kernel/apic.c static int __init calibrate_by_pmtimer(l · line 566

Quoted 4 lines
arch/x86/kernel/apic.c +2 -1
+DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 6);
 
-             printk(KERN_WARNING "APIC calibration not consistent "
+             printk(KERN_WARNING KERN_APIC "APIC calibration not consistent "

here too the question arises: what should the semantics of the 'mixing' of such subsystem printk tags with the classic priority tags be. I think in this particular case we dont want the KERN_APIC tag, as that would prevent this failure message to be printed by default. I.e. this line should remain:

Quoted 3 lines
Quoted 1 line

- printk(KERN_WARNING "APIC calibration not consistent "

to make sure this warning always shows up in the logs. Agreed?

with

DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 6);

the KERN_WARNING <5> will be showing up that warning, even without loglevl=apic:8

or change that to DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 7); ?

YH

#18 lore raw

Re: [PATCH 6/6] x86: add KERN_APIC

Quoted 22 lines · Yinghai Lu
Quoted 21 lines · Ingo Molnar
Quoted 2 lines · Yinghai Lu

and kill apic_printk
using loglevel=apic:8 instead

yes, that aspect is very nice.

arch/x86/kernel/apic.c static int __init calibrate_by_pmtimer(l · line 566

Quoted 4 lines
arch/x86/kernel/apic.c +2 -1
+DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 6);
 
-             printk(KERN_WARNING "APIC calibration not consistent "
+             printk(KERN_WARNING KERN_APIC "APIC calibration not consistent "

here too the question arises: what should the semantics of the 'mixing' of such subsystem printk tags with the classic priority tags be. I think in this particular case we dont want the KERN_APIC tag, as that would prevent this failure message to be printed by default. I.e. this line should remain:

Quoted 1 line

- printk(KERN_WARNING "APIC calibration not consistent "

Quoted 8 lines
Quoted 1 line

to make sure this warning always shows up in the logs. Agreed?

with

DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 6);

the KERN_WARNING <5> will be showing up that warning, even without loglevl=apic:8

ok, but if that printk will show up no matter what, why is there any need to add an extra tag?

my main worry is the duplication of the tag. People have a hard enough time adding a _single_ printk tag - adding multiple ones is clearly too much.

Ingo

#19 lore raw

Re: [PATCH 6/6] x86: add KERN_APIC

In reply to Yinghai Lu
Quoted 15 lines · Yinghai Lu
Quoted 10 lines · Ingo Molnar
Quoted 3 lines
(quoted diff) +1 -1
-             printk(KERN_WARNING "APIC calibration not consistent "
+             printk(KERN_WARNING KERN_APIC "APIC calibration not

consistent "

here too the question arises: what should the semantics of the 'mixing' of such subsystem printk tags with the classic priority tags be. I think in this particular case we dont want the KERN_APIC tag, as that would prevent this failure message to be printed by default. I.e. this line should remain:

Quoted 3 lines
Quoted 1 line

- printk(KERN_WARNING "APIC calibration not consistent "

to make sure this warning always shows up in the logs. Agreed?

Quoted 7 lines

with
DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 6); the KERN_WARNING <5> will be showing up that warning, even without loglevl=apic:8

or change that to DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 7);

Are you suggesting that each subsystem define its own default log level? That sounds truly horrible. It would mean that when reading code or adding new messages you'd always have to check what the default loglevel is for a particular subsystem.

I really like the idea of being able to easily increase the verbosity for a particular subsystem, but please make sure that by default all messages with the same level are treated the same, irrespective of which subsystem they belong to.

So IMO
printk(KERN_WARNING "APIC calibration not consistent "
and
printk(KERN_WARNING KERN_APIC "APIC calibration not consistent "
should do exactly the same thing if no 'loglevel=apic:X' is used and that should be guaranteed for all subsystems.

Cheers,
FJP

author
#20 lore raw

Re: [PATCH 6/6] x86: add KERN_APIC

Quoted 21 lines · Frans Pop
Quoted 20 lines · Yinghai Lu
Quoted 10 lines · Ingo Molnar
Quoted 3 lines
(quoted diff) +1 -1
-             printk(KERN_WARNING "APIC calibration not consistent "
+             printk(KERN_WARNING KERN_APIC "APIC calibration not

consistent "

here too the question arises: what should the semantics of the 'mixing' of such subsystem printk tags with the classic priority tags be. I think in this particular case we dont want the KERN_APIC tag, as that would prevent this failure message to be printed by default. I.e. this line should remain:

Quoted 3 lines
Quoted 1 line

- printk(KERN_WARNING "APIC calibration not consistent "

to make sure this warning always shows up in the logs. Agreed?

with
DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 6); the KERN_WARNING <5> will be showing up that warning, even without loglevl=apic:8

Quoted 7 lines
Quoted 2 lines

or change that to DEFINE_LOGLEVEL_SETUP_DEF(apic, KERN_APIC, "apic:", 7);

Are you suggesting that each subsystem define its own default log level? That sounds truly horrible. It would mean that when reading code or adding new messages you'd always have to check what the default loglevel is for a particular subsystem.

could be done.
SPEW: 8
???:9

current msg_loglevel is limted to one digital

YH

#21 lore raw
In reply to Yinghai Lu
Quoted 17 lines · On Wed, 17 Sep 2008 01:27:41 -0700 Yinghai Lu <[email protected]> wrote:

KERN_PCI
KERN_ACPI
v4: fix some checkpatch error and warning
v5: add default with DEFINE_LOGLEVE_SETUP_DEF
KERN_APIC
v6: set the default only one time

usage:

	in .h to have
		#define KERN_PCI "<pci>"
	in .c to have
		DEFINE_LOGLEVEL_SETUP(pci, KERN_PCI, "pci:");
	then could use
		printk(KERN_DEBUG KERN_PCI fmt, ...);
	and command line
		loglevel=3,pci:8
Quoted 2 lines

you can add different printk to different files of one subsys if you like not just one susbsys one tag, and don't need to update kernel.h to add more tags

This all looks dreadfully similar to Jason Baron's "dynamic debug v2".

Similar enough that we couldn't justify merging both.

#22 lore raw

(Jason Cc:-ed)

Quoted 19 lines · Andrew Morton
Quoted 17 lines · On Wed, 17 Sep 2008 01:27:41 -0700 Yinghai Lu <[email protected]> wrote:

KERN_PCI
KERN_ACPI
v4: fix some checkpatch error and warning
v5: add default with DEFINE_LOGLEVE_SETUP_DEF
KERN_APIC
v6: set the default only one time

usage:

	in .h to have
		#define KERN_PCI "<pci>"
	in .c to have
		DEFINE_LOGLEVEL_SETUP(pci, KERN_PCI, "pci:");
	then could use
		printk(KERN_DEBUG KERN_PCI fmt, ...);
	and command line
		loglevel=3,pci:8
Quoted 4 lines
Quoted 2 lines

you can add different printk to different files of one subsys if you like not just one susbsys one tag, and don't need to update kernel.h to add more tags

This all looks dreadfully similar to Jason Baron's "dynamic debug v2".

yeah, but s/dreadfully/luckily

Quoted 1 line

Similar enough that we couldn't justify merging both.

agreed.

Here's the summary as i see it: Jason's "dynamic debug" mainly relies on automatically creating a section of tags associated with each pr_debug() callsite. The unit of filtering is the .c file - which lends itself well to things like individual drivers but is not quite good for more generic entities like full subsystems.

I think a better model is what hpa suggested: add string tags at the call site and make it all a sub-case of printk, via ASCII space tags. OTOH, a pr_debug() variant could be offered that just inserts a __FILE__ tag into the output - this would enable most of the "dynamic debug" functionality that Jason's patch series implements IMO.

There's also a wider robustness argument why this is better: we want to keep printk simple by default, hence doing these things via the ASCII space is good design. "dynamic debug" does it all programmatically via extra sections, etc., which is eventually a source of bugs and unrobustness.

Ingo

#23 lore raw
Quoted 46 lines · Ingo Molnar

(Jason Cc:-ed)

Quoted 19 lines · Andrew Morton
Quoted 17 lines · On Wed, 17 Sep 2008 01:27:41 -0700 Yinghai Lu <[email protected]> wrote:

KERN_PCI
KERN_ACPI
v4: fix some checkpatch error and warning
v5: add default with DEFINE_LOGLEVE_SETUP_DEF
KERN_APIC
v6: set the default only one time

usage:

	in .h to have
		#define KERN_PCI "<pci>"
	in .c to have
		DEFINE_LOGLEVEL_SETUP(pci, KERN_PCI, "pci:");
	then could use
		printk(KERN_DEBUG KERN_PCI fmt, ...);
	and command line
		loglevel=3,pci:8
Quoted 4 lines
Quoted 2 lines

you can add different printk to different files of one subsys if you like not just one susbsys one tag, and don't need to update kernel.h to add more tags

This all looks dreadfully similar to Jason Baron's "dynamic debug v2".

yeah, but s/dreadfully/luckily

Quoted 1 line

Similar enough that we couldn't justify merging both.

agreed.

Here's the summary as i see it: Jason's "dynamic debug" mainly relies on automatically creating a section of tags associated with each pr_debug() callsite. The unit of filtering is the .c file - which lends itself well to things like individual drivers but is not quite good for more generic entities like full subsystems.

I think a better model is what hpa suggested: add string tags at the call site and make it all a sub-case of printk, via ASCII space tags. OTOH, a pr_debug() variant could be offered that just inserts a __FILE__ tag into the output - this would enable most of the "dynamic debug" functionality that Jason's patch series implements IMO.

Quoted 7 lines

There's also a wider robustness argument why this is better: we want to keep printk simple by default, hence doing these things via the ASCII space is good design. "dynamic debug" does it all programmatically via extra sections, etc., which is eventually a source of bugs and unrobustness.

Ingo

hi,

indeed both proposals seem to be addressing a similar core issue - being able to dynamically (as opposed to re-compiling) change the amount of verbosity that the kernel spews. I would liken it to adding a -verbose flag to the kernel.

Beyond that the 2 approaches differ in a number of ways as I see:

1)

Filtering Unit. 'Boot printk', or Yinghai's approach explicitly defines filtering units via tags. 'dynamic debug' is implicitly based around "KBUILD_MODNAME", not .c files, which seems to be a good unit for most parts of the kernel. For full subsystems, it is not appropriate. There, i have introduced the conecpt, of 'logical modname', which is very roughly similar to the 'boot printk' tag concept. Basically, subsystems could be grouped together using this 'logical modname'.

2)

kernel impact. Part of the design of 'dynamic debug' was to be very low impact. in fact, when its disabled, we basically jump around the printk with a test and a jump. So, there is only a 2 instruction overhead per call-site. I believe (and please correct me if i'm wrong) that 'boot printk' is filtering after printk has been called...So you have at least the overhead of a fucntion call plus the overhead of the printk() function.

3)

usefullness beyond just doing 'printk'. The basic building block of dynamic debug is simply: 'dynamic_debug_enabled()'. So blocks of code are built up as:

if (dynamic_debug_enabled()) {
do debugging work
}

printk is then simply:

if (dynamic_debug_enabled()) {
        printk();
}

or:

define pr_debug()

        (dynamic_debug_enabled()) {
                printk();
        }

The intent here was to dynamically be able to turn 'printk' or other debugging code dynamically off and on.

4)

ability to compile out the code. 'dynamic debug' has 3 modes of compilation. If 'DEBUG' is set then then dynamic_debug_enabled() simply is defined to 1. If 'DYNAMIC_DEBUG' is set dynamic_debug_enabled() becomes the test and jump i desscribe in #2. If neither 'DEBUG' is set nor 'DYNAMIC_DEBUG' then the code is compiled out (no impact). So to enable 'dynamic debug' for the entire kernel, 'DYNAMIC_DEBUG' is defined for all compilation units. Additionally subsystems, can define there own: CONFIG_SUBSYSTEM_DEBUG, and CONFIG_SUBSYSTEM_DEBUG_DYNAMIC, which sets either 'DEBUG' or 'DYNAMIC_DEBUG' for their particular subsystem. I believe this approach provides a good level of flexibility.

5)

debug filtering. In my survey of subsystems, not only were levels used, but also 'flags' ie a set of debug flags can be set for a particular subsystem. In 'dynamic debug' this is implemented in dynamic_debug_enabled() before printk is called. In 'boot printk' this is implemented in printk() itself. 'dynamic printk' defines 3 types of
filtering: TYPE_BOOLEAN , TYPE_LEVEL, and TYPE_FLAG. Seems like 'boot printk' at least at the moment has type level.

6)

compatibility with existing code. In 'dynamic debug' I tried to reduce code churn as much as possible. Thus, pr_debug() and dev_dbg() calls don't need to be changed at all. Further, subsystem specfic printing, for example, subsystem_dprintk(), can be implemented in 'dynamic debug' by simply just changing the definition of ubsystem_dprintk(). The callers do not need to be modified.

7) 'robustness'. Dynamic debug does add extra kernel sections. But if they are designed carefully I don't think they are very risky. Further, 'boot printk' also defines extra sections. So unless i'm missing something i don't see how that makes 'boot printk' more or less robust.

thanks,

-Jason

#24 lore raw
Quoted 10 lines · Jason Baron

hi,

indeed both proposals seem to be addressing a similar core issue - being able to dynamically (as opposed to re-compiling) change the amount of verbosity that the kernel spews. I would liken it to adding a -verbose flag to the kernel.

Beyond that the 2 approaches differ in a number of ways as I see:

8) The ability to accessed filtered messages a posteori (via dmesg), which is something we currently take for granted.

This *is* the fundamental difference between what Yinghai has now and both your stuff and Yinghai's original proposal. Not producing the additional messages at all is inherently cheaper, sometimes *much* cheaper, but it obviously means the information is not accessible at all.

At the moment, I would argue that the fact that dmesg is, in effect, more verbose than the kernel itself is a good thing; it makes dmesg dumps more useful.

-hpa

#25 lore raw
Quoted 8 lines · H. Peter Anvin

8) The ability to accessed filtered messages a posteori (via dmesg), which is something we currently take for granted.

This *is* the fundamental difference between what Yinghai has now and both your stuff and Yinghai's original proposal. Not producing the additional messages at all is inherently cheaper, sometimes *much* cheaper, but it obviously means the information is not accessible at all.

which is what we really want. If a bootup fails, the user has to repeat the bootup at least once with a verbosity level increased and with (hopefully) some sort of log capture facility attached.

So the point would be, if the user specified loglevel=all, we would get really comprehensive, one-stop-shop output.

Quoted 3 lines

At the moment, I would argue that the fact that dmesg is, in effect, more verbose than the kernel itself is a good thing; it makes dmesg dumps more useful.

yes - but log messages not showing up on the physical console is already a task that is solved via regular loglevels. printks are being removed because even printing to the dmesg can be expensive (vsprintf is not the cheapest of functions, and most of dmesg shows up in the syslog and people want a clear, default, not too verbose output for that).

so the main feature of these patches is that we can cut out too verbose information by default, and we can reactivate it with a single central switch (and a repeated bootup - which has to be done anyway). Everything else is already solved via either traditional loglevels or pr_debug() based, build-time facilities.

Ingo

#26 lore raw
Quoted 5 lines · Ingo Molnar

which is what we really want. If a bootup fails, the user has to repeat the bootup at least once with a verbosity level increased and with (hopefully) some sort of log capture facility attached.

So the point would be, if the user specified loglevel=all, we would get really comprehensive, one-stop-shop output.

That is true if the bootup fails, but it's fairly common that we get the machine up (at least to the point when we can dmesg), but the user wants to report a problem. For that case, it's very nice if the dmesg log contains as much information as possible.

So I don't think it's clear that pre-filtering is what we want, at all.

-hpa

#27 lore raw
Quoted 10 lines · H. Peter Anvin
Quoted 8 lines · Ingo Molnar

which is what we really want. If a bootup fails, the user has to repeat the bootup at least once with a verbosity level increased and with (hopefully) some sort of log capture facility attached.

So the point would be, if the user specified loglevel=all, we would get really comprehensive, one-stop-shop output.

Quoted 9 lines

That is true if the bootup fails, but it's fairly common that we get the machine up (at least to the point when we can dmesg), but the user wants to report a problem. For that case, it's very nice if the dmesg log contains as much information as possible.

So I don't think it's clear that pre-filtering is what we want, at all.

-hpa

hi,

if we take this argument to its extreme, then we end up spending all of our time verifying that the kernel is working correctly and no time actually doing work. I think 'printk_ratelimit' captures this. Thus, the line has to be drawn somewhere. If you want the messages in 'dmesg' use, printk(KERN_DEBUG), and 'grep'. For the rest, I propose pre-filtering, which is what 'dynamic debug' uses.

thanks,

-Jason

#28 lore raw
Quoted 7 lines · Jason Baron

if we take this argument to its extreme, then we end up spending all of
our time verifying that the kernel is working correctly and no time
actually doing work. I think 'printk_ratelimit' captures this. Thus, the line has to be drawn somewhere. If you want the messages in 'dmesg' use, printk(KERN_DEBUG), and 'grep'. For the rest, I propose pre-filtering, which is
what 'dynamic debug' uses.

Taking any argument to its extreme and you come up with something ridiculous.

One could equally argue that if you have so many debugging messages that you have to prefilter for performance, you're so bloating your kernel that you need to stop.

I find it highly questionable that it makes sense to put even skipped messages into hot paths in the production kernel. Skipped prints are NOT free, even if they are lot cheaper than actually rendering the string.

-hpa

#29 lore raw
Quoted 11 lines · H. Peter Anvin
Quoted 9 lines · Jason Baron

if we take this argument to its extreme, then we end up spending all of our time verifying that the kernel is working correctly and no time actually doing work. I think 'printk_ratelimit' captures this. Thus, the line has to be drawn somewhere. If you want the messages in 'dmesg' use,
printk(KERN_DEBUG), and 'grep'. For the rest, I propose pre-filtering, which is what 'dynamic debug' uses.

Quoted 6 lines

Taking any argument to its extreme and you come up with something ridiculous.

One could equally argue that if you have so many debugging messages that you have to prefilter for performance, you're so bloating your kernel that you need to stop.

in my testing there was no significant difference between pre-filtering vs. not built in. However, there was a measureable affect of having them built in vs. not built in.

Quoted 6 lines

I find it highly questionable that it makes sense to put even skipped messages into hot paths in the production kernel. Skipped prints are NOT free, even if they are lot cheaper than actually rendering the string.

If you feel that way, you simply don't have to turn the single CONFIG_ on. Futher, the patchset allows fine-grained control over the modules that you would want to enable/disable.

thanks,

-Jason

#30 lore raw
Quoted 5 lines · Jason Baron

in my testing there was no significant difference between pre-filtering vs. not built in. However, there was a measureable affect of having them built in vs. not built in.

<somewhat irrelevant rant>

Okay, I'm so bloody sick of hearing people justifying bloat by saying "no measurable difference." That only means that you don't have GROSS bloat. Unless you have real statistics to the contrary, most people's performance testing is at the very best accurate to 5-10%. This is hardly "no bloat".

</somewhat irrelevant rant>

-hpa

author
#31 lore raw
Quoted 7 lines · H. Peter Anvin
Quoted 5 lines · Jason Baron

in my testing there was no significant difference between pre-filtering vs. not built in. However, there was a measureable affect of having them built in vs. not built in.

Quoted 8 lines

<somewhat irrelevant rant>

Okay, I'm so bloody sick of hearing people justifying bloat by saying "no measurable difference." That only means that you don't have GROSS bloat.
Unless you have real statistics to the contrary, most people's performance
testing is at the very best accurate to 5-10%. This is hardly "no bloat".

</somewhat irrelevant rant>

about performance difference:
1. will have printk(KERN_level KERN_tag "...\n");
2. will have tag_printk like

    #define dev_printk(level, dev, format, arg...)  \
           printk(level KERN_DEV "%s %s: " format , dev_driver_string(dev) , \
                   dev_name(dev) , ## arg)
3. still can use MACRO for compiling time
    #ifdef DEBUG
    #define dev_dbg(dev, format, arg...)            \
           dev_printk(KERN_DEBUG , dev , format , ## arg)
    #else
    #define dev_dbg(dev, format, arg...)            \
           ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
    #endif

4. with /proc/sys/kernel/printk_tag/dev could modify run-time level.
5. for big chunk dump or spew, caller could use
level = get_tag_level(KERN_DEV, &len) and compare level to
KERN_SPEW_LEVEL or etc
to decide if need to dump it.
6. other overhead to put tag like <dev> should be ok just like loglevel aready in the buffer

current only have one struct {
char *tag;
char *name; /* with extra : */
int level;
}
the level is some kind of console_loglevel for that tag.

if want to go further, let every dev_printk check that. then will not have them in log buffer

YH