Questions tagged [linux-kernel]

This tag is for questions about the internals of the Linux kernel itself - particularly about writing code that runs within the context of the kernel (like kernel modules or drivers). Questions about writing userspace code in Linux should generally be tagged [linux] instead. Since the internals of the Linux kernel are constantly changing, it is helpful to include the precise kernel version(s) that you are interested in.

This tag is for questions about the internals of the Linux kernel itself - particularly about writing code that runs within the context of the kernel (like kernel modules or drivers).

Questions about writing userspace code in Linux should generally be tagged instead. Since the internals of the Linux kernel are constantly changing, it is helpful to include the precise kernel version(s) that you are interested in.

The kernel is a UNIX-like kernel initially created by Linus Torvalds in 1991 and now is maintained by developers around the world.

Frequently Asked Questions

Online resources

Books

Kernel source code and source code browsers

Further reading

Mailing lists

17371 questions
41
votes
6 answers

How to debug the Linux kernel with GDB and QEMU?

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the…
E-Kami
  • 2,529
  • 5
  • 30
  • 50
40
votes
1 answer

What is the difference between FUTEX_WAIT and FUTEX_WAIT_PRIVATE?

I have been tracing a process with strace and have seen entries such as: futex(0x7ffff79b3e00, FUTEX_WAKE_PRIVATE, 1) = 1 futex(0x7ffff79b3e00, FUTEX_WAIT_PRIVATE, 2, NULL) = 0…
Gabriel Southern
  • 9,602
  • 12
  • 56
  • 95
40
votes
1 answer

What do the counters in /proc/[pid]/io mean?

I'm creating a plugin for Munin to monitor stats of named processes. One of the sources of information would be /proc/[pid]/io. But I have a hard time finding out what the difference is between rchar/wchar and read_bytes/written_bytes. They are not…
Kvisle
  • 698
  • 1
  • 5
  • 12
40
votes
9 answers

Difference between physical/logical/virtual memory address

I am a little confused about the terms physical/logical/virtual addresses in an Operating System(I use Linux- open SUSE) Here is what I understand: Physical Address- When the processor is in system mode, the address used by the processor is…
gst
  • 1,251
  • 1
  • 14
  • 32
39
votes
5 answers

How to find out what Linux capabilities a process requires to work?

I am in a difficult situation where I don't know what Linux capabilities a process requires to work. What is the best way, or any way, to find out what capability is required? The only thing I can think of right now is using capsh and drop all…
rand0m
  • 903
  • 2
  • 8
  • 16
39
votes
3 answers

Is there a macro definition to check the Linux kernel version?

I'm wondering if there is a gcc macro that will tell me the Linux kernel version so I can set variable types appropriately. If not, how would I go about defining my own macro that does this?
zztops
  • 694
  • 1
  • 5
  • 11
39
votes
2 answers

How to sleep in the Linux kernel?

Can I use the msleep() function to sleep for a specified amount of time in kernel space? If so, which header files do I need to include? #include doesn't seem to be the right one. Is there perhaps a better function for this purpose?
John Roberts
  • 5,885
  • 21
  • 70
  • 124
39
votes
3 answers

Where can I find system call source code?

In Linux where can I find the source code for all system calls given that I have the source tree? Also if I were to want to look up the source code and assembly for a particular system call is there something that I can type in terminal like …
Dr.Knowitall
  • 10,080
  • 23
  • 82
  • 133
38
votes
4 answers

How does kernel get an executable binary file running under linux?

How does kernel get an executable binary file running under linux? It seems a simple question, but anyone can help me dig deep? How the file is loaded to memory and how execution code get started? Can anyone help me and tell what's happening step by…
Daniel
  • 631
  • 2
  • 7
  • 14
38
votes
2 answers

Detecting Integer Constant Expressions in Macros

There was a discussion in the Linux kernel mailing list regarding a macro that tests whether its argument is an integer constant expression and is an integer constant expression itself. One particularly clever approach that does not use builtins,…
Acorn
  • 24,970
  • 5
  • 40
  • 69
38
votes
6 answers

spin_lock_irqsave vs spin_lock_irq

On an SMP machine we must use spin_lock_irqsave and not spin_lock_irq from interrupt context. Why would we want to save the flags (which contain the IF)? Is there another interrupt routine that could interrupt us?
cojocar
  • 1,782
  • 2
  • 18
  • 22
38
votes
2 answers

good explanation of __read_mostly, __init, __exit macros

The macro expansion of __read_mostly : #define __read_mostly __attribute__((__section__(".data..read_mostly")) This one is from cache.h __init: #define __init __section(.init.text) __cold notrace from init.h __exit: #define __exit …
Aftnix
  • 4,461
  • 6
  • 26
  • 43
37
votes
4 answers

Configuring ARP age timeout

I am trying to configure the ARP age timeout. I think I should set /proc/sys/net/ipv4/neigh/default/base_reachable_time_ms to the desired timeout. But although I set this to 30000ms (30sec) it still takes close to 10mins for an entry to get removed…
Thomas
  • 489
  • 1
  • 8
  • 13
36
votes
4 answers

What is a Kernel thread?

I am just started coding of device driver and new to threading, went through many documents for getting an idea about threads. I still have some doubts. what is a kernel thread? how it differs from user thread? what is the relationship between the…
tijin
  • 707
  • 1
  • 6
  • 12
36
votes
3 answers

How to continuously monitor the directory using dnotify /inotify command

I am new to dnotify/inotify command. Can any one help me how to write a script such that it continuously monitors a directory and indicates that there is some change or modification to it.
sai sindhu
  • 1,155
  • 5
  • 20
  • 30