To understand and use printk log levels, let's begin by reproducing that single line of code – the first printk from our helloworld_lkm kernel module:
printk(KERN_INFO "Hello, world\n");
Let's now address the elephant in the room: what exactly does KERN_INFO mean? Firstly, be careful now: it's not what your knee-jerk reaction says it is – a parameter. No! Notice that there is no comma character between it and the format string; just white space. KERN_INFO is merely one of eight log levels that a kernel printk gets logged at. A key thing to understand right away is that this log level is not a priority of any sort; its presence allows us to filter messages based on log level. The kernel defines eight possible log levels for printk; here they are:
// include/linux/kern_levels.h
#ifndef __KERN_LEVELS_H__
#define __KERN_LEVELS_H__
#define KERN_SOH "...