Why a locked page must be copied in COW?
Parmenides
mobile.parmenides at gmail.com
Sat Sep 15 10:51:05 EDT 2012
Hi,
The do_wp_page() implements the Copy-On-write approach. I have no idea
about its doing concerning locked pages.
static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
unsigned long address, pte_t *page_table, pmd_t *pmd, pte_t pte)
{
old_page = pfn_to_page(pfn); <-- old_page is in quesiton.
... ... ...
if (!TestSetPageLocked(old_page)) { <-- We test the 'PG_locked'
flag of old_page.
If it is not set, we can further check whether
the page should be copied.
int reuse = can_share_swap_page(old_page);
unlock_page(old_page);
if (reuse) { <-- If only one
process owns old_page, we should copy it.
flush_cache_page(vma, address);
entry = maybe_mkwrite(pte_mkyoung(pte_mkdirty(pte)),
vma);
ptep_set_access_flags(vma, address, page_table, entry, 1);
update_mmu_cache(vma, address, entry);
pte_unmap(page_table);
spin_unlock(&mm->page_table_lock);
return VM_FAULT_MINOR;
}
}
pte_unmap(page_table);
/*
* Ok, we need to copy. Oh, well..
*/ <-- At this
point, we should copy old_page.
... ... ...
}
In conclusion, if old_page is locked or it is not locked and two or
more processes own old_page, we should copy it. I don't understand
why a locked page must be copied regardless of how many processes own
it. Why do we give a locked page a special consideration?
More information about the Kernelnewbies
mailing list