1

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?

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.

  • 1
    Hi, I get that but which page table/directory contains the allocated pages? Only processes contain page tables/directories isn't it? – user2277550 Jun 28 at 9:58
  • See my updated answer. – Stephen Kitt Jun 28 at 10:41
  • "vmalloc, unlike kmalloc, allocates new page table entries." That's because the page table entries for kmalloc 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 between kmalloc and vmalloc 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 with kmalloc is also contiguous in the physical address space. – Johan Myréen Jun 28 at 11:08

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.