7.2. The Memory Descriptor
All information related to the process address space is included in a table referenced by the mm field of the process descriptor. This table is a structure of type mm_struct as follows:
struct mm_struct {
struct vm_area_struct *mmap, *mmap_avl, *mmap_cache;
pgd_t * pgd;
atomic_t count;
int map_count;
struct semaphore mmap_sem;
unsigned long context;
unsigned long start_code, end_code, start_data, end_data;
unsigned long start_brk, brk, start_stack;
unsigned long arg_start, arg_end, env_start, env_end;
unsigned long rss, total_vm, locked_vm;
unsigned long def_flags;
unsigned long cpu_vm_mask;
unsigned long swap_cnt;
unsigned long swap_address;
void * segments;
};
For the present discussion, the most important fields are:
pgd and segments
Point, respectively, to the Page Global Directory and Local Descriptor Table of the process.
rss
Specifies the number of page frames allocated to the process.
total_vm
Denotes the size of the process address space expressed as a number of pages.
locked_vm
Counts the number of "locked" pages, that is, pages that cannot be swapped out (see Chapter 16).
count
Denotes the number of processes that share the same struct mm_struct descriptor. If count is greater than 1, the processes are lightweight processes sharing the same address space, that is, using the same memory descriptor.
The mm_alloc( ) function is invoked to get a new memory descriptor. Since these descriptors are stored in a slab allocator cache, mm_alloc( ) ...