ia64/xen-unstable

changeset 9898:369bdfa1e04a

balloon_alloc_empty_page_range() should set the reference count
on every page structure before returning.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Apr 30 09:32:21 2006 +0100 (2006-04-30)
parents 0ee104bd6557
children 3e5a203c5489
files linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sun Apr 30 09:26:01 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sun Apr 30 09:32:21 2006 +0100
     1.3 @@ -540,6 +540,8 @@ struct page *balloon_alloc_empty_page_ra
     1.4  	unsigned long vstart, flags;
     1.5  	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
     1.6  	int ret;
     1.7 +	unsigned long i;
     1.8 +	struct page *page;
     1.9  
    1.10  	vstart = __get_free_pages(GFP_KERNEL, order);
    1.11  	if (vstart == 0)
    1.12 @@ -559,7 +561,12 @@ struct page *balloon_alloc_empty_page_ra
    1.13  
    1.14  	flush_tlb_all();
    1.15  
    1.16 -	return virt_to_page(vstart);
    1.17 +	page = virt_to_page(vstart);
    1.18 +
    1.19 +	for (i = 0; i < (1UL << order); i++)
    1.20 +		set_page_count(page + i, 1);
    1.21 +
    1.22 +	return page;
    1.23  }
    1.24  
    1.25  void balloon_dealloc_empty_page_range(
    1.26 @@ -569,8 +576,10 @@ void balloon_dealloc_empty_page_range(
    1.27  	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
    1.28  
    1.29  	balloon_lock(flags);
    1.30 -	for (i = 0; i < (1UL << order); i++)
    1.31 +	for (i = 0; i < (1UL << order); i++) {
    1.32 +		BUG_ON(page_count(page + i) != 1);
    1.33  		balloon_append(page + i);
    1.34 +	}
    1.35  	balloon_unlock(flags);
    1.36  
    1.37  	schedule_work(&balloon_worker);