About do_brk function in linux
Posted: Tue Dec 09, 2008 8:23 pm
Hi,
I have some problems about do_brk function in linux,I think many of friends here know more about linux souce code than I do,
We all know that when the process wants to allocate heap space for users,we use the function do_brk,then do_brk will use make_pages_present,then my questions are:
1.in do_brk,if we want to use make_pages_present function,we should set the vm_lockflag,then vm_lock flag is always set in do_brk,if be set,when it is set?
2.when make_pages_present function have been used by do_brk,we know that a parameter called "write "will be passed to handle_mm_fault function by make_pages_present,in this situation,the value of the parameter "write" must be 1,so when the handle_mm_fault needs to use handle_pte_fault,the handle_pte_fault will use alloc_pages function to allocate page frame(physical memory) for the process heap space,that is to say we will build the mapping from the virtual address to physical address,then I do not understand linux has lazy-allocation feature,why in this situation it immediately allocates memory for the process ,why it does not delay the allocation until the process really accesses the page.
I have some problems about do_brk function in linux,I think many of friends here know more about linux souce code than I do,
We all know that when the process wants to allocate heap space for users,we use the function do_brk,then do_brk will use make_pages_present,then my questions are:
1.in do_brk,if we want to use make_pages_present function,we should set the vm_lockflag,then vm_lock flag is always set in do_brk,if be set,when it is set?
2.when make_pages_present function have been used by do_brk,we know that a parameter called "write "will be passed to handle_mm_fault function by make_pages_present,in this situation,the value of the parameter "write" must be 1,so when the handle_mm_fault needs to use handle_pte_fault,the handle_pte_fault will use alloc_pages function to allocate page frame(physical memory) for the process heap space,that is to say we will build the mapping from the virtual address to physical address,then I do not understand linux has lazy-allocation feature,why in this situation it immediately allocates memory for the process ,why it does not delay the allocation until the process really accesses the page.