I'm adding a system call to Linux 6.1.9 (using user-mode Linux) for a school assignment. I would like to use printk
/pr_*
for debugging, but printk
/pr_*
prints what the previous printk
call was supposed to print. The first printk
doesn't print anything, the second prints what the first was supposed to print, the third the second, and so on.
For example, with the following syscall implementation:
#include <linux/syscalls.h>
SYSCALL_DEFINE0(my_syscall)
{
pr_alert("1");
pr_alert("2");
pr_alert("3");
return 0;
}
and the following user program:
// I use -I/path/to/my/custom/kernel/headers of course
#include <linux/unistd.h>
#include <unistd.h>
int main(void) {
syscall(__NR_my_syscall);
return 0;
}
The first run of the program prints
1
2
And all subsequent runs print
3
1
2
I have tried:
- checking
dmesg
. echo 7 > /proc/sys/kernel/printk
before running the program, even though the log level was already sufficient.
printk
returns the number of characters it was supposed to print every time, so I have no idea what could be happening!