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

Read/write files within a Linux kernel module

I know all the discussions about why one should not read/write files from kernel, instead how to use /proc or netlink to do that. I want to read/write anyway. I have also read Driving Me Nuts - Things You Never Should Do in the Kernel. However, the…
Methos
  • 13,608
  • 11
  • 46
  • 49
120
votes
3 answers

If threads share the same PID, how can they be identified?

I have a query related to the implementation of threads in Linux. Linux does not have an explicit thread support. In userspace, we might use an thread library (like NPTL) for creating threads. Now if we use NPTL it supports 1:1 mapping. The kernel…
SPSN
  • 1,411
  • 2
  • 13
  • 14
115
votes
14 answers

How to "hibernate" a process in Linux by storing its memory to disk and restoring it later?

Is it possible to 'hibernate' a process in linux? Just like 'hibernate' in laptop, I would to write all the memory used by a process to disk, free up the RAM. And then later on, I can 'resume the process', i.e, reading all the data from memory and…
hap497
  • 154,439
  • 43
  • 83
  • 99
110
votes
7 answers

Understanding container_of macro in the Linux kernel

When I was browsing the Linux kernel, I found a container_of macro which is defined as follows: #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)(…
jaeyong
  • 8,951
  • 14
  • 50
  • 63
108
votes
2 answers

What are vdso and vsyscall?

I did sudo cat /proc/1/maps -vv I am attempting to make sense of the output.I can see a lot of shared libraries being mapped to the memory mapping segment as expected. 7f3c00137000-7f3c00179000 r-xp 00000000 08:01 21233923 …
liv2hak
  • 14,472
  • 53
  • 157
  • 270
106
votes
3 answers

Use of floating point in the Linux kernel

I am reading Robert Love's "Linux Kernel Development", and I came across the following passage: No (Easy) Use of Floating Point When a user-space process uses floating-point instructions, the kernel manages the transition from integer to floating…
NPE
  • 486,780
  • 108
  • 951
  • 1,012
105
votes
3 answers

Using gdb to single-step assembly code outside specified executable causes error "cannot find bounds of current function"

I'm outside gdb's target executable and I don't even have a stack that corresponds to that target. I want to single-step anyway, so that I can verify what's going on in my assembly code, because I'm not an expert at x86 assembly. Unfortunately,…
Paul
  • 1,800
  • 2
  • 17
  • 17
104
votes
1 answer

Image vs zImage vs uImage

What is the difference between them? I know that u-boot needs a kernel in uImage format. The system I use first boots from stage 1 loader and then it calls u-boot. I want to discard u-boot and directly boot from stage 1 loader. Which type of kernel…
yildizabdullah
  • 1,895
  • 5
  • 24
  • 37
102
votes
3 answers

Context switches much slower in new linux kernels

We are looking to upgrade the OS on our servers from Ubuntu 10.04 LTS to Ubuntu 12.04 LTS. Unfortunately, it seems that the latency to run a thread that has become runnable has significantly increased from the 2.6 kernel to the 3.2 kernel. In fact…
Michael Goldshteyn
  • 71,784
  • 24
  • 131
  • 181
101
votes
8 answers

What are IN & OUT instructions in x86 used for?

I've encoutered these to instructions IN & OUT while reading "Understanding Linux Kernel" book. I've looked up reference manual. 5.1.9 I/O Instructions These instructions move data between the processor’s I/O ports and a register or…
claws
  • 52,236
  • 58
  • 146
  • 195
98
votes
6 answers

What does "make oldconfig" do exactly in the Linux kernel makefile?

Can anyone explain what the target "oldconfig" does exactly in the Linux kernel makefile? I see it referenced in some build documentation but never explained what it does exactly.
fred basset
  • 9,774
  • 28
  • 88
  • 138
98
votes
6 answers

How to avoid transparent_hugepage/defrag warning from mongodb?

I'm receiving the following warning from mongodb about THP 2015-03-06T21:01:15.526-0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2015-03-06T21:01:15.526-0800 I CONTROL [initandlisten] ** …
Frederick Zhang
  • 3,593
  • 4
  • 32
  • 54
97
votes
1 answer

what does anon-rss and total-vm mean

Recently, tomcat process on my Linux machine was killed abruptly. After investigation I found below error message in /var/log/messages file: kernel: [1799319.246494] Out of memory: Kill process 28536 (java) score 673 or sacrifice childSep kernel:…
UW20989
  • 1,157
  • 2
  • 8
  • 9
92
votes
2 answers

How can Docker run distros with different kernels?

How can docker run on a Debian host maybe an OpenSUSE in a container? It uses different kernel, with separated modules. Also older Debian versions have used older kernels, so how can run it on a kernel version 3.10+ ? Older kernels have only older…
plaidshirt
  • 5,189
  • 19
  • 91
  • 181
88
votes
4 answers

Privileged containers and capabilities

If I am running a container in privileged mode, does it have all the Kernel capabilities or do I need to add them separately?
codefx
  • 9,872
  • 16
  • 53
  • 81