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
6
votes
2 answers

Does ftrace allow capture of system call arguments to the Linux kernel, or only function names?

The goal is to examine arguments passed to specific system calls (e.g. exec, open, etc.) by any process. From the official documentation, no capability to log function arguments is described (looked mostly at the "function" tracer, as I don't need…
MaxVT
  • 12,989
  • 6
  • 36
  • 50
6
votes
1 answer

Why compile Android kernel module with -fno-pic?

I often read that Android kernel modules have to be compiled with -fno-pic to work. Is this specific to the ARM architecture, or why don't/(when do) kernel modules for x86 need to be compiled with that flag?
jckuester
  • 277
  • 1
  • 5
  • 15
6
votes
1 answer

How linux kernel get data from the Device tree?

I am a beginner to the Linux Kernel. In my knowledge, in the older versions of the Kernel there was a board specific file, in which all the devices were registered (by using some API s like platform_get_register, etc). And in newer versions of the…
Vineesh Vijayan
  • 313
  • 1
  • 5
  • 13
6
votes
1 answer

Linux input device events, how to retrieve initial state

I am using the gpio-keys device driver to handle some buttons in an embedded device running Linux. Applications in user space can just open /dev/input/eventX and read input events in a loop. My question is how to get the initial states of the…
Grodriguez
  • 21,501
  • 10
  • 63
  • 107
6
votes
2 answers

Seq-locks vs RCU vs Per-CPU use cases

I am trying to understand different use cases for some of the kernel synchronization mechanisms (sequential locks vs RCU (Read-Copy-Update) vs Per-CPU locks) are recommended to be used in writing your device driver or kernel module. Any examples…
Greg Petr
  • 1,099
  • 2
  • 11
  • 18
6
votes
2 answers

irqs_disabled() vs in_interrupt() in linux

What is the difference between these two functions in Linux. I know that irqs_disabled() will return whether irqs are disabled or not and in_interrupt() will return whether you are in interrupt context or not. By default if you are in the interrupt…
Venkatesh
  • 157
  • 1
  • 10
6
votes
1 answer

Difference between spi_driver.id_table and spi_driver.driver.of_match_table

I'm currently trying to understand how linux drivers work. As far as I know, A driver's probe/init function is called when the kernel parses the corresponding .compatible string in the device tree. However, in the arizona-spi driver it looks like…
JohnnyVang
  • 113
  • 2
  • 8
6
votes
1 answer

Why memory usage is more than physical RAM in Linux?

I am working on an embedded system with 512MB of RAM and enough swap memory to support the application. From the kernel, I have restricted the RAM size from the kernel cmd argument to 130MB. And disabled the swap using swapoff -a. I also disabled…
jsaji
  • 900
  • 1
  • 15
  • 31
6
votes
3 answers

Linux OOM Killer and Java Process

I am often facing issue in our production environment of the Tomcat process getting killed by Linux OOM. Checking /var/log/messages it says java not tainted and java invoked OOM killer. -Xms20480m -Xmx20480m on a 32 GB box. I see below crash - Is…
Novice User
  • 3,552
  • 6
  • 31
  • 56
6
votes
1 answer

libpcap or PF_PACKET?

I understand this question has been discussed many times: Should I use libpcap or PF_PACKET (the data link socket) to capture packets? Based on my research, libpcap is suggested over PF_PACKET almost everywhere, mainly due to its…
user2975098
  • 115
  • 1
  • 7
6
votes
7 answers

How do I benchmark or trace a specific function in the Linux Kernel?

How do I use ftrace() (or anything else) to trace a specific, user-defined function in the Linux kernel? I'm trying to create and run some microbenchmarks, so I'd like to have the time it takes certain functions to run. I've read through (at least…
Ricky Mutschlechner
  • 4,291
  • 2
  • 31
  • 36
6
votes
3 answers

Linux Kernel - Where in the kernel are blocks of data physically written to specific disk partitions?

I'm modifying the Linux kernel and am trying to find where in the kernel source blocks of data are physically written to disk partitions such as ubd0. Where does this occur in kernel source? The actual physical write call? I cannot find this.…
SpdStr
  • 61
  • 2
6
votes
1 answer

Purpose of `#ifdef MODULE` around module_exit()?

I am currently looking through the code of a "third-party" driver in an attempt to figure out/learn how it functions. I've had a look at sites such as this one, so I sort of understand how the basic premise works, but I don't understand the purpose…
6
votes
2 answers

File in which the data structure for Global Descriptor and Local Descriptor table is defined?

I am reading Understanding Linux Kernel, and in it I read about the Global Descriptor table and the Local Descriptor Table. In which source file(s)(of linux kernel) the data structure for GDT and LDT are defined?
user3686233
  • 109
  • 1
  • 1
  • 6
6
votes
3 answers

How to export a struct between two kernel modules using EXPORT_SYMBOL or equivalent?

I have a kernel module which has a structure like this: struct test { int a; int b; ..... } I have created an array of instances of this struct as: struct test foo[8]; I want to export this structure or the array "foo" using…
iqstatic
  • 2,322
  • 3
  • 21
  • 39