The patch titled paravirt: optimize ptep establish for pae has been added to the -mm tree. Its filename is paravirt-optimize-ptep-establish-for-pae.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: paravirt: optimize ptep establish for pae From: Zachary Amsden <zach@xxxxxxxxxx> The ptep_establish macro is only used on user-level PTEs, for P->P mapping changes. Since these always happen under protection of the pagetable lock, the strong synchronization of a 64-bit cmpxchg is not needed, in fact, not even a lock prefix needs to be used. We can simply instead clear the P-bit, followed by a normal set. The write ordering is still important to avoid the possibility of the TLB snooping a partially written PTE and getting a bad mapping installed. Signed-off-by: Zachary Amsden <zach@xxxxxxxxxx> Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx> Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- include/asm-i386/pgtable-2level.h | 1 + include/asm-i386/pgtable-3level.h | 15 +++++++++++++++ include/asm-i386/pgtable.h | 11 +++++++++++ 3 files changed, 27 insertions(+) diff -puN include/asm-i386/pgtable-2level.h~paravirt-optimize-ptep-establish-for-pae include/asm-i386/pgtable-2level.h --- a/include/asm-i386/pgtable-2level.h~paravirt-optimize-ptep-establish-for-pae +++ a/include/asm-i386/pgtable-2level.h @@ -16,6 +16,7 @@ #define set_pte(pteptr, pteval) (*(pteptr) = pteval) #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval) +#define set_pte_present(mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval) #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval)) #define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) diff -puN include/asm-i386/pgtable-3level.h~paravirt-optimize-ptep-establish-for-pae include/asm-i386/pgtable-3level.h --- a/include/asm-i386/pgtable-3level.h~paravirt-optimize-ptep-establish-for-pae +++ a/include/asm-i386/pgtable-3level.h @@ -58,6 +58,21 @@ static inline void set_pte(pte_t *ptep, } #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) +/* + * Since this is only called on user PTEs, and the page fault handler + * must handle the already racy situation of simultaneous page faults, + * we are justified in merely clearing the PTE present bit, followed + * by a set. The ordering here is important. + */ +static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) +{ + ptep->pte_low = 0; + smp_wmb(); + ptep->pte_high = pte.pte_high; + smp_wmb(); + ptep->pte_low = pte.pte_low; +} + #define __HAVE_ARCH_SET_PTE_ATOMIC #define set_pte_atomic(pteptr,pteval) \ set_64bit((unsigned long long *)(pteptr),pte_val(pteval)) diff -puN include/asm-i386/pgtable.h~paravirt-optimize-ptep-establish-for-pae include/asm-i386/pgtable.h --- a/include/asm-i386/pgtable.h~paravirt-optimize-ptep-establish-for-pae +++ a/include/asm-i386/pgtable.h @@ -269,6 +269,17 @@ do { \ #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG +/* + * Rules for using ptep_establish: the pte MUST be a user pte, and + * must be a present->present transition. + */ +#define __HAVE_ARCH_PTEP_ESTABLISH +#define ptep_establish(vma, address, ptep, pteval) \ +do { \ + set_pte_present((vma)->vm_mm, address, ptep, pteval); \ + flush_tlb_page(vma, address); \ +} while (0) + #define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH #define ptep_clear_flush_dirty(vma, address, ptep) \ ({ \ _ Patches currently in -mm which might be from zach@xxxxxxxxxx are split-i386-and-x86_64-ptraceh.patch uml-use-ptrace-abih-instead-of-ptraceh.patch x86-allow-a-kernel-to-not-be-in-ring-0.patch x86-allow-a-kernel-to-not-be-in-ring-0-tidy.patch x86-add-a-bootparameter-to-reserve-high-linear-address-space.patch x86-trivial-pgtableh-__assembly__-move.patch x86-trivial-move-of-__have-macros-in-i386-pagetable-headers.patch x86-trivial-move-of-ptep_set_access_flags.patch x86-remove-unused-include-from-efi_stubs.patch paravirt-remove-read-hazard-from-cow.patch paravirt-pte-clear-not-present.patch paravirt-lazy-mmu-mode-hooks.patch paravirt-combine-flush-accessed-dirty.patch paravirt-kpte-flush.patch paravirt-optimize-ptep-establish-for-pae.patch paravirt-remove-set-pte-atomic.patch paravirt-pae-compile-fix.patch paravirt-update-pte-hook.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html