
From: Christoph Lameter <clameter@sgi.com>

Changelog
        * Provide atomic pte operations for x86_64

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/include/asm-x86_64/pgalloc.h |   12 ++++++++++++
 25-akpm/include/asm-x86_64/pgtable.h |    4 ++++
 2 files changed, 16 insertions(+)

diff -puN include/asm-x86_64/pgalloc.h~page-fault-scalability-patch-v11-x86_64-atomic-pte-operations include/asm-x86_64/pgalloc.h
--- 25/include/asm-x86_64/pgalloc.h~page-fault-scalability-patch-v11-x86_64-atomic-pte-operations	Thu Dec  2 12:39:49 2004
+++ 25-akpm/include/asm-x86_64/pgalloc.h	Thu Dec  2 12:40:57 2004
@@ -7,10 +7,15 @@
 #include <linux/threads.h>
 #include <linux/mm.h>
 
+#define PMD_NONE 0
+#define PGD_NONE 0
+
 #define pmd_populate_kernel(mm, pmd, pte) \
 		set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)))
 #define pgd_populate(mm, pgd, pmd) \
 		set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pmd)))
+#define pgd_test_and_populate(mm, pgd, pmd) \
+		(cmpxchg((int *)pgd, PGD_NONE, _PAGE_TABLE | __pa(pmd)) == PGD_NONE)
 #define pml4_populate(mm, pml4, pgd) \
 		set_pml4(pml4, __pml4(_PAGE_TABLE | __pa(pgd)))
 
@@ -19,6 +24,13 @@ static inline void pmd_populate(struct m
 	set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
 }
 
+static inline int
+pmd_test_and_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
+{
+	return cmpxchg((int *)pmd, PMD_NONE, _PAGE_TABLE |
+			(page_to_pfn(pte) << PAGE_SHIFT)) == PMD_NONE;
+}
+
 extern __inline__ pmd_t *get_pmd(void)
 {
 	return (pmd_t *)get_zeroed_page(GFP_KERNEL);
diff -puN include/asm-x86_64/pgtable.h~page-fault-scalability-patch-v11-x86_64-atomic-pte-operations include/asm-x86_64/pgtable.h
--- 25/include/asm-x86_64/pgtable.h~page-fault-scalability-patch-v11-x86_64-atomic-pte-operations	Thu Dec  2 12:39:49 2004
+++ 25-akpm/include/asm-x86_64/pgtable.h	Thu Dec  2 12:39:49 2004
@@ -415,6 +415,10 @@ extern int kern_addr_valid(unsigned long
 #define	kc_offset_to_vaddr(o) \
    (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o))
 
+
+#define ptep_cmpxchg(__vma,__addr,__xp,__oldval,__newval) (cmpxchg(&(__xp)->pte, pte_val(__oldval), pte_val(__newval)) == pte_val(__oldval))
+#define __HAVE_ARCH_ATOMIC_TABLE_OPS
+
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
_
