kernel, logbuf: add support for external log buffer
RFC 1/1 kernel, logbuf: add support for external log buffer
This merges support for the previously DENX-only kernel feature of specifying an alternative, "external" buffer for kernel printk messages and their associated metadata. This patch is based on DENX-only kernel commit:
commit 212f61c7fd3b952a81d1459dd32a86a32ddfd4ce
Author: Igor Lisitsin <[email protected]> Date: Wed Apr 18 14:55:19 2007 +0400
Add support for external log buffer.
Add support for external log buffer, for example passed by U-Boot, which may already contain messages (from the boot loader and/or POST).
see:
http://git.denx.de/?p=linux-denx.git;a=commit;h=212f61c7fd3b952a81d1459dd32a86a32ddfd4ce
When this option is enabled, an architecture- or machine-specific log buffer is used for all printk messages. This allows entities such as boot loaders (e.g. U-Boot) to place printk-compatible messages into this buffer and for the kernel to coalesce them with its normal messages. This patch support this feature for arch/arm based boards.
---
restage prior discussion from lkml:
https://lkml.org/lkml/2009/1/21/250
Discussion stopped, and I want to reanimate it, also there is a Project Proposal on the "CE Linux Developers List" for such a feature, see here:
http://www.mail-archive.com/celinux-dev at lists.celinuxforum.org/msg00103.html
Maybe it is now the time to discuss this again?
Is it worth to try to get this old code in current kernel, or should we investigate Kay Sievers proposal for a structured logging system, which will alter the format of the messages as they are stored in the log buffer, and discuss for this a "logbuffer support"?
See this discussion here:
http://thread.gmane.org/gmane.linux.kernel/1277619
arch/arm/mm/init.c | 25 ++++++++++ include/linux/logbuff.h | 51 ++++++++++++++++++++ init/Kconfig | 12 +++++ init/main.c | 5 ++ kernel/printk.c | 117 +++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 include/linux/logbuff.h
arch/arm/mm/init.c +25 -0
@@ -20,6 +20,7 @@#include <linux/highmem.h> #include <linux/gfp.h> #include <linux/memblock.h> +#include <linux/logbuff.h> #include <asm/mach-types.h> #include <asm/memblock.h>
@@ -38,6 +39,10 @@static unsigned long phys_initrd_start__initdata =0 ;static unsigned long phys_initrd_size__initdata =0 ; +#ifdef CONFIG_LOGBUFFER +static unsigned long ext_logbuff__initdata ; +#endif +static int __init early_initrd (char *p) {unsigned long start, size;
@@ -325,6 +330,9 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)void __init arm_memblock_init (struct meminfo *mi,struct machine_desc *mdesc) {int i; +#ifdef CONFIG_LOGBUFFER +unsigned long log_buf_base; +#endif for (i =0 ; i < mi->nr_banks; i++)memblock_add (mi->bank[i].start, mi->bank[i].size);
@@ -356,6 +364,16 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) initrd_end = initrd_start + phys_initrd_size; }#endif +#ifdef CONFIG_LOGBUFFER + log_buf_base =memblock_end_of_DRAM () -LOGBUFF_RESERVE ; +if (memblock_is_region_reserved (log_buf_base,LOGBUFF_RESERVE )) { +pr_err ("LOGBUF: could not use addr: %lx for logbuf support -" \ +" disabling logbuf support\n" , log_buf_base); + }else { +memblock_reserve (log_buf_base,LOGBUFF_RESERVE ); + ext_logbuff =__phys_to_virt (log_buf_base); + } +#endif arm_mm_memblock_reserve ();arm_dt_memblock_reserve ();
@@ -409,6 +427,13 @@ void __init bootmem_init(void) max_pfn = max_high -PHYS_PFN_OFFSET ; } +#ifdef CONFIG_LOGBUFFER +void *__init setup_ext_logbuff_mem (void ) +{ +return (void *)ext_logbuff; +} +#endif +static inline int free_area (unsigned long pfn,unsigned long end,char *s) {unsigned int pages =0 , size = (end - pfn) << (PAGE_SHIFT -10 );
include/linux/logbuff.h new file +51 -0
51 lines not on this page · raw message
init/Kconfig +12 -0
@@ -1031,6 +1031,18 @@ config PRINTK very difficult to diagnose system problems, saying N here is strongly discouraged. +config LOGBUFFER + bool "External logbuffer" if PRINTK + default n + depends on ARM + help + This option enables support for an alternative, "external" + printk log buffer. When enabled, an architecture- or machine- + specific log buffer is used for all printk messages. This + allows entities such as boot loaders to place printk-compatible + messages into this buffer and for the kernel to coalesce them + with its normal messages. + config BUG bool "BUG() support" if EXPERT default y
init/main.c +5 -0
@@ -68,6 +68,7 @@#include <linux/shmem_fs.h> #include <linux/slab.h> #include <linux/perf_event.h> +#include <linux/logbuff.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -492,6 +493,7 @@ asmlinkage void __init start_kernel(void)tick_init ();boot_cpu_init ();page_address_init (); +printk (KERN_NOTICE "%s" , linux_banner);setup_arch (&command_line);mm_init_owner (&init_mm, &init_task);
@@ -522,6 +524,9 @@ asmlinkage void __init start_kernel(void)sort_main_extable ();trap_init ();mm_init (); +#ifdef CONFIG_LOGBUFFER +setup_ext_logbuff (); +#endif /* * Set up the scheduler prior starting any interrupts (such as the
kernel/printk.c +113 -4
148 lines not on this page · raw message
Signature · 1 line
1.7.7.6
Hello,
Quoted 57 lines · Heiko Schocher
This merges support for the previously DENX-only kernel feature of specifying an alternative, "external" buffer for kernel printk messages and their associated metadata. This patch is based on DENX-only kernel commit:
commit
212f61c7fd3b952a81d1459dd32a86a32ddfd4ceAuthor: Igor Lisitsin<[email protected]> Date: Wed Apr 18 14:55:19 2007 +0400Add support for external log buffer.
Add support for external log buffer, for example passed by U-Boot, which may already contain messages (from the boot loader and/or POST).
Signed-off-by Igor Lisitsin<[email protected]>see:
http://git.denx.de/?p=linux-denx.git;a=commit;h=212f61c7fd3b952a81d1459dd32a86a32ddfd4ceWhen this option is enabled, an architecture- or machine-specific log buffer is used for all printk messages. This allows entities such as boot loaders (e.g. U-Boot) to place printk-compatible messages into this buffer and for the kernel to coalesce them with its normal messages. This patch support this feature for
arch/armbased boards.Signed-off-by Heiko Schocher<[email protected]>Cc Wolfgang Denk<[email protected]>Cc Igor Lisitsin<[email protected]>Cc Grant Erickson<[email protected]>Cc linux-kernel at vger.kernel.orgCc Tim Bird<[email protected]>Cc CE Linux Developers List<[email protected]>Cc Kay Sievers<[email protected]>---
restage prior discussion from lkml:https://lkml.org/lkml/2009/1/21/250
Discussion stopped, and I want to reanimate it, also there is a Project Proposal on the "CE Linux Developers List" for such a feature, see here:
http://www.mail-archive.com/celinux-dev at lists.celinuxforum.org/msg00103.html
Maybe it is now the time to discuss this again?
Is it worth to try to get this old code in current kernel, or should we investigate Kay Sievers proposal for a structured logging system, which will alter the format of the messages as they are stored in the log buffer, and discuss for this a "logbuffer support"?
See this discussion here:
Quoted 7 lines
arch/arm/mm/init.c | 25 ++++++++++ include/linux/logbuff.h | 51 ++++++++++++++++++++ init/Kconfig | 12 +++++ init/main.c | 5 ++ kernel/printk.c | 117 +++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 206 insertions(+), 4 deletions(-)create mode 100644
include/linux/logbuff.h
ping? I got no respond to this RFC ... no chance to get this to mainline?
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 19 lines · On Mon, 11 Jun 2012 08:13:08 +0200 Heiko Schocher <[email protected]> wrote:
This merges support for the previously DENX-only kernel feature of specifying an alternative, "external" buffer for kernel printk messages and their associated metadata. This patch is based on DENX-only kernel commit:
commit
212f61c7fd3b952a81d1459dd32a86a32ddfd4ceAuthor: Igor Lisitsin <[email protected]> Date: Wed Apr 18 14:55:19 2007 +0400Add support for external log buffer.
Add support for external log buffer, for example passed by U-Boot, which may already contain messages (from the boot loader and/or POST).
Signed-off-by Igor Lisitsin <[email protected]>see:
http://git.denx.de/?p=linux-denx.git;a=commit;h=212f61c7fd3b952a81d1459dd32a86a32ddfd4ce
Quoted 6 lines
When this option is enabled, an architecture- or machine-specific log buffer is used for all printk messages. This allows entities such as boot loaders (e.g. U-Boot) to place printk-compatible messages into this buffer and for the kernel to coalesce them with its normal messages. This patch support this feature for
arch/armbased boards.
Why was it done this way, rather than adding a hook to permit architectures to insert data into the head of the existing kernel buffer?
The latter approach would be quite simple, wouldn't it? A single line added to printk.c which calls an arch function which locates the boot loader buffer and prints it, with printk. And this is more flexible - for example, there might be more than one external message stream which we wish to capture.