From: Zachary Amsden Also, setting PDPEs in PAE mode does not require atomic operations, since the PDPEs are cached by the processor, and only reloaded on an explicit or implicit reload of CR3. Since the four PDPEs must always be present in an active root, and the kernel PDPE is never updated, we are safe even from SMIs and interrupts / NMIs using task gates (which reload CR3). Actually, much of this is moot, since the user PDPEs are never updated either, and the only usage of task gates is by the doublefault handler. It appears the only place PGDs get updated in PAE mode is in init_low_mappings() / zap_low_mapping() for initial page table creation and recovery from ACPI sleep state, and these sites are safe by inspection. Getting rid of the cmpxchg8b saves code space and 720 cycles in pgd_alloc on P4. Signed-off-by: Zachary Amsden Signed-off-by: Andrew Morton --- arch/i386/mm/init.c | 2 +- arch/i386/mm/pageattr.c | 5 +++-- include/asm-i386/pgtable-3level.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff -puN arch/i386/mm/init.c~i386-use-set_pte-macros-in-a-couple-places-where-they-were-missing arch/i386/mm/init.c --- devel/arch/i386/mm/init.c~i386-use-set_pte-macros-in-a-couple-places-where-they-were-missing 2005-07-30 00:28:09.000000000 -0700 +++ devel-akpm/arch/i386/mm/init.c 2005-07-30 00:28:09.000000000 -0700 @@ -349,7 +349,7 @@ static void __init pagetable_init (void) * All user-space mappings are explicitly cleared after * SMP startup. */ - pgd_base[0] = pgd_base[USER_PTRS_PER_PGD]; + set_pgd(&pgd_base[0], pgd_base[USER_PTRS_PER_PGD]); #endif } diff -puN arch/i386/mm/pageattr.c~i386-use-set_pte-macros-in-a-couple-places-where-they-were-missing arch/i386/mm/pageattr.c --- devel/arch/i386/mm/pageattr.c~i386-use-set_pte-macros-in-a-couple-places-where-they-were-missing 2005-07-30 00:28:09.000000000 -0700 +++ devel-akpm/arch/i386/mm/pageattr.c 2005-07-30 00:28:09.000000000 -0700 @@ -12,6 +12,7 @@ #include #include #include +#include static DEFINE_SPINLOCK(cpa_lock); static struct list_head df_list = LIST_HEAD_INIT(df_list); @@ -52,8 +53,8 @@ static struct page *split_large_page(uns addr = address & LARGE_PAGE_MASK; pbase = (pte_t *)page_address(base); for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) { - pbase[i] = pfn_pte(addr >> PAGE_SHIFT, - addr == address ? prot : PAGE_KERNEL); + set_pte(&pbase[i], pfn_pte(addr >> PAGE_SHIFT, + addr == address ? prot : PAGE_KERNEL)); } return base; } diff -puN include/asm-i386/pgtable-3level.h~i386-use-set_pte-macros-in-a-couple-places-where-they-were-missing include/asm-i386/pgtable-3level.h --- devel/include/asm-i386/pgtable-3level.h~i386-use-set_pte-macros-in-a-couple-places-where-they-were-missing 2005-07-30 00:28:09.000000000 -0700 +++ devel-akpm/include/asm-i386/pgtable-3level.h 2005-07-30 00:28:09.000000000 -0700 @@ -64,7 +64,7 @@ static inline void set_pte(pte_t *ptep, #define set_pmd(pmdptr,pmdval) \ set_64bit((unsigned long long *)(pmdptr),pmd_val(pmdval)) #define set_pud(pudptr,pudval) \ - set_64bit((unsigned long long *)(pudptr),pud_val(pudval)) + (*(pudptr) = (pudval)) /* * Pentium-II erratum A13: in PAE mode we explicitly have to flush _