When we malloc memory, only virtual memory is available, and it actually pointed to zero-page. The real physical memory will be allocated when we try to write to the malloced memory, at this moment, there will be copy-on-wright that copy zeros from zero-page to physical memory which mapped by page-fault. My problem is, how/where zero-fill-on demand is implemented in linux source code, I want to disable this functionality to do some test. I guess it may happened in page-fault procedure, rather than brk() or mmap().
Similar topics related to zero-fill-on-demand. ZFOD and COW.
prep_new_page()
inmm/page_alloc.c
. If you comment out the (conditional) call toprep_zero_page()
then the pages should remain uninitialized. – Tableaufree_list
, if so, if I can clean pages before they are put into free_list, and then disableprep_zero_page()
. – Adenosine