Re: Page fault scalability patch V18: Drop first acquisition of ptl

Christoph Lameter
2005-03-03T06:13:59Z

On Wed, 2 Mar 2005, Andrew Morton wrote:

> > Any mmap changes requires the mmapsem.
>
> sys_remap_file_pages() will call install_page() under down_read(mmap_sem).
> It relies upon page_table_lock for pte atomicity.

This is not relevant since it only deals with file pages. ptes are only
installed atomically for anonymous memory (if CONFIG_ATOMIC_OPS
is defined).

do_file_page() does call the populate function which does the right thing
in acquiring the page_table_lock before a pte update. My patch does not
touch that.

/*
* Install a file pte to a given virtual memory address, release any
* previously existing mapping.
*/
int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long addr, unsigned long pgoff, pgprot_t prot)
{
int err = -ENOMEM;
pte_t *pte;
pmd_t *pmd;
pud_t *pud;
pgd_t *pgd;
pte_t pte_val;

pgd = pgd_offset(mm, addr);
spin_lock(&mm->page_table_lock);

pud = pud_alloc(mm, pgd, addr);
if (!pud)
goto err_unlock;

pmd = pmd_alloc(mm, pud, addr);
if (!pmd)
goto err_unlock;

pte = pte_alloc_map(mm, pmd, addr);
if (!pte)
goto err_unlock;

zap_pte(mm, vma, addr, pte);

set_pte(pte, pgoff_to_pte(pgoff));
pte_val = *pte;
pte_unmap(pte);
update_mmu_cache(vma, addr, pte_val);
spin_unlock(&mm->page_table_lock);
return 0;

err_unlock:
spin_unlock(&mm->page_table_lock);
return err;
}