When memory is allocated using kmalloc, is a virtual memory address with an already established PTE (Page Table Entry) returned?
0
votes
1
answer
104
views
When memory is allocated via **
kmalloc
** (i.e., slab cache allocation like slab_alloc_node
), it returns a virtual memory address. Presumably, when accessing this virtual address, the corresponding PTE (which translates the virtual address to a physical address) already exists, enabling address translation because kernel address don't allow page fault. Who creates this PTE, and when is it created?
I am using a 64-bit system, not a 32-bit one. In 32-bit systems, I understand that there is a “low memory” region (typically within 1GiB), and that this low memory is pre-mapped to physical memory during boot.
However, I’m curious about how this works on 64-bit systems. According to this StackOverflow post (https://stackoverflow.com/questions/30541036/will-physical-addresses-of-all-paging-structures-in-linux-be-mapped-in-the-page) , it says that on 64-bit systems,
> “all physical addresses are always mapped with a Supervisor mapping in
> the kernel half of the address space.”
, And here (https://unix.stackexchange.com/questions/527430/which-processes-page-table-does-vmalloc-allocate-new-memory-in) said
> the page table entries for kmalloc have already been allocated.
I want to verify whether this is actually true.
Here’s why I’m skeptical: suppose my machine has 128GiB of DRAM, and each PTE is 8 bytes. Then, just the page table itself would require 256MiB (128GiB/4KiB * 8Byte). But when I run numastat -m after boot, the size of the PageTable doesn’t appear to be that large. So I wonder what’s really going on.
Asked by Doodu
(3 rep)
Mar 25, 2025, 02:46 AM
Last activity: Mar 25, 2025, 09:42 AM
Last activity: Mar 25, 2025, 09:42 AM