2

Different processes have different different page tables for their address spaces.

Does the Linux kernel have its own page table? If not, how are the virtual addresses of kernel translated to physical memory addresses?

In the sense that the address space of each process is divided into user space and kernel space, does the page table of each process contain the "page table" of the kernel?

Thanks.

Related Do page fault, page replacement, and paging happen to the kernel or just to processes, and to the kernel space or the user space?

3

You are correct. The VM of a process consists of the user address space and kernel address space. The kernel address space is the same across all processes but protected from access. If you've heard the 2/2 or 3/1 memory split (from x32), it was the user/kernel amount of memory in GBs. So for a 4GB address space you could (e.g.) have 3G for processes and 1G for the kernel.

I would recommend reading the "Understanding the Linux Kernel" book which will answer this and many other of your questions.

  • Here is the focus of my questions: Does the Linux kernel have its own page table? does the page table of each process contain the "page table" of the kernel, i.e. is the "page table" of the kernel redundantly repeated in the page table of every process? – Tim Oct 15 '18 at 23:02
  • @Tim AFAIK, it's one per process and includes the kernel part – V13 Oct 15 '18 at 23:31
  • Do you mean repetition? Isn't that redundant and waste space? – Tim Oct 16 '18 at 0:05
2

"Page tables" are actually a type of tree structure. E.g. see "Four-level page tables" [LWN.net, 2004].

The top level is a single page (4096 bytes). The entries which map the kernel range, are set to the same values in all processes, and hence are shared. Kernel temporary mappings happen at a lower level of the tree, so they only need to modify inside the shared kernel page tables, and they do not need to modify each process page table separately.

At least, that's my high-level overview. I don't have all the words.

The above is cross-posted from my answer here: https://unix.stackexchange.com/a/513184/29483

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.