remap_file_pages protection support: optimize install_file_pte for MAP_POPULATE
PATCH 12/18 remap_file_pages protection support: optimize install_file_pte for MAP_POPULATE
From: Paolo 'Blaisorblade' Giarrusso <[email protected]>
Add an optimization to install_file_pte: if the VMA is uniform (and thus we're likely called by MAP_POPULATE), and the PTE was null, it will be installed correctly if needed at fault time - we avoid thus touching the page tables, but we must still do the walk...
The PTE could have a wrong value only if we are in a private VMA, and it was a broken COW page, either installed or swapped. So, in subsequent patches we even optimize away the walk.
Signed-off-by Paolo 'Blaisorblade' Giarrusso <[email protected]>
---
linux-2.6.git-paolo/mm/fremap.c | 9 +++++++++ 1 files changed, 9 insertions(+)
mm/fremap.c renamed from mm/fremap.c~rfp-linear-optim-v2 +9 -0
@@ -125,6 +125,9 @@ int install_file_pte(struct mm_struct *mpud_t *pud;pgd_t *pgd;pte_t pte_val; +int uniform = !(vma->vm_flags & (VM_NONUNIFORM |VM_NONLINEAR )); + +BUG_ON (!uniform && !(vma->vm_flags &VM_SHARED )); pgd =pgd_offset (mm, addr);spin_lock (&mm->page_table_lock);
@@ -140,6 +143,12 @@ int install_file_pte(struct mm_struct *m pte =pte_alloc_map (mm, pmd, addr);if (!pte) goto err_unlock; +/* +* Skip uniform non-existent ptes: +*/ + err =0 ; +if (uniform &&pte_none (*pte)) + goto err_unlock;zap_pte (mm, vma, addr, pte);
_