ia64/linux-2.6.18-xen.hg

changeset 748:39a8680e7a70

linux/x86: revert the effect of xen_limit_pages_to_max_mfn()

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Nov 28 13:30:58 2008 +0000 (2008-11-28)
parents d545a95fca73
children 2892ca2b9c17
files arch/i386/mm/hypervisor.c arch/i386/mm/pgtable-xen.c arch/x86_64/mm/pageattr-xen.c drivers/xen/core/gnttab.c drivers/xen/netback/netback.c include/linux/page-flags.h mm/page_alloc.c
line diff
     1.1 --- a/arch/i386/mm/hypervisor.c	Fri Nov 28 13:30:27 2008 +0000
     1.2 +++ b/arch/i386/mm/hypervisor.c	Fri Nov 28 13:30:58 2008 +0000
     1.3 @@ -374,6 +374,15 @@ void xen_destroy_contiguous_region(unsig
     1.4  }
     1.5  EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
     1.6  
     1.7 +static void undo_limit_pages(struct page *pages, unsigned int order)
     1.8 +{
     1.9 +	BUG_ON(xen_feature(XENFEAT_auto_translated_physmap));
    1.10 +	BUG_ON(order > MAX_CONTIG_ORDER);
    1.11 +	xen_limit_pages_to_max_mfn(pages, order, 0);
    1.12 +	ClearPageForeign(pages);
    1.13 +	__free_pages(pages, order);
    1.14 +}
    1.15 +
    1.16  int xen_limit_pages_to_max_mfn(
    1.17  	struct page *pages, unsigned int order, unsigned int address_bits)
    1.18  {
    1.19 @@ -402,16 +411,28 @@ int xen_limit_pages_to_max_mfn(
    1.20  	if (unlikely(order > MAX_CONTIG_ORDER))
    1.21  		return -ENOMEM;
    1.22  
    1.23 -	bitmap_zero(limit_map, 1U << order);
    1.24 +	if (address_bits) {
    1.25 +		if (address_bits < PAGE_SHIFT)
    1.26 +			return -EINVAL;
    1.27 +		bitmap_zero(limit_map, 1U << order);
    1.28 +	} else if (order) {
    1.29 +		BUILD_BUG_ON(sizeof(pages->index) != sizeof(*limit_map));
    1.30 +		for (i = 0; i < BITS_TO_LONGS(1U << order); ++i)
    1.31 +			limit_map[i] = pages[i + 1].index;
    1.32 +	} else
    1.33 +		__set_bit(0, limit_map);
    1.34 +
    1.35  	set_xen_guest_handle(exchange.in.extent_start, in_frames);
    1.36  	set_xen_guest_handle(exchange.out.extent_start, out_frames);
    1.37  
    1.38  	/* 0. Scrub the pages. */
    1.39  	for (i = 0, n = 0; i < 1U<<order ; i++) {
    1.40  		page = &pages[i];
    1.41 -		if (!(pfn_to_mfn(page_to_pfn(page)) >> (address_bits - PAGE_SHIFT)))
    1.42 -			continue;
    1.43 -		__set_bit(i, limit_map);
    1.44 +		if (address_bits) {
    1.45 +			if (!(pfn_to_mfn(page_to_pfn(page)) >> (address_bits - PAGE_SHIFT)))
    1.46 +				continue;
    1.47 +			__set_bit(i, limit_map);
    1.48 +		}
    1.49  
    1.50  		if (!PageHighMem(page))
    1.51  			scrub_pages(page_address(page), 1);
    1.52 @@ -497,7 +518,19 @@ int xen_limit_pages_to_max_mfn(
    1.53  
    1.54  	balloon_unlock(flags);
    1.55  
    1.56 -	return success ? 0 : -ENOMEM;
    1.57 +	if (!success)
    1.58 +		return -ENOMEM;
    1.59 +
    1.60 +	if (address_bits) {
    1.61 +		if (order) {
    1.62 +			BUILD_BUG_ON(sizeof(*limit_map) != sizeof(pages->index));
    1.63 +			for (i = 0; i < BITS_TO_LONGS(1U << order); ++i)
    1.64 +				pages[i + 1].index = limit_map[i];
    1.65 +		}
    1.66 +		SetPageForeign(pages, undo_limit_pages);
    1.67 +	}
    1.68 +
    1.69 +	return 0;
    1.70  }
    1.71  EXPORT_SYMBOL_GPL(xen_limit_pages_to_max_mfn);
    1.72  
     2.1 --- a/arch/i386/mm/pgtable-xen.c	Fri Nov 28 13:30:27 2008 +0000
     2.2 +++ b/arch/i386/mm/pgtable-xen.c	Fri Nov 28 13:30:58 2008 +0000
     2.3 @@ -152,6 +152,12 @@ pte_t *pte_alloc_one_kernel(struct mm_st
     2.4  	return pte;
     2.5  }
     2.6  
     2.7 +static void _pte_free(struct page *page, unsigned int order)
     2.8 +{
     2.9 +	BUG_ON(order);
    2.10 +	pte_free(page);
    2.11 +}
    2.12 +
    2.13  struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
    2.14  {
    2.15  	struct page *pte;
    2.16 @@ -162,7 +168,7 @@ struct page *pte_alloc_one(struct mm_str
    2.17  	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
    2.18  #endif
    2.19  	if (pte) {
    2.20 -		SetPageForeign(pte, pte_free);
    2.21 +		SetPageForeign(pte, _pte_free);
    2.22  		init_page_count(pte);
    2.23  	}
    2.24  	return pte;
     3.1 --- a/arch/x86_64/mm/pageattr-xen.c	Fri Nov 28 13:30:27 2008 +0000
     3.2 +++ b/arch/x86_64/mm/pageattr-xen.c	Fri Nov 28 13:30:58 2008 +0000
     3.3 @@ -248,13 +248,19 @@ void _arch_exit_mmap(struct mm_struct *m
     3.4  		mm_unpin(mm);
     3.5  }
     3.6  
     3.7 +static void _pte_free(struct page *page, unsigned int order)
     3.8 +{
     3.9 +	BUG_ON(order);
    3.10 +	pte_free(page);
    3.11 +}
    3.12 +
    3.13  struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
    3.14  {
    3.15  	struct page *pte;
    3.16  
    3.17  	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
    3.18  	if (pte) {
    3.19 -		SetPageForeign(pte, pte_free);
    3.20 +		SetPageForeign(pte, _pte_free);
    3.21  		init_page_count(pte);
    3.22  	}
    3.23  	return pte;
     4.1 --- a/drivers/xen/core/gnttab.c	Fri Nov 28 13:30:27 2008 +0000
     4.2 +++ b/drivers/xen/core/gnttab.c	Fri Nov 28 13:30:58 2008 +0000
     4.3 @@ -505,8 +505,9 @@ static int gnttab_map(unsigned int start
     4.4  	return 0;
     4.5  }
     4.6  
     4.7 -static void gnttab_page_free(struct page *page)
     4.8 +static void gnttab_page_free(struct page *page, unsigned int order)
     4.9  {
    4.10 +	BUG_ON(order);
    4.11  	ClearPageForeign(page);
    4.12  	gnttab_reset_grant_page(page);
    4.13  	put_page(page);
     5.1 --- a/drivers/xen/netback/netback.c	Fri Nov 28 13:30:27 2008 +0000
     5.2 +++ b/drivers/xen/netback/netback.c	Fri Nov 28 13:30:58 2008 +0000
     5.3 @@ -55,7 +55,6 @@ struct netbk_tx_pending_inuse {
     5.4  };
     5.5  
     5.6  static void netif_idx_release(u16 pending_idx);
     5.7 -static void netif_page_release(struct page *page);
     5.8  static void make_tx_response(netif_t *netif, 
     5.9  			     netif_tx_request_t *txp,
    5.10  			     s8       st);
    5.11 @@ -1436,8 +1435,9 @@ static void netif_idx_release(u16 pendin
    5.12  	tasklet_schedule(&net_tx_tasklet);
    5.13  }
    5.14  
    5.15 -static void netif_page_release(struct page *page)
    5.16 +static void netif_page_release(struct page *page, unsigned int order)
    5.17  {
    5.18 +	BUG_ON(order);
    5.19  	netif_idx_release(netif_page_index(page));
    5.20  }
    5.21  
     6.1 --- a/include/linux/page-flags.h	Fri Nov 28 13:30:27 2008 +0000
     6.2 +++ b/include/linux/page-flags.h	Fri Nov 28 13:30:58 2008 +0000
     6.3 @@ -252,15 +252,15 @@
     6.4  #define PageForeign(page)	test_bit(PG_foreign, &(page)->flags)
     6.5  #define SetPageForeign(_page, dtor) do {		\
     6.6  	set_bit(PG_foreign, &(_page)->flags);		\
     6.7 -	BUG_ON((dtor) == (void (*)(struct page *))0);	\
     6.8 +	BUG_ON((dtor) == (void (*)(struct page *, unsigned int))0); \
     6.9  	(_page)->index = (long)(dtor);			\
    6.10  } while (0)
    6.11  #define ClearPageForeign(page) do {			\
    6.12  	clear_bit(PG_foreign, &(page)->flags);		\
    6.13  	(page)->index = 0;				\
    6.14  } while (0)
    6.15 -#define PageForeignDestructor(_page)			\
    6.16 -	((void (*)(struct page *))(_page)->index)(_page)
    6.17 +#define PageForeignDestructor(_page, order)		\
    6.18 +	((void (*)(struct page *, unsigned int))(_page)->index)(_page, order)
    6.19  
    6.20  struct page;	/* forward declaration */
    6.21  
     7.1 --- a/mm/page_alloc.c	Fri Nov 28 13:30:27 2008 +0000
     7.2 +++ b/mm/page_alloc.c	Fri Nov 28 13:30:58 2008 +0000
     7.3 @@ -453,7 +453,7 @@ static void __free_pages_ok(struct page 
     7.4  
     7.5  #ifdef CONFIG_XEN
     7.6  	if (PageForeign(page)) {
     7.7 -		PageForeignDestructor(page);
     7.8 +		PageForeignDestructor(page, order);
     7.9  		return;
    7.10  	}
    7.11  #endif
    7.12 @@ -737,7 +737,7 @@ static void fastcall free_hot_cold_page(
    7.13  
    7.14  #ifdef CONFIG_XEN
    7.15  	if (PageForeign(page)) {
    7.16 -		PageForeignDestructor(page);
    7.17 +		PageForeignDestructor(page, 0);
    7.18  		return;
    7.19  	}
    7.20  #endif