ia64/xen-unstable

changeset 19158:97ca3400d17c

Eliminate some special page list accessors

Since page_list_move_tail(), page_list_splice_init(), and
page_list_is_eol() are only used by relinquish_memory(), and that
function can easily be changed to use more generic accessors, just
eliminate them altogether.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 04 12:01:47 2009 +0000 (2009-02-04)
parents 1b2fdbb33716
children 7a3124098155
files xen/arch/x86/domain.c xen/include/xen/mm.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Wed Feb 04 12:01:05 2009 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Wed Feb 04 12:01:47 2009 +0000
     1.3 @@ -1657,23 +1657,20 @@ int hypercall_xlat_continuation(unsigned
     1.4  static int relinquish_memory(
     1.5      struct domain *d, struct page_list_head *list, unsigned long type)
     1.6  {
     1.7 -    struct page_info  *page, *cur;
     1.8 +    struct page_info  *page;
     1.9      unsigned long     x, y;
    1.10      int               ret = 0;
    1.11  
    1.12      /* Use a recursive lock, as we may enter 'free_domheap_page'. */
    1.13      spin_lock_recursive(&d->page_alloc_lock);
    1.14  
    1.15 -    page = page_list_first(list);
    1.16 -    while ( !page_list_is_eol(page, list) )
    1.17 +    while ( (page = page_list_remove_head(list)) )
    1.18      {
    1.19          /* Grab a reference to the page so it won't disappear from under us. */
    1.20          if ( unlikely(!get_page(page, d)) )
    1.21          {
    1.22              /* Couldn't get a reference -- someone is freeing this page. */
    1.23 -            cur = page;
    1.24 -            page = page_list_next(page, list);
    1.25 -            page_list_move_tail(cur, list, &d->arch.relmem_list);
    1.26 +            page_list_add_tail(page, &d->arch.relmem_list);
    1.27              continue;
    1.28          }
    1.29  
    1.30 @@ -1685,6 +1682,7 @@ static int relinquish_memory(
    1.31              break;
    1.32          case -EAGAIN:
    1.33          case -EINTR:
    1.34 +            page_list_add(page, list);
    1.35              set_bit(_PGT_pinned, &page->u.inuse.type_info);
    1.36              put_page(page);
    1.37              goto out;
    1.38 @@ -1721,6 +1719,7 @@ static int relinquish_memory(
    1.39                  case 0:
    1.40                      break;
    1.41                  case -EINTR:
    1.42 +                    page_list_add(page, list);
    1.43                      page->u.inuse.type_info |= PGT_validated;
    1.44                      if ( x & PGT_partial )
    1.45                          put_page(page);
    1.46 @@ -1728,6 +1727,7 @@ static int relinquish_memory(
    1.47                      ret = -EAGAIN;
    1.48                      goto out;
    1.49                  case -EAGAIN:
    1.50 +                    page_list_add(page, list);
    1.51                      page->u.inuse.type_info |= PGT_partial;
    1.52                      if ( x & PGT_partial )
    1.53                          put_page(page);
    1.54 @@ -1744,11 +1744,9 @@ static int relinquish_memory(
    1.55              }
    1.56          }
    1.57  
    1.58 -        /* Follow the list chain and /then/ potentially free the page. */
    1.59 -        cur = page;
    1.60 -        page = page_list_next(page, list);
    1.61 -        page_list_move_tail(cur, list, &d->arch.relmem_list);
    1.62 -        put_page(cur);
    1.63 +        /* Put the page on the list and /then/ potentially free it. */
    1.64 +        page_list_add_tail(page, &d->arch.relmem_list);
    1.65 +        put_page(page);
    1.66  
    1.67          if ( hypercall_preempt_check() )
    1.68          {
    1.69 @@ -1757,7 +1755,12 @@ static int relinquish_memory(
    1.70          }
    1.71      }
    1.72  
    1.73 -    page_list_splice_init(&d->arch.relmem_list, list);
    1.74 +    /* list is empty at this point. */
    1.75 +    if ( !page_list_empty(&d->arch.relmem_list) )
    1.76 +    {
    1.77 +        *list = d->arch.relmem_list;
    1.78 +        INIT_PAGE_LIST_HEAD(&d->arch.relmem_list);
    1.79 +    }
    1.80  
    1.81   out:
    1.82      spin_unlock_recursive(&d->page_alloc_lock);
     2.1 --- a/xen/include/xen/mm.h	Wed Feb 04 12:01:05 2009 +0000
     2.2 +++ b/xen/include/xen/mm.h	Wed Feb 04 12:01:47 2009 +0000
     2.3 @@ -125,12 +125,6 @@ page_list_prev(const struct page_info *p
     2.4  {
     2.5      return page != head->next ? mfn_to_page(page->list.prev) : NULL;
     2.6  }
     2.7 -static inline int
     2.8 -page_list_is_eol(const struct page_info *page,
     2.9 -                 const struct page_list_head *head)
    2.10 -{
    2.11 -    return !page;
    2.12 -}
    2.13  static inline void
    2.14  page_list_add(struct page_info *page, struct page_list_head *head)
    2.15  {
    2.16 @@ -214,13 +208,6 @@ page_list_del2(struct page_info *page, s
    2.17          prev->list.next = page->list.next;
    2.18      }
    2.19  }
    2.20 -static inline void
    2.21 -page_list_move_tail(struct page_info *page, struct page_list_head *list,
    2.22 -                    struct page_list_head *head)
    2.23 -{
    2.24 -    page_list_del(page, list);
    2.25 -    page_list_add_tail(page, head);
    2.26 -}
    2.27  static inline struct page_info *
    2.28  page_list_remove_head(struct page_list_head *head)
    2.29  {
    2.30 @@ -231,19 +218,6 @@ page_list_remove_head(struct page_list_h
    2.31  
    2.32      return page;
    2.33  }
    2.34 -static inline void
    2.35 -page_list_splice_init(struct page_list_head *list, struct page_list_head *head)
    2.36 -{
    2.37 -    if ( !page_list_empty(list) )
    2.38 -    {
    2.39 -        if ( head->next )
    2.40 -            head->tail->list.next = page_to_mfn(list->next);
    2.41 -        else
    2.42 -            head->next = list->next;
    2.43 -        head->tail = list->tail;
    2.44 -        INIT_PAGE_LIST_HEAD(list);
    2.45 -    }
    2.46 -}
    2.47  
    2.48  #define page_list_for_each(pos, head) \
    2.49      for ( pos = (head)->next; pos; pos = page_list_next(pos, head) )
    2.50 @@ -266,19 +240,16 @@ page_list_splice_init(struct page_list_h
    2.51                                                      struct page_info, list)
    2.52  # define page_list_next(pg, hd)          list_entry((pg)->list.next, \
    2.53                                                      struct page_info, list)
    2.54 -# define page_list_is_eol(pg, hd)        (&(pg)->list == (hd))
    2.55  # define page_list_add(pg, hd)           list_add(&(pg)->list, hd)
    2.56  # define page_list_add_tail(pg, hd)      list_add_tail(&(pg)->list, hd)
    2.57  # define page_list_del(pg, hd)           list_del(&(pg)->list)
    2.58  # define page_list_del2(pg, hd1, hd2)    list_del(&(pg)->list)
    2.59 -# define page_list_move_tail(pg, o, n)   list_move_tail(&(pg)->list, n)
    2.60  # define page_list_remove_head(hd)       (!page_list_empty(hd) ? \
    2.61      ({ \
    2.62          struct page_info *__pg = page_list_first(hd); \
    2.63          list_del(&__pg->list); \
    2.64          __pg; \
    2.65      }) : NULL)
    2.66 -# define page_list_splice_init           list_splice_init
    2.67  # define page_list_for_each(pos, head)   list_for_each_entry(pos, head, list)
    2.68  # define page_list_for_each_safe(pos, tmp, head) \
    2.69      list_for_each_entry_safe(pos, tmp, head, list)