1

I'm reading "Understanding the Linux Virtual Memory Manager" by Gorman.

In Chapter 4 about Process Address Space, when VMA operations are introduced, for example create, lock and unlock, the text mentions "fix up region". What does "fix up" means specifically? Does it apply in the same way to different VMA operations?

Detailed quote:

Linux can lock pages from an address range into memory via the system call mlock() which is implemented by sys_mlock() whose call graph is shown in Figure 4.10. At a high level, the function is simple; it creates a VMA for the address range to be locked, sets the VM_LOCKED flag on it and forces all the pages to be present with make_pages_present(). A second system call mlockall() which maps to sys_mlockall() is also provided which is a simple extension to do the same work as sys_mlock() except for every VMA on the calling process. Both functions rely on the core function do_mlock() to perform the real work of finding the affected VMAs and deciding what function is needed to fix up the regions as described later.

The system calls munlock() and munlockall() provide the corollary for the locking functions and map to sys_munlock() and sys_munlockall() respectively. The functions are much simpler than the locking functions as they do not have to make numerous checks. They both rely on the same do_mmap() function to fix up the regions.

If an old area exists where the mapping is to take place, fix it up so that it is suitable for the new mapping;

The kernel version used in the book is Linux 2.4.22.

1 Answer 1

0

In this context, “fixing up” means merging or splitting the VMAs as appropriate so that they match the regions being manipulated:

  • if a region to be locked (or unlocked) is smaller than the VMA containing it, the VMA needs to be split;
  • if consecutive VMAs can be merged, they should be.

The documentation you’re reading is old, but this still applies to current kernels. Fixing up is handled by mlock_fixup, which calls vma_merge and split_vma as appropriate. See also the documentation describing the unevictable LRU infrastructure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .