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
56
votes
1 answer

Difference between POSIX AIO and libaio on Linux?

What I seem to understand: POSIX AIO APIs are prototyped in and you link your program with librt(-lrt), while the libaio APIs in and your program is linked with libaio (-laio). What I can't figure out: 1.Does the kernel handle the…
itisravi
  • 3,406
  • 3
  • 23
  • 30
56
votes
3 answers

Why do some kernel programmers use goto instead of simple while loops?

When I learned C, teacher told me all day long: "Don't use goto, that's a bad habit, it's ugly, it's dangerous!" and so on. Why then, do some kernel programmers use goto, for example in this function, where it could be replaced with a simple…
musicmatze
  • 4,124
  • 7
  • 33
  • 48
55
votes
7 answers

How can I see which CPU core a thread is running in?

In Linux, supposing a thread's pid is [pid], from the directory /proc/[pid] we can get many useful information. For example, these proc files, /proc/[pid]/status,/proc/[pid]/stat and /proc/[pid]/schedstat are all useful. But how can I get the CPU…
flypen
  • 2,515
  • 4
  • 34
  • 51
55
votes
4 answers

Why do we need a swapper task in linux?

The idle task (a.k.a. swapper task) is chosen to run when no more runnable tasks in the run queue at the point of task scheduling. But what is the usage for this so special task? Another question is why i can't find this thread/process in the "ps…
jscoot
  • 2,019
  • 3
  • 24
  • 27
55
votes
3 answers

Checking if errno != EINTR: what does it mean?

I've found this piece of code used several times (also a similar one where it's used open() instead of write()). int c = write(fd, &v, sizeof(v)); if (c == -1 && errno != EINTR) { perror("Write to output file"); exit(EXIT_FAILURE); } Why it…
Robb1
  • 4,587
  • 6
  • 31
  • 60
55
votes
3 answers

what is the use of SPL (secondary program loader)

I am confused in clearing my concepts regarding these three questions why do we need a secondary program loader ? in which memory it gets loaded and relocated ? what is the difference between system internal memory and RAM ? as far as I…
theadnangondal
  • 1,546
  • 3
  • 14
  • 28
55
votes
4 answers

How to write a simple Linux device driver?

I need to write an SPI Linux character device driver for omap4 from scratch. I know some basics of writing device drivers. But, I don't know how to start writing platform specific device driver from scratch. I've written some basic char drivers, and…
Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
55
votes
3 answers

How to read, understand, analyze, and debug a Linux kernel panic?

Consider the following Linux kernel dump stack trace; e.g., you can trigger a panic from the kernel source code by calling panic("debugging a Linux kernel panic");: [<001360ac>] (unwind_backtrace+0x0/0xf8) from [<00147b7c>]…
0x90
  • 39,472
  • 36
  • 165
  • 245
55
votes
4 answers

redis bgsave failed because fork Cannot allocate memory

all: here is my server memory info with 'free -m' total used free shared buffers cached Mem: 64433 49259 15174 0 3 31 -/+ buffers/cache: 49224 15209 Swap:…
Jim Gray
  • 571
  • 1
  • 4
  • 4
54
votes
4 answers

How does Linux determine the next PID?

How does Linux determine the next PID it will use for a process? The purpose of this question is to better understand the Linux kernel. Don't be afraid to post kernel source code. If PIDs are allocated sequentially how does Linux fill in the…
rook
  • 66,304
  • 38
  • 162
  • 239
54
votes
3 answers

How to compile dts Linux device tree source files to dtb?

I have a device tree file (.dts) and I want to compile the file for my powerpc based board. How can I do it on my machine, which is not powerpc based?? Can I do it with the DTC installed on my Ubuntu system? Or will it be more like using a separate…
54
votes
11 answers

Why kernel code/thread executing in interrupt context cannot sleep?

I am reading following article by Robert Love http://www.linuxjournal.com/article/6916 that says "...Let's discuss the fact that work queues run in process context. This is in contrast to the other bottom-half mechanisms, which all run in interrupt…
Methos
  • 13,608
  • 11
  • 46
  • 49
53
votes
4 answers

What's the relationship between a Linux OS and a kernel?

I've been using Linux for several years, but never stepped beyond installing from a CD/DVD. If the app manager didn't have what I was looking for in the software, then I was a lost cause. But right now I'm trying to get a grip around what "Linux"…
Jason94
  • 13,320
  • 37
  • 106
  • 184
53
votes
10 answers

Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted software under Linux? I have read the work of van…
TH.
  • 1,738
  • 1
  • 12
  • 15
53
votes
1 answer

What is the 'asmlinkage' modifier meant for?

I have read that it is used for functions that implement system calls in Linux. For example: asmlinkage long sys_getjiffies( void ) { return (long)get_jiffies_64(); } and that it tells the compiler to pass all function arguments on the stack. But…
gjain
  • 4,468
  • 5
  • 39
  • 47