Discussion:
Delay in Printk Messages.
Arun Kumar
2014-06-28 17:33:45 UTC
Permalink
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.
Kristofer Hallin
2014-06-28 17:39:58 UTC
Permalink
Try 'sysctl kernel.printk=7' where 7 is one of the levels defined in
"include/linux/kern_levels.h".
Post by 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
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Aruna Hewapathirane
2014-06-28 17:43:00 UTC
Permalink
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.
m***@gmail.com
2014-06-28 21:58:16 UTC
Permalink
Hello Arun Kumar,
Post by 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");
Post by Arun Kumar
i wait for around 15-20 seconds for the init message but it only shows
up on removing the module.
_______________________________________________
Kernelnewbies mailing list
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
With best regards

Michael Hornung

Loading...