Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 4: Virtual Process Memory


vm_ area_structinstance. Recall, however, that it is in a union with avm_set. This allows for associating
a list ofvm_sets(andthusvm_area_structs) with a prio tree node. Figure 4-9 illustrates the situation in
memory.


Process 1 Process 2

Process 3

File
7101230

Figure 4-8: Multiple processes can map identical or
overlapping regions of a file into their virtual address
space.

prio_tree_root

vm_set
vm_set vm_set vm_set

raw_prio_
tree_node

raw_prio_tree_node

Figure 4-9: Interrelation of data structures in the
management of shared identical mappings.

When an interval is inserted into the prio tree, the kernel proceeds as follows:


❑ When thevm_area_structinstance is linked into the prio tree as a node,prio_tree_nodeis
used to establish the necessary associations. To check whether there is avm_area_structin
the tree, the kernel exploits the fact that theparentelement ofvm_setcoincides with the last
structure element ofprio_tree_node— the data structures are coordinated accordingly. Since
parentis not used withinvm_set, the kernel can useparent != NULLto check whether the cur-
rentvm_area_structmember is in a tree.
The definition ofprio_tree_nodealso ensures that theheadelement ofvmsetdoesnotoverlap
withprio_tree_nodeso that both can be used together, although they are actually combined in
aunion.
The kernel therefore usesvm_set.headto point to the first element on the list ofvm_area_struct
instances that belong to a shared mapping.
❑ If the above list of shared mappings contains avm_area_struct,vm_set.listis used as the list
head to list all regions affected.

Section 4.5.3 discusses the technical details of how the kernel goes about inserting new regions.

Free download pdf