Table of Contents
printk()
include/linux/kernel.h
copy_[to/from]_user()
/
get_user()
/
put_user()
include/asm/uaccess.h
kmalloc()
/kfree()
include/linux/slab.h
current
include/asm/current.h
mdelay()
/udelay()
include/asm/delay.h
include/linux/delay.h
cpu_to_be32()
/be32_to_cpu()
/cpu_to_le32()
/le32_to_cpu()
include/asm/byteorder.h
local_irq_save()
/local_irq_restore()
include/linux/irqflags.h
local_bh_disable()
/local_bh_enable()
include/linux/interrupt.h
smp_processor_id
()
include/asm/smp.h
include/linux/init.h
__initcall()
/module_init()
include/linux/init.h
module_exit()
include/linux/init.h
try_module_get()
/module_put()
include/linux/module.h
printk()
feeds kernel messages to the
console, dmesg, and the syslog daemon. It is useful for debugging
and reporting errors, and can be used inside interrupt context,
but use with caution: a machine which has its console flooded with
printk messages is unusable. It uses a format string mostly
compatible with ANSI C printf, and C string concatenation to give
it a first "priority" argument:
printk(KERN_INFO "i = %u\n", i);
See include/linux/kernel.h
;
for other KERN_ values; these are interpreted by syslog as the
level. Special case: for printing an IP address use
__be32 ipaddress; printk(KERN_INFO "my ip: %pI4\n", &ipaddress);
printk()
internally uses a 1K buffer and does
not catch overruns. Make sure that will be enough.
You will know when you are a real kernel hacker when you start typoing printf as printk in your user programs :)
Another sidenote: the original Unix Version 6 sources had a comment on top of its printf function: "Printf should not be used for chit-chat". You should follow that advice.