ia64/xen-unstable

changeset 16502:8e3d42fdb8e7

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@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Dec 04 09:56:10 2007 +0000 (2007-12-04)
parents 3057f813da14
children f54b2dd57037
files xen/arch/x86/mm.c xen/include/asm-x86/mm.h
line diff
     1.1 --- a/xen/arch/x86/mm.c	Thu Nov 29 19:30:33 2007 +0000
     1.2 +++ b/xen/arch/x86/mm.c	Tue Dec 04 09:56:10 2007 +0000
     1.3 @@ -1609,6 +1609,58 @@ static int mod_l4_entry(struct domain *d
     1.4  
     1.5  #endif
     1.6  
     1.7 +void put_page(struct page_info *page)
     1.8 +{
     1.9 +    u32 nx, x, y = page->count_info;
    1.10 +
    1.11 +    do {
    1.12 +        x  = y;
    1.13 +        nx = x - 1;
    1.14 +    }
    1.15 +    while ( unlikely((y = cmpxchg(&page->count_info, x, nx)) != x) );
    1.16 +
    1.17 +    if ( unlikely((nx & PGC_count_mask) == 0) )
    1.18 +    {
    1.19 +        cleanup_page_cacheattr(page);
    1.20 +        free_domheap_page(page);
    1.21 +    }
    1.22 +}
    1.23 +
    1.24 +
    1.25 +int get_page(struct page_info *page, struct domain *domain)
    1.26 +{
    1.27 +    u32 x, nx, y = page->count_info;
    1.28 +    u32 d, nd = page->u.inuse._domain;
    1.29 +    u32 _domain = pickle_domptr(domain);
    1.30 +
    1.31 +    do {
    1.32 +        x  = y;
    1.33 +        nx = x + 1;
    1.34 +        d  = nd;
    1.35 +        if ( unlikely((x & PGC_count_mask) == 0) ||  /* Not allocated? */
    1.36 +             unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */
    1.37 +             unlikely(d != _domain) )                /* Wrong owner? */
    1.38 +        {
    1.39 +            if ( !_shadow_mode_refcounts(domain) && !domain->is_dying )
    1.40 +                gdprintk(XENLOG_INFO,
    1.41 +                         "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%"
    1.42 +                         PRtype_info "\n",
    1.43 +                         page_to_mfn(page), domain, unpickle_domptr(d),
    1.44 +                         x, page->u.inuse.type_info);
    1.45 +            return 0;
    1.46 +        }
    1.47 +        asm volatile (
    1.48 +            LOCK_PREFIX "cmpxchg8b %3"
    1.49 +            : "=d" (nd), "=a" (y), "=c" (d),
    1.50 +            "=m" (*(volatile u64 *)(&page->count_info))
    1.51 +            : "0" (d), "1" (x), "c" (d), "b" (nx) );
    1.52 +    }
    1.53 +    while ( unlikely(nd != d) || unlikely(y != x) );
    1.54 +
    1.55 +    return 1;
    1.56 +}
    1.57 +
    1.58 +
    1.59  static int alloc_page_type(struct page_info *page, unsigned long type)
    1.60  {
    1.61      struct domain *owner = page_get_owner(page);
    1.62 @@ -2839,8 +2891,9 @@ int steal_page(
    1.63      y   = page->count_info;
    1.64      do {
    1.65          x = y;
    1.66 -        if (unlikely((x & (PGC_count_mask|PGC_allocated)) !=
    1.67 -                     (1 | PGC_allocated)) || unlikely(_nd != _d)) { 
    1.68 +        if ( unlikely((x & (PGC_count_mask|PGC_allocated)) !=
    1.69 +                      (1 | PGC_allocated)) || unlikely(_nd != _d) )
    1.70 +        { 
    1.71              MEM_LOG("gnttab_transfer: Bad page %p: ed=%p(%u), sd=%p,"
    1.72                      " caf=%08x, taf=%" PRtype_info "\n", 
    1.73                      (void *) page_to_mfn(page),
    1.74 @@ -2849,7 +2902,7 @@ int steal_page(
    1.75              spin_unlock(&d->page_alloc_lock);
    1.76              return -1;
    1.77          }
    1.78 -        __asm__ __volatile__(
    1.79 +        asm volatile (
    1.80              LOCK_PREFIX "cmpxchg8b %2"
    1.81              : "=d" (_nd), "=a" (y),
    1.82              "=m" (*(volatile u64 *)(&page->count_info))
     2.1 --- a/xen/include/asm-x86/mm.h	Thu Nov 29 19:30:33 2007 +0000
     2.2 +++ b/xen/include/asm-x86/mm.h	Tue Dec 04 09:56:10 2007 +0000
     2.3 @@ -149,60 +149,10 @@ int _shadow_mode_refcounts(struct domain
     2.4  
     2.5  void cleanup_page_cacheattr(struct page_info *page);
     2.6  
     2.7 -static inline void put_page(struct page_info *page)
     2.8 -{
     2.9 -    u32 nx, x, y = page->count_info;
    2.10 -
    2.11 -    do {
    2.12 -        x  = y;
    2.13 -        nx = x - 1;
    2.14 -    }
    2.15 -    while ( unlikely((y = cmpxchg(&page->count_info, x, nx)) != x) );
    2.16 -
    2.17 -    if ( unlikely((nx & PGC_count_mask) == 0) )
    2.18 -    {
    2.19 -        cleanup_page_cacheattr(page);
    2.20 -        free_domheap_page(page);
    2.21 -    }
    2.22 -}
    2.23 -
    2.24 -
    2.25 -static inline int get_page(struct page_info *page,
    2.26 -                           struct domain *domain)
    2.27 -{
    2.28 -    u32 x, nx, y = page->count_info;
    2.29 -    u32 d, nd = page->u.inuse._domain;
    2.30 -    u32 _domain = pickle_domptr(domain);
    2.31 -
    2.32 -    do {
    2.33 -        x  = y;
    2.34 -        nx = x + 1;
    2.35 -        d  = nd;
    2.36 -        if ( unlikely((x & PGC_count_mask) == 0) ||  /* Not allocated? */
    2.37 -             unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */
    2.38 -             unlikely(d != _domain) )                /* Wrong owner? */
    2.39 -        {
    2.40 -            if ( !_shadow_mode_refcounts(domain) )
    2.41 -                gdprintk(XENLOG_INFO,
    2.42 -                        "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%"
    2.43 -                        PRtype_info "\n",
    2.44 -                        page_to_mfn(page), domain, unpickle_domptr(d),
    2.45 -                        x, page->u.inuse.type_info);
    2.46 -            return 0;
    2.47 -        }
    2.48 -        __asm__ __volatile__(
    2.49 -            LOCK_PREFIX "cmpxchg8b %3"
    2.50 -            : "=d" (nd), "=a" (y), "=c" (d),
    2.51 -              "=m" (*(volatile u64 *)(&page->count_info))
    2.52 -            : "0" (d), "1" (x), "c" (d), "b" (nx) );
    2.53 -    }
    2.54 -    while ( unlikely(nd != d) || unlikely(y != x) );
    2.55 -
    2.56 -    return 1;
    2.57 -}
    2.58 -
    2.59  int is_iomem_page(unsigned long mfn);
    2.60  
    2.61 +void put_page(struct page_info *page);
    2.62 +int  get_page(struct page_info *page, struct domain *domain);
    2.63  void put_page_type(struct page_info *page);
    2.64  int  get_page_type(struct page_info *page, unsigned long type);
    2.65  int  get_page_from_l1e(l1_pgentry_t l1e, struct domain *d);