printk is a function that prints messages and is used in the C Programming Language exclusively for the Linux Kernel. It accepts a string parameter called the format string, which specifies a method for rendering an arbitrary number of varied data type parameter(s) into a string. The string is then printed to the kernel log.
Questions tagged [printk]
94 questions
33
votes
2 answers
Difference between printk and pr_info
What's the exact difference between printk and pr_info functions ? And under what conditions, should I choose one over the another ?

Jarvis
- 8,494
- 3
- 27
- 58
22
votes
7 answers
Where does output of print in kernel go?
I am debugging a driver for linux (specifically ubuntu server 9.04), and there are several printf statements in the code.
Where can I view the output of these statements?
EDIT1: What i'm trying to do is write to kernel using the proc…

apoorv020
- 5,420
- 11
- 40
- 63
20
votes
1 answer
difference between dmesg and /var/log/kern.log
I am modifying the kvm module and I have added printk statements in the kernel code.After running the virtual machine, printk gives me the faulting address and other information about the guest OS.
I need to generate the statistic from this…

Deepthought
- 2,815
- 2
- 28
- 39
16
votes
2 answers
printk inside an interrupt handler , is it really that bad?
everybody knows that interrupt handler should be short as possible. and adding functions like printk for debugging inside an interrupt handler is something that shouldn't be done.
Actually, I tried it before when I was debugging the linux kernel for…

stdcall
- 27,613
- 18
- 81
- 125
13
votes
2 answers
Linux-kernel debug printouts?
Is there a better way to debug printouts in the Linux kernel?
Right now littering the code with:
printk(KERN_DBG "%s:%d - %s() ", __FILE__, __LINE__, __FUNCTION__ );
Which isn't very clean.
There ought to be a way for the whole row to be…

user616128
- 133
- 1
- 5
13
votes
1 answer
Format specifier for printk loff_t types?
I am working on a Linux character device driver for a school assignment and am not sure how to print the *ppos passed into my read function which is of type loff_t.
I know I must use printk rather than the standard library printf from within the…

Anthony Jack
- 5,333
- 7
- 28
- 47
12
votes
2 answers
How to print a message in one single line in Linux kernel
I am making a simple enque/deque program in kernel. I want to print message in kernel, and this is what I got:
[18594.595747] Enqueue 3
[18594.595748] queue :
[18594.595751] 2
[18594.595751] 1
[18594.595752] 3
But I want to print this…

jijijijiji
- 1,038
- 11
- 17
12
votes
1 answer
Enlarge Linux Kernel Log Buffer more that 2M
I am in the process of collecting some sort of Linux Kernel activities. I have placed multiple printk statements with in the kernel source code and would like to monitor those during regular kernel activities. Unfortunately, I have realized that the…

ARH
- 1,355
- 3
- 18
- 32
8
votes
3 answers
Kernel module: how to get console ouput?
I am writing a kernel module, and I want to be able to print something on the console output when loading it using insmod module.ko.
I tried using
printk(KERN_EMERG "test kernel emergency\n");
but nothing appears on my console. It does however…

Jens Nyman
- 1,186
- 2
- 14
- 16
7
votes
1 answer
Why printk doesn't print message in kernel log(dmesg)
I wrote small kernel module code as mentioned below,
I am testing it in ubuntu 14.04
#include
#include
#include
#include
int init_mod_func(void)
{
printk(KERN_INFO "My module…

ART
- 1,509
- 3
- 29
- 47
6
votes
2 answers
Linux-kernel: printk from "open" syscall don't work
I have a doubt.
I opened the kernel and I changed the directory linux-3.1.1/fs/open.c
I changed the follow code in the open.c.
SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode)
{
long ret;
printk(KERN_EMERG…

UserJ
- 77
- 1
- 6
6
votes
2 answers
Setting CFLAGS for pr_debug and printk
I am trying to understand a Linux kernel module and would like to see the output of pr_debug and printk. I am using GNU Make.
I understand that to get pr_debug messages, we have to use DDEBUG.
So, how do I enable printk statements ?
Lets say…

db42
- 4,474
- 4
- 32
- 36
5
votes
3 answers
How to use a variable as a format string in printk?
I try to use the command printk.
All the examples I can find on the internet is by putting a string directly in the printk like this:
printk(KERN_INFO "Hello %s!", "World");
However, I tried to replace the "Hello %s!" using a buffer like this:
char…

Major
- 159
- 1
- 7
5
votes
2 answers
how to avoid printk log dropping in linux kernel
Is there any tips or method to avoid kernel log drop or log buffer overrun ?
I have increased the log buffer size to maximum with below code change. I'm running in high end device only. But, still when when i want to get the complete log from my…

Balamurugan A
- 1,886
- 2
- 17
- 19
4
votes
3 answers
How can I show a printk() message in a console?
The information which is printed by printk() can only be seen under the Alt+Ctrl+F1 ~ F7 consoles.
These consoles are very inconvenient for debugging since they can't roll back. I am using the KDE desktop environment and console terminal. How could…

Douglas Su
- 3,214
- 7
- 29
- 58