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

[Xen-ia64-devel] PATCH: pte_xchg added


Hi,

this patch adds a new function: pte_xchg to atomically exchange pte.
It also adds a few mb().

With this small patch, I was able to boot dom0 with 2 vcpus (Yesterday it 
crashed).

Tested by boot+halt of dom0+domU (each 2 cpus).

Tristan.
# HG changeset patch
# User tristan.gingold@xxxxxxxx
# Node ID fe9c44cec710d136ed42f5667311e7c90dba74ca
# Parent  99f880fea7e1c0a8de8205897d635c4a80776696
pte_xchg added to atomically exchange pte.

Signed-off-by: Tristan Gingold <tristan.gingold@xxxxxxxx>

diff -r 99f880fea7e1 -r fe9c44cec710 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c	Tue May 16 18:54:26 2006
+++ b/xen/arch/ia64/xen/domain.c	Wed May 17 03:27:14 2006
@@ -752,6 +752,7 @@
     set_pte(pte, pfn_pte(maddr >> PAGE_SHIFT,
                          __pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX)));
 
+    mb ();
     //XXX CONFIG_XEN_IA64_DOM0_VP
     //    TODO racy
     set_gpfn_from_mfn(page_to_mfn(p), mpaddr >> PAGE_SHIFT);
@@ -809,6 +810,7 @@
         set_pte(pte,
                 pfn_pte(physaddr >> PAGE_SHIFT,
                         __pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX)));
+	mb ();
     } else
         printk("%s: mpaddr %lx already mapped!\n", __func__, mpaddr);
 }
@@ -1074,13 +1076,13 @@
     struct mm_struct *mm = d->arch.mm;
     pte_t* pte;
     pte_t old_pte;
+    pte_t npte;
 
     pte = lookup_alloc_domain_pte(d, mpaddr);
 
     // update pte
-    old_pte = ptep_get_and_clear(mm, mpaddr, pte);
-    set_pte(pte, pfn_pte(mfn,
-                         __pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX)));
+    npte = pfn_pte(mfn, __pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX));
+    old_pte = ptep_xchg(mm, mpaddr, pte, npte);
     if (!pte_none(old_pte)) {
         unsigned long old_mfn;
         struct page_info* old_page;
diff -r 99f880fea7e1 -r fe9c44cec710 xen/include/asm-ia64/linux-xen/asm/pgtable.h
--- a/xen/include/asm-ia64/linux-xen/asm/pgtable.h	Tue May 16 18:54:26 2006
+++ b/xen/include/asm-ia64/linux-xen/asm/pgtable.h	Wed May 17 03:27:14 2006
@@ -397,6 +397,18 @@
 #endif
 }
 
+static inline pte_t
+ptep_xchg(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t npte)
+{
+#ifdef CONFIG_SMP
+	return __pte(xchg((long *) ptep, pte_val(npte)));
+#else
+	pte_t pte = *ptep;
+	set_pte (ptep, npte);
+	return pte;
+#endif
+}
+
 #ifndef XEN
 static inline void
 ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel


This mailing list archive is a service of Copilotco.