1
votes

In Linux, every process has a page table which maps user address spaces to physical page frames.

Does page table per process contain entries mapping to Kernel address space?

If yes, page tables of all processes map one Kernel image in same address. That means all of tables contains same entries for Kernel address. Is it wasteful?

2

2 Answers

2
votes

Yes, sort of. The top level page table is per-process, but it can contain a single entry (on 64-bit architectures or several on 32-bit) for the kernel address space. This entry would then point to a common "sub" page table that is shared between every process. These entries would also be marked as "global", such that the hardware preserves the virtual to physical translations in the TLB on a context switch.

Each process needs kernel space entries as kernel code may be executed at any time in any process. For example, any interrupt or system call will immediately try to access kernel addresses as it executes the appropriate handler. Without the mappings present in the current process's address space, the kernel code would not be accessible.

By having each process share a common "sub" page table for the kernel addresses, the kernel does not have to duplicate the entries in memory and waste space. And the any updates to the kernel's memory usage only requires modifying one page table and not every process.

0
votes

All user processes would have to share the same kernel so they would need part of their page tables to address the kernel space. This is done by copying kernel page table entries. So yes, each process contains entries mapping to kernel space.