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

[Xen-changelog] [xen-unstable] x86: Move get_page/put_page out of header file, and only print on



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1196762170 0
# Node ID 8e3d42fdb8e784b947fbd998d9a6df0ebf771718
# Parent  3057f813da143f0dd6086129b5ce65a97c85e146
x86: Move get_page/put_page out of header file, and only print on
get_page() failure if the domain is not dying.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/mm.c        |   59 ++++++++++++++++++++++++++++++++++++++++++++---
 xen/include/asm-x86/mm.h |   54 +------------------------------------------
 2 files changed, 58 insertions(+), 55 deletions(-)

diff -r 3057f813da14 -r 8e3d42fdb8e7 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Thu Nov 29 19:30:33 2007 +0000
+++ b/xen/arch/x86/mm.c Tue Dec 04 09:56:10 2007 +0000
@@ -1609,6 +1609,58 @@ static int mod_l4_entry(struct domain *d
 
 #endif
 
+void put_page(struct page_info *page)
+{
+    u32 nx, x, y = page->count_info;
+
+    do {
+        x  = y;
+        nx = x - 1;
+    }
+    while ( unlikely((y = cmpxchg(&page->count_info, x, nx)) != x) );
+
+    if ( unlikely((nx & PGC_count_mask) == 0) )
+    {
+        cleanup_page_cacheattr(page);
+        free_domheap_page(page);
+    }
+}
+
+
+int get_page(struct page_info *page, struct domain *domain)
+{
+    u32 x, nx, y = page->count_info;
+    u32 d, nd = page->u.inuse._domain;
+    u32 _domain = pickle_domptr(domain);
+
+    do {
+        x  = y;
+        nx = x + 1;
+        d  = nd;
+        if ( unlikely((x & PGC_count_mask) == 0) ||  /* Not allocated? */
+             unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */
+             unlikely(d != _domain) )                /* Wrong owner? */
+        {
+            if ( !_shadow_mode_refcounts(domain) && !domain->is_dying )
+                gdprintk(XENLOG_INFO,
+                         "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%"
+                         PRtype_info "\n",
+                         page_to_mfn(page), domain, unpickle_domptr(d),
+                         x, page->u.inuse.type_info);
+            return 0;
+        }
+        asm volatile (
+            LOCK_PREFIX "cmpxchg8b %3"
+            : "=d" (nd), "=a" (y), "=c" (d),
+            "=m" (*(volatile u64 *)(&page->count_info))
+            : "0" (d), "1" (x), "c" (d), "b" (nx) );
+    }
+    while ( unlikely(nd != d) || unlikely(y != x) );
+
+    return 1;
+}
+
+
 static int alloc_page_type(struct page_info *page, unsigned long type)
 {
     struct domain *owner = page_get_owner(page);
@@ -2839,8 +2891,9 @@ int steal_page(
     y   = page->count_info;
     do {
         x = y;
-        if (unlikely((x & (PGC_count_mask|PGC_allocated)) !=
-                     (1 | PGC_allocated)) || unlikely(_nd != _d)) { 
+        if ( unlikely((x & (PGC_count_mask|PGC_allocated)) !=
+                      (1 | PGC_allocated)) || unlikely(_nd != _d) )
+        { 
             MEM_LOG("gnttab_transfer: Bad page %p: ed=%p(%u), sd=%p,"
                     " caf=%08x, taf=%" PRtype_info "\n", 
                     (void *) page_to_mfn(page),
@@ -2849,7 +2902,7 @@ int steal_page(
             spin_unlock(&d->page_alloc_lock);
             return -1;
         }
-        __asm__ __volatile__(
+        asm volatile (
             LOCK_PREFIX "cmpxchg8b %2"
             : "=d" (_nd), "=a" (y),
             "=m" (*(volatile u64 *)(&page->count_info))
diff -r 3057f813da14 -r 8e3d42fdb8e7 xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h  Thu Nov 29 19:30:33 2007 +0000
+++ b/xen/include/asm-x86/mm.h  Tue Dec 04 09:56:10 2007 +0000
@@ -149,60 +149,10 @@ int _shadow_mode_refcounts(struct domain
 
 void cleanup_page_cacheattr(struct page_info *page);
 
-static inline void put_page(struct page_info *page)
-{
-    u32 nx, x, y = page->count_info;
-
-    do {
-        x  = y;
-        nx = x - 1;
-    }
-    while ( unlikely((y = cmpxchg(&page->count_info, x, nx)) != x) );
-
-    if ( unlikely((nx & PGC_count_mask) == 0) )
-    {
-        cleanup_page_cacheattr(page);
-        free_domheap_page(page);
-    }
-}
-
-
-static inline int get_page(struct page_info *page,
-                           struct domain *domain)
-{
-    u32 x, nx, y = page->count_info;
-    u32 d, nd = page->u.inuse._domain;
-    u32 _domain = pickle_domptr(domain);
-
-    do {
-        x  = y;
-        nx = x + 1;
-        d  = nd;
-        if ( unlikely((x & PGC_count_mask) == 0) ||  /* Not allocated? */
-             unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */
-             unlikely(d != _domain) )                /* Wrong owner? */
-        {
-            if ( !_shadow_mode_refcounts(domain) )
-                gdprintk(XENLOG_INFO,
-                        "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%"
-                        PRtype_info "\n",
-                        page_to_mfn(page), domain, unpickle_domptr(d),
-                        x, page->u.inuse.type_info);
-            return 0;
-        }
-        __asm__ __volatile__(
-            LOCK_PREFIX "cmpxchg8b %3"
-            : "=d" (nd), "=a" (y), "=c" (d),
-              "=m" (*(volatile u64 *)(&page->count_info))
-            : "0" (d), "1" (x), "c" (d), "b" (nx) );
-    }
-    while ( unlikely(nd != d) || unlikely(y != x) );
-
-    return 1;
-}
-
 int is_iomem_page(unsigned long mfn);
 
+void put_page(struct page_info *page);
+int  get_page(struct page_info *page, struct domain *domain);
 void put_page_type(struct page_info *page);
 int  get_page_type(struct page_info *page, unsigned long type);
 int  get_page_from_l1e(l1_pgentry_t l1e, struct domain *d);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.