1

It is said that Physically contiguous memory region is more efficient than virtually contiguous memory, for that Robert Love's book says that kernel don't need to set up the page table entries for physically contiguous memory.

But doesn't kernel needs the page table in all scenario ? So which page table entries it needs to create in case of virtually contiguous memory.

Rahul
  • 1,607
  • 3
  • 23
  • 41
  • Note: [`vmalloc` is faster with Kernel 5.2](https://stackoverflow.com/a/56224524/6309) (Q2 2019) – VonC May 20 '19 at 16:04

2 Answers2

2

For large blocks of physically contiguous memory, the kernel can use huge pages, i.e., much fewer page table entries.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • 1
    To add to this answer, most architectures have multiple-level page tables. Generally speaking, the more granular mapping you want, the more space you have to allocate to page tables. Naturally, large blocks of physically contiguous memory will need less page table entries to describe the mapping. – tangrs Jul 23 '14 at 14:35
  • Thanks to both of you ... but I have one tiny doubt, is it possible to change the page table size as per requirement? What I mean is, if kmalloc() is used then page table will have each entry with bigger size while in case of vmalloc() it will be smaller ? – Rahul Jul 24 '14 at 04:23
0

Virtually contiguous (vmalloc() and friends) means the kernel allocates memory based on non-contiguous page frames accessed through contiguous linear addresses. The downside is bad performance, as additional set of page tables are required. You may want to go through the data structure vmap_area and vm_struct

askb
  • 6,501
  • 30
  • 43