Skip to contentSkip to conversation

Delay in Printk Messages.

DISCUSSION Arun Kumar 4 participants 4 messages Jun 28, 2014

lore
Share & tools
lore

Arun Kumar

author
#0 lore raw

I am able to read my printk messages in the kernel buffer only after unloading the module..
Is there some reason or configuration behind this.

I used a simple kernel module with only init and exit functions, and after loading the module i cannot see the message printed by the "module_init" function in the output given by "dmesg -c" I can see them only after i unload the module.

i wait for around 15-20 seconds for the init message but it only shows up on removing the module.

#1 lore raw

Try 'sysctl kernel.printk=7' where 7 is one of the levels defined in "include/linux/kern_levels.h".

Quoted 16 lines · Arun Kumar

I am able to read my printk messages in the kernel buffer only after unloading the module..
Is there some reason or configuration behind this.

I used a simple kernel module with only init and exit functions, and after loading the module i cannot see the message printed by the "module_init" function in the output given by "dmesg -c" I can see them only after i unload the module.

i wait for around 15-20 seconds for the init message but it only shows up on removing the module.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#2 lore raw

Try echo "7" > /proc/sys/kernel/printk to enable all console log levels.

The numbers are corresponding to below:

#define KERN_EMERG "<0>" /* system is unusable*/ #define KERN_ALERT "<1>" /* action must be taken immediately*/ #define KERN_CRIT "<2>" /* critical conditions*/ #define KERN_ERR "<3>" /* error conditions*/
#define KERN_WARNING "<4>" /* warning conditions*/ #define KERN_NOTICE "<5>" /* normal but significant condition*/ #define KERN_INFO "<6>" /* informational*/
#define KERN_DEBUG "<7>" /* debug-level messages*/

The default number is 4, which allows console to show messages only at least in KERN_WARNING. That could be why you cannot see log in KERN_INFO level.

#3 lore raw
In reply to Arun Kumar

Hello Arun Kumar,

Quoted 9 lines · Arun Kumar

I am able to read my printk messages in the kernel buffer only after unloading the module..
Is there some reason or configuration behind this.

I used a simple kernel module with only init and exit functions, and after loading the module i cannot see the message printed by the "module_init" function in the output given by "dmesg -c" I can see them only after i unload the module.

Since you do not provide your code I have to guess that your print statement looks like this:

	  pr_debug("Hello World!");

Please notice that printk doesn't flush until a trailing newline is provided (Linux Device Drivers Chapter 4). So maybe this is what you want:

	  pr_debug("Hello World!\n");
Quoted 7 lines

i wait for around 15-20 seconds for the init message but it only shows up on removing the module.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

With best regards

Michael Hornung