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>
This commit is contained in:
Keir Fraser committed 2009-02-04 12:01:47 +00:00
1 parent 6ecbae750b
commit e0d92ea91c
2 files changed
+15 -41

No files matched your search

+15 -12
View File
@@ -1657,23 +1657,20 @@ int hypercall_xlat_continuation(unsigned int *id, unsigned int mask, ...)
static int relinquish_memory(
struct domain *d, struct page_list_head *list, unsigned long type)
{
struct page_info *page, *cur;
struct page_info *page;
unsigned long x, y;
int ret = 0;
/* Use a recursive lock, as we may enter 'free_domheap_page'. */
spin_lock_recursive(&d->page_alloc_lock);
page = page_list_first(list);
while ( !page_list_is_eol(page, list) )
while ( (page = page_list_remove_head(list)) )
{
/* Grab a reference to the page so it won't disappear from under us. */
if ( unlikely(!get_page(page, d)) )
{
/* Couldn't get a reference -- someone is freeing this page. */
cur = page;
page = page_list_next(page, list);
page_list_move_tail(cur, list, &d->arch.relmem_list);
page_list_add_tail(page, &d->arch.relmem_list);
continue;
}
@@ -1685,6 +1682,7 @@ static int relinquish_memory(
break;
case -EAGAIN:
case -EINTR:
page_list_add(page, list);
set_bit(_PGT_pinned, &page->u.inuse.type_info);
put_page(page);
goto out;
@@ -1721,6 +1719,7 @@ static int relinquish_memory(
case 0:
break;
case -EINTR:
page_list_add(page, list);
page->u.inuse.type_info |= PGT_validated;
if ( x & PGT_partial )
put_page(page);
@@ -1728,6 +1727,7 @@ static int relinquish_memory(
ret = -EAGAIN;
goto out;
case -EAGAIN:
page_list_add(page, list);
page->u.inuse.type_info |= PGT_partial;
if ( x & PGT_partial )
put_page(page);
@@ -1744,11 +1744,9 @@ static int relinquish_memory(
}
}
/* Follow the list chain and /then/ potentially free the page. */
cur = page;
page = page_list_next(page, list);
page_list_move_tail(cur, list, &d->arch.relmem_list);
put_page(cur);
/* Put the page on the list and /then/ potentially free it. */
page_list_add_tail(page, &d->arch.relmem_list);
put_page(page);
if ( hypercall_preempt_check() )
{
@@ -1757,7 +1755,12 @@ static int relinquish_memory(
}
}
page_list_splice_init(&d->arch.relmem_list, list);
/* list is empty at this point. */
if ( !page_list_empty(&d->arch.relmem_list) )
{
*list = d->arch.relmem_list;
INIT_PAGE_LIST_HEAD(&d->arch.relmem_list);
}
out:
spin_unlock_recursive(&d->page_alloc_lock);
-29
View File
@@ -125,12 +125,6 @@ page_list_prev(const struct page_info *page,
{
return page != head->next ? mfn_to_page(page->list.prev) : NULL;
}
static inline int
page_list_is_eol(const struct page_info *page,
const struct page_list_head *head)
{
return !page;
}
static inline void
page_list_add(struct page_info *page, struct page_list_head *head)
{
@@ -214,13 +208,6 @@ page_list_del2(struct page_info *page, struct page_list_head *head1,
prev->list.next = page->list.next;
}
}
static inline void
page_list_move_tail(struct page_info *page, struct page_list_head *list,
struct page_list_head *head)
{
page_list_del(page, list);
page_list_add_tail(page, head);
}
static inline struct page_info *
page_list_remove_head(struct page_list_head *head)
{
@@ -231,19 +218,6 @@ page_list_remove_head(struct page_list_head *head)
return page;
}
static inline void
page_list_splice_init(struct page_list_head *list, struct page_list_head *head)
{
if ( !page_list_empty(list) )
{
if ( head->next )
head->tail->list.next = page_to_mfn(list->next);
else
head->next = list->next;
head->tail = list->tail;
INIT_PAGE_LIST_HEAD(list);
}
}
#define page_list_for_each(pos, head) \
for ( pos = (head)->next; pos; pos = page_list_next(pos, head) )
@@ -266,19 +240,16 @@ page_list_splice_init(struct page_list_head *list, struct page_list_head *head)
struct page_info, list)
# define page_list_next(pg, hd) list_entry((pg)->list.next, \
struct page_info, list)
# define page_list_is_eol(pg, hd) (&(pg)->list == (hd))
# define page_list_add(pg, hd) list_add(&(pg)->list, hd)
# define page_list_add_tail(pg, hd) list_add_tail(&(pg)->list, hd)
# define page_list_del(pg, hd) list_del(&(pg)->list)
# define page_list_del2(pg, hd1, hd2) list_del(&(pg)->list)
# define page_list_move_tail(pg, o, n) list_move_tail(&(pg)->list, n)
# define page_list_remove_head(hd) (!page_list_empty(hd) ? \
({ \
struct page_info *__pg = page_list_first(hd); \
list_del(&__pg->list); \
__pg; \
}) : NULL)
# define page_list_splice_init list_splice_init
# define page_list_for_each(pos, head) list_for_each_entry(pos, head, list)
# define page_list_for_each_safe(pos, tmp, head) \
list_for_each_entry_safe(pos, tmp, head, list)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.