I would guess that it does so into the memory of the process from which the system call is made. However, if so, how do the rest of the processes use that space? How does the kernel know that the buffer points to a virtual address space, and not a real one? But then that would be like eating up space meant for the process for some general purpose kernel stuff, wouldn't it?
Asked
Active
Viewed 811 times
1 Answers
4
vmalloc
is a kernel allocator, it doesn’t (necessarily) relate to processes. The kernel also sees virtual memory, not linear memory, most of the time. The particularity of vmalloc
is that it only allocates contiguous virtual memory, not physical memory; kmalloc
allocates contiguous virtual and physical memory. Both return virtual addresses.
vmalloc
, unlike kmalloc
, has to allocate new page table entries (kmalloc
allocates from a pre-mapped area); they are mapped in the shared part of the page table tree, or when KPTI is enabled, in the kernel-private part of the tree.
See Linux Device Drivers chapter 8 for details.

Stephen Kitt
- 434,908
vmalloc
, unlikekmalloc
, allocates new page table entries." That's because the page table entries forkmalloc
have already been allocated. All memory accessed using software, be it from user code or kernel code, uses virtual addresses that are mapped to physical addresses using the page tables. The difference betweenkmalloc
andvmalloc
is that kmalloc'd memory is carved out of the virtual address space that contains a 1:1 mapping (with an offset) of the physical memory. Contiguous memory allocated withkmalloc
is also contiguous in the physical address space. – Johan Myréen Jun 28 '19 at 11:08