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
2
votes
1 answer
How to pass application printf messages to /var/log/messages
I want to pass application printf log messages to the /var/log/messages.
Because kernel debug messages can be visible to /var/log/messages.But i am not getting how to pass application printf log messages to the /var/log/messages.
Can anyone please…

Deepak Singh
- 1,079
- 2
- 11
- 15
2
votes
1 answer
How can I send printk message into ttyS0?
I'm trying to debug my PC using laptop and serial port.
So, I wanna get some printk log from tty connected laptop.
I referred this sites (https://help.ubuntu.com/community/SerialConsoleHowto), and I already set all of console setup on my laptop and…

Hyukjoong Kim
- 81
- 5
2
votes
1 answer
Is it safe to call printk inside spin_lock_irqsave?
I've written a code something like this:
It is in non-interrupt context:
spin_lock_irqsave(&lock, flags);
printk("some message blah...\n");
spin_unlock_irqrestore(&lock, flags);
I am running this code and "looks" safe because I don't see any…

jaeyong
- 8,951
- 14
- 50
- 63
2
votes
0 answers
printk/pr_info still not printing to kernel buffer
I'm trying to debug why a change I made isn't working as it should. It's quite strange because there's two different builds of this driver running simultaneously (mpt2sas and mpt3sas) and the change is such that it's identical for both. The change…

Andrew Falanga
- 2,274
- 4
- 26
- 51
2
votes
0 answers
Printk print twice: how to supress the one with prefix information?
I am trying the linux device programming but run into a strange problem. For all of my printk lines, it will always display twice on the console.
For example, here is my helloworld driver program:
#include
#include…

Shawshank
- 61
- 3
2
votes
1 answer
Making my module's printk's print to my own logfile
I'm doing some Linux module programming. I typically printk little error messages and stuff for debugging - I then exit out of my module and use "dmesg" to see what's up.
That method of debugging is no longer sufficient. I would like to pipe my…

PinkElephantsOnParade
- 6,452
- 12
- 53
- 91
1
vote
0 answers
OpenvSwitch building, installation and testing problem
I am trying to install OpenvSwitch on Ubuntu 18.04.
I have two kernels version which are 5.11.0-27-generic and 5.4.0-42-generic.
I set ./configure to build 5.4.0-42-generic version.
Then I use command 'make modules_install', and I get the following…

MrQ.
- 21
- 1
- 3
1
vote
0 answers
how to write logs to specific file from kernel space?
I have a kernel module that uses printk() for debugging. printk() logs to /var/log/messages. /var/log/messages contains information of other modules too. I am trying to implement dynamic tracing for my module. My plan is to use ioctl calls to set…

vek
- 11
- 2
1
vote
1 answer
printk implementation in linux
I want to know how printk passes the data from the kernel space to the user space. I have heard of relayfs, which provides that the efficient and unified file-system to transfer huge data from the kernel space to user space, whether printk also uses…

pradeepchhetri
- 2,899
- 6
- 28
- 50
1
vote
1 answer
copy_to_user() keeps printing message infinitely
I am learning the "Linux device drivers". I created a character device named char_device. When I read the data from the device it keeps printing the message to terminal infinitely crashing the machine.
Source code of the read operation in the…

Vivek
- 455
- 6
- 14
1
vote
1 answer
printk() messages not appearing in console
So I'm trying to learn to write Linux modules and right now I'm experimenting with a basic "Hello World" module:
#include
#include
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void){
printk(KERN_ALERT…

exliontamer
- 95
- 12
1
vote
1 answer
How to avoid quotes ("...") in shortcut-ed printk Macros inside Linux Kernel Modules
I have created a set of shortcut Macros for Linux Kernel printk to prefix with the module name and to have a set of aliases for severity.
#define _pp(severity, format, args...) \
printk(severity "%s: " #format "\n", THIS_MODULE->name,…

Thomas Piekarski
- 126
- 3
- 9
1
vote
2 answers
How to find which function prints printk statement?
Is it a way to find in which function printk was executed?
I know that I can add __function__ to my printk to get this information, but I'm working with big project and it's kinda impossible to add this to all printk manually.
Maybe I should add…

ivoriik
- 155
- 1
- 11
1
vote
2 answers
undefined reference to `printk'
I want to use printk function in my userspace code, but I don't want to write kernel module. Is it any possibility to do that?
I tried use linux/kernel.h header and linux/module.h but it doesn't work
printk("<1>some text");

user3272
- 103
- 1
- 9
1
vote
1 answer
What is the loglevel for : printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
In the kernel function call
printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
No kernel log-level is mentioned. Then what will be the log level that will be taken by deafult?

nitin_cherian
- 6,405
- 21
- 76
- 127