Difference between revisions of "Printk"

From eLinux.org
Jump to: navigation, search
 
Line 1: Line 1:
 +
printk is the routine used to submit a message to the kernel log buffer
 +
 +
See http://www.ibm.com/developerworks/linux/library/l-kernel-logging-apis/index.html
 +
 +
== conversion specifiers ==
 +
Most of the conversion specifiers supported by the user-space library routine printf()
 +
are also available in the kernel.
 +
However there are some exceptions (I don't think 64-bit types are supported on 32-bit systems).
 +
Also, there is at least one notable addition: %p for pointers will print the symbol name in place of the numeric pointer value, if available.
 +
 +
See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/printk-formats.txt
 +
for details.
 +
 +
== disabling printk messages at compile time ==
 +
There is a configuration option which allows you to turn off all the printk messages in the
 +
whole kernel (CONFIG_PRINTK).  This reduces the size the kernel, usually by at least 100k,
 +
since all the message strings are not compiled into the kernel binary image.  However, it
 +
also means you get absolutely no output from the kernel while it is running.  Disabling kernel
 +
printk messages is usually the last thing you do when you are tuning your kernel for size.
 +
 +
== pages related to printk ==
 +
Some page related to printk:
 +
* [[Printk Times]] - has information about how to turn on timestamps for each printk message
 +
** [[Printk_Times_Sample_4| printk time stamps sample]]
 
* [[Printk_Size_Info|printk size information]]
 
* [[Printk_Size_Info|printk size information]]
* [[Printk_Times_Sample_4| printk time stamps sample]]
+
* [[Do Printk]] - has information about a method of disabling printk messages on a per-module basis
* [[Do_Printk| printk debugging hacks]]
 

Revision as of 13:54, 4 February 2011

printk is the routine used to submit a message to the kernel log buffer

See http://www.ibm.com/developerworks/linux/library/l-kernel-logging-apis/index.html

conversion specifiers

Most of the conversion specifiers supported by the user-space library routine printf() are also available in the kernel. However there are some exceptions (I don't think 64-bit types are supported on 32-bit systems). Also, there is at least one notable addition: %p for pointers will print the symbol name in place of the numeric pointer value, if available.

See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/printk-formats.txt for details.

disabling printk messages at compile time

There is a configuration option which allows you to turn off all the printk messages in the whole kernel (CONFIG_PRINTK). This reduces the size the kernel, usually by at least 100k, since all the message strings are not compiled into the kernel binary image. However, it also means you get absolutely no output from the kernel while it is running. Disabling kernel printk messages is usually the last thing you do when you are tuning your kernel for size.

pages related to printk

Some page related to printk: