[patch 12/18] remap_file_pages protection support: optimize install_file_pte for MAP_POPULATE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(+)

diff -puN mm/fremap.c~rfp-linear-optim-v2 mm/fremap.c
--- linux-2.6.git/mm/fremap.c~rfp-linear-optim-v2	2005-08-25 12:50:10.000000000 +0200
+++ linux-2.6.git-paolo/mm/fremap.c	2005-08-25 12:58:29.000000000 +0200
@@ -125,6 +125,9 @@ int install_file_pte(struct mm_struct *m
 	pud_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);
 
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux