Difference between revisions of "Printk"

From eLinux.org
Jump to: navigation, search
m (conversion specifiers: re-word slightly)
m (Add category)
Line 31: Line 31:
* [[Printk_Size_Info|printk size information]]
* [[Printk_Size_Info|printk size information]]
* [[Do Printk]] - has information about a method of disabling printk messages on a per-module basis
* [[Do Printk]] - has information about a method of disabling printk messages on a per-module basis

Revision as of 15:28, 27 October 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 are some notable additions, including "%pf", which will print the symbol name in place of the numeric pointer value, if available.

There is a file printk-formats in the kernel Documentation directory describing the difference conversion specifiers that are available.

See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/printk-formats.txt (But, as of kernel 2.6.37, this file did not include information about the %p* conversions.)

For information about the %p variants available in the kernel, see: http://www.embedded-bits.co.uk/2010/printk-format-specifiers/

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: