For Kernel_Newbies By a Kernel_Newbie
which is the page_directory for init.) After 3 GB, a Process has the Kernel Page
Tables entries.Infact it has the same entries as that of the init process, after
3 GB. The KERNEL_PGD_PTRS entries are copied when a Process is created, from
swapper_pg_dir,by doing a memcpy(task->mm->pgd + USER_PGD_PTRS,
swapper_pg_dir + USER_PGD_PTRS , sizeof(pgd_t) * KERNEL_PGD_PTRS); Hence the
last 256 entries (The mapping for 3 GB and up) is copied directly to the process
page tables. The links to the next vm_area_struct are reflected by vm_next
entry, and the links to the inode address_spaces shared and private mapping, are
reflected by vm_next_share and vm_pprev_share entries in the vm_area_struct.The
root of the AVL tree,is represented by mmap_avl, in the mm_struct of a process,
and the head of the vm_area_structs is the mmap field in the mm_struct,and there
is also a mmap_cache for the last vma struct found. AVL trees are used to speed
up vm_area_struct searches by having the vm_area_structs represented by a
Tree,which starts builing when the mmap count reaches AVL_MIN_MAP_COUNT.You can
check out the avl_tree code in mm/mmap_avl.c, which gets included in mm/mmap.c.
Each vm area also has pointers to functions that represent the
page_faults,no_page handlers,etc. for that area, in vm_operations_struct. If the
process has a file mapped to that area,the file can be traced by vm_file field.
Across a fork,not only does the vm_area gets copied (check fork.c ),but any
inode shares,that the parent has mapped, gets linked to the child thread,and the
area is opened.(vm_ops->open ) In order to get a first hand glimpse of
vm_area management,you should have a look at mmap.c, which has important
definitions for do_mmap_pgoff, do_unmap,do_brk,insert_vm_struct, which inserts a
vm struct, sorted by address,and also builds the mmap_avl list,on reaching
AVL_MIN_MAP_COUNT,by calling build_mmap_avl.There are also other important
routines which you need to take up.(like find_vma,find_vma_prev,vmtruncate_list
in memory.c,etc.etc). The do_mmap_pgoff gets called on a mmap syscall. A mmap
system call is used to map Physical pages to the tasks virtual address
space.Supposing that a task wants to mmap LEN bytes from offset OFFSET (Page
aligned), from a File to its virtual address space,it uses a mmap system call,to
map them to its address space. The task of do_mmap in a nutshell,apart from
- « first
- ‹ previous
- of 24
- next ›
- last »