ia64/xen-unstable

changeset 9435:bd108ccc38a0

Rename generic_page_range as apply_to_page_range, export the symbol
to GPL modules. Rename pte_page parameter to pmd_page (following the
Linux idiom). apply_to_pte_range() should take the pte spinlock.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Mar 23 15:30:00 2006 +0100 (2006-03-23)
parents 401624a17ef7
children c947b278a349
files linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/core/gnttab.c linux-2.6-xen-sparse/drivers/xen/util.c linux-2.6-xen-sparse/include/linux/mm.h linux-2.6-xen-sparse/mm/memory.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Thu Mar 23 14:45:21 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Thu Mar 23 15:30:00 2006 +0100
     1.3 @@ -32,13 +32,13 @@
     1.4  #endif
     1.5  
     1.6  static int direct_remap_area_pte_fn(pte_t *pte, 
     1.7 -				    struct page *pte_page,
     1.8 +				    struct page *pmd_page,
     1.9  				    unsigned long address, 
    1.10  				    void *data)
    1.11  {
    1.12  	mmu_update_t **v = (mmu_update_t **)data;
    1.13  
    1.14 -	(*v)->ptr = ((u64)pfn_to_mfn(page_to_pfn(pte_page)) <<
    1.15 +	(*v)->ptr = ((u64)pfn_to_mfn(page_to_pfn(pmd_page)) <<
    1.16  		     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
    1.17  	(*v)++;
    1.18  
    1.19 @@ -67,9 +67,9 @@ static int __direct_remap_pfn_range(stru
    1.20  	for (i = 0; i < size; i += PAGE_SIZE) {
    1.21  		if ((v - u) == (PAGE_SIZE / sizeof(mmu_update_t))) {
    1.22  			/* Fill in the PTE pointers. */
    1.23 -			rc = generic_page_range(mm, start_address, 
    1.24 -						address - start_address,
    1.25 -						direct_remap_area_pte_fn, &w);
    1.26 +			rc = apply_to_page_range(mm, start_address, 
    1.27 +						 address - start_address,
    1.28 +						 direct_remap_area_pte_fn, &w);
    1.29  			if (rc)
    1.30  				goto out;
    1.31  			w = u;
    1.32 @@ -93,8 +93,9 @@ static int __direct_remap_pfn_range(stru
    1.33  
    1.34  	if (v != u) {
    1.35  		/* get the ptep's filled in */
    1.36 -		rc = generic_page_range(mm, start_address, address - start_address,
    1.37 -				   direct_remap_area_pte_fn, &w);
    1.38 +		rc = apply_to_page_range(mm, start_address,
    1.39 +					 address - start_address,
    1.40 +					 direct_remap_area_pte_fn, &w);
    1.41  		if (rc)
    1.42  			goto out;
    1.43  		rc = -EFAULT;
    1.44 @@ -142,11 +143,11 @@ int direct_kernel_remap_pfn_range(unsign
    1.45  EXPORT_SYMBOL(direct_kernel_remap_pfn_range);
    1.46  
    1.47  static int lookup_pte_fn(
    1.48 -	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
    1.49 +	pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
    1.50  {
    1.51  	uint64_t *ptep = (uint64_t *)data;
    1.52  	if (ptep)
    1.53 -		*ptep = ((uint64_t)pfn_to_mfn(page_to_pfn(pte_page)) <<
    1.54 +		*ptep = ((uint64_t)pfn_to_mfn(page_to_pfn(pmd_page)) <<
    1.55  			 PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
    1.56  	return 0;
    1.57  }
    1.58 @@ -155,13 +156,14 @@ int create_lookup_pte_addr(struct mm_str
    1.59  			   unsigned long address,
    1.60  			   uint64_t *ptep)
    1.61  {
    1.62 -	return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
    1.63 +	return apply_to_page_range(mm, address, PAGE_SIZE,
    1.64 +				   lookup_pte_fn, ptep);
    1.65  }
    1.66  
    1.67  EXPORT_SYMBOL(create_lookup_pte_addr);
    1.68  
    1.69  static int noop_fn(
    1.70 -	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
    1.71 +	pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
    1.72  {
    1.73  	return 0;
    1.74  }
    1.75 @@ -170,7 +172,7 @@ int touch_pte_range(struct mm_struct *mm
    1.76  		    unsigned long address,
    1.77  		    unsigned long size)
    1.78  {
    1.79 -	return generic_page_range(mm, address, size, noop_fn, NULL);
    1.80 +	return apply_to_page_range(mm, address, size, noop_fn, NULL);
    1.81  } 
    1.82  
    1.83  EXPORT_SYMBOL(touch_pte_range);
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Mar 23 14:45:21 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Mar 23 15:30:00 2006 +0100
     2.3 @@ -517,7 +517,7 @@ void balloon_update_driver_allowance(lon
     2.4  }
     2.5  
     2.6  static int dealloc_pte_fn(
     2.7 -	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
     2.8 +	pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
     2.9  {
    2.10  	unsigned long mfn = pte_mfn(*pte);
    2.11  	int ret;
    2.12 @@ -547,8 +547,8 @@ struct page *balloon_alloc_empty_page_ra
    2.13  	scrub_pages(vstart, 1 << order);
    2.14  
    2.15  	balloon_lock(flags);
    2.16 -	ret = generic_page_range(
    2.17 -		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL);
    2.18 +	ret = apply_to_page_range(&init_mm, vstart,
    2.19 +				  PAGE_SIZE << order, dealloc_pte_fn, NULL);
    2.20  	BUG_ON(ret);
    2.21  	current_pages -= 1UL << order;
    2.22  	totalram_pages = current_pages;
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Mar 23 14:45:21 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Mar 23 15:30:00 2006 +0100
     3.3 @@ -360,7 +360,7 @@ gnttab_request_free_callback(struct gntt
     3.4  }
     3.5  
     3.6  #ifndef __ia64__
     3.7 -static int map_pte_fn(pte_t *pte, struct page *pte_page,
     3.8 +static int map_pte_fn(pte_t *pte, struct page *pmd_page,
     3.9  		      unsigned long addr, void *data)
    3.10  {
    3.11  	unsigned long **frames = (unsigned long **)data;
    3.12 @@ -370,7 +370,7 @@ static int map_pte_fn(pte_t *pte, struct
    3.13  	return 0;
    3.14  }
    3.15  
    3.16 -static int unmap_pte_fn(pte_t *pte, struct page *pte_page,
    3.17 +static int unmap_pte_fn(pte_t *pte, struct page *pmd_page,
    3.18  		      unsigned long addr, void *data)
    3.19  {
    3.20  
    3.21 @@ -384,6 +384,7 @@ gnttab_resume(void)
    3.22  {
    3.23  	gnttab_setup_table_t setup;
    3.24  	unsigned long frames[NR_GRANT_FRAMES];
    3.25 +	int rc;
    3.26  #ifndef __ia64__
    3.27  	void *pframes = frames;
    3.28  	struct vm_struct *area;
    3.29 @@ -393,8 +394,8 @@ gnttab_resume(void)
    3.30  	setup.nr_frames  = NR_GRANT_FRAMES;
    3.31  	setup.frame_list = frames;
    3.32  
    3.33 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1));
    3.34 -	BUG_ON(setup.status != 0);
    3.35 +	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
    3.36 +	BUG_ON(rc || setup.status);
    3.37  
    3.38  #ifndef __ia64__
    3.39  	if (shared == NULL) {
    3.40 @@ -402,9 +403,10 @@ gnttab_resume(void)
    3.41  		BUG_ON(area == NULL);
    3.42  		shared = area->addr;
    3.43  	}
    3.44 -	BUG_ON(generic_page_range(&init_mm, (unsigned long)shared,
    3.45 -				  PAGE_SIZE * NR_GRANT_FRAMES,
    3.46 -				  map_pte_fn, &pframes));
    3.47 +	rc = apply_to_page_range(&init_mm, (unsigned long)shared,
    3.48 +				 PAGE_SIZE * NR_GRANT_FRAMES,
    3.49 +				 map_pte_fn, &pframes);
    3.50 +	BUG_ON(rc);
    3.51  #else
    3.52  	shared = __va(frames[0] << PAGE_SHIFT);
    3.53  	printk("grant table at %p\n", shared);
    3.54 @@ -418,9 +420,9 @@ gnttab_suspend(void)
    3.55  {
    3.56  
    3.57  #ifndef __ia64__
    3.58 -	generic_page_range(&init_mm, (unsigned long)shared,
    3.59 -			   PAGE_SIZE * NR_GRANT_FRAMES,
    3.60 -			   unmap_pte_fn, NULL);
    3.61 +	apply_to_page_range(&init_mm, (unsigned long)shared,
    3.62 +			    PAGE_SIZE * NR_GRANT_FRAMES,
    3.63 +			    unmap_pte_fn, NULL);
    3.64  #endif
    3.65  
    3.66  	return 0;
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/util.c	Thu Mar 23 14:45:21 2006 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/util.c	Thu Mar 23 15:30:00 2006 +0100
     4.3 @@ -6,9 +6,9 @@
     4.4  #include <asm/uaccess.h>
     4.5  #include <xen/driver_util.h>
     4.6  
     4.7 -static int f(pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
     4.8 +static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
     4.9  {
    4.10 -	/* generic_page_range() does all the hard work. */
    4.11 +	/* apply_to_page_range() does all the hard work. */
    4.12  	return 0;
    4.13  }
    4.14  
    4.15 @@ -24,8 +24,8 @@ struct vm_struct *alloc_vm_area(unsigned
    4.16  	 * This ensures that page tables are constructed for this region
    4.17  	 * of kernel virtual address space and mapped into init_mm.
    4.18  	 */
    4.19 -	if (generic_page_range(&init_mm, (unsigned long)area->addr,
    4.20 -			       area->size, f, NULL)) {
    4.21 +	if (apply_to_page_range(&init_mm, (unsigned long)area->addr,
    4.22 +				area->size, f, NULL)) {
    4.23  		free_vm_area(area);
    4.24  		return NULL;
    4.25  	}
     5.1 --- a/linux-2.6-xen-sparse/include/linux/mm.h	Thu Mar 23 14:45:21 2006 +0100
     5.2 +++ b/linux-2.6-xen-sparse/include/linux/mm.h	Thu Mar 23 15:30:00 2006 +0100
     5.3 @@ -1020,10 +1020,10 @@ struct page *follow_page(struct vm_area_
     5.4  #define FOLL_ANON	0x08	/* give ZERO_PAGE if no pgtable */
     5.5  
     5.6  #ifdef CONFIG_XEN
     5.7 -typedef int (*pte_fn_t)(pte_t *pte, struct page *pte_page, unsigned long addr,
     5.8 -                        void *data);
     5.9 -extern int generic_page_range(struct mm_struct *mm, unsigned long address,
    5.10 -                              unsigned long size, pte_fn_t fn, void *data);
    5.11 +typedef int (*pte_fn_t)(pte_t *pte, struct page *pmd_page, unsigned long addr,
    5.12 +			void *data);
    5.13 +extern int apply_to_page_range(struct mm_struct *mm, unsigned long address,
    5.14 +			       unsigned long size, pte_fn_t fn, void *data);
    5.15  #endif
    5.16  
    5.17  #ifdef CONFIG_PROC_FS
     6.1 --- a/linux-2.6-xen-sparse/mm/memory.c	Thu Mar 23 14:45:21 2006 +0100
     6.2 +++ b/linux-2.6-xen-sparse/mm/memory.c	Thu Mar 23 15:30:00 2006 +0100
     6.3 @@ -1378,36 +1378,39 @@ int remap_pfn_range(struct vm_area_struc
     6.4  EXPORT_SYMBOL(remap_pfn_range);
     6.5  
     6.6  #ifdef CONFIG_XEN
     6.7 -static inline int generic_pte_range(struct mm_struct *mm, pmd_t *pmd,
     6.8 -				    unsigned long addr, unsigned long end,
     6.9 -				    pte_fn_t fn, void *data)
    6.10 +static inline int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
    6.11 +				     unsigned long addr, unsigned long end,
    6.12 +				     pte_fn_t fn, void *data)
    6.13  {
    6.14  	pte_t *pte;
    6.15  	int err;
    6.16 -	struct page *pte_page;
    6.17 +	struct page *pmd_page;
    6.18 +	spinlock_t *ptl;
    6.19  
    6.20  	pte = (mm == &init_mm) ?
    6.21  		pte_alloc_kernel(pmd, addr) :
    6.22 -		pte_alloc_map(mm, pmd, addr);
    6.23 +		pte_alloc_map_lock(mm, pmd, addr, &ptl);
    6.24  	if (!pte)
    6.25  		return -ENOMEM;
    6.26  
    6.27 -	pte_page = pmd_page(*pmd);
    6.28 +	BUG_ON(pmd_huge(*pmd));
    6.29 +
    6.30 +	pmd_page = pmd_page(*pmd);
    6.31  
    6.32  	do {
    6.33 -		err = fn(pte, pte_page, addr, data);
    6.34 +		err = fn(pte, pmd_page, addr, data);
    6.35  		if (err)
    6.36  			break;
    6.37  	} while (pte++, addr += PAGE_SIZE, addr != end);
    6.38  
    6.39  	if (mm != &init_mm)
    6.40 -		pte_unmap(pte-1);
    6.41 +		pte_unmap_unlock(pte-1, ptl);
    6.42  	return err;
    6.43  }
    6.44  
    6.45 -static inline int generic_pmd_range(struct mm_struct *mm, pud_t *pud,
    6.46 -				    unsigned long addr, unsigned long end,
    6.47 -				    pte_fn_t fn, void *data)
    6.48 +static inline int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
    6.49 +				     unsigned long addr, unsigned long end,
    6.50 +				     pte_fn_t fn, void *data)
    6.51  {
    6.52  	pmd_t *pmd;
    6.53  	unsigned long next;
    6.54 @@ -1418,16 +1421,16 @@ static inline int generic_pmd_range(stru
    6.55  		return -ENOMEM;
    6.56  	do {
    6.57  		next = pmd_addr_end(addr, end);
    6.58 -		err = generic_pte_range(mm, pmd, addr, next, fn, data);
    6.59 +		err = apply_to_pte_range(mm, pmd, addr, next, fn, data);
    6.60  		if (err)
    6.61  			break;
    6.62  	} while (pmd++, addr = next, addr != end);
    6.63  	return err;
    6.64  }
    6.65  
    6.66 -static inline int generic_pud_range(struct mm_struct *mm, pgd_t *pgd,
    6.67 -				    unsigned long addr, unsigned long end,
    6.68 -				    pte_fn_t fn, void *data)
    6.69 +static inline int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
    6.70 +				     unsigned long addr, unsigned long end,
    6.71 +				     pte_fn_t fn, void *data)
    6.72  {
    6.73  	pud_t *pud;
    6.74  	unsigned long next;
    6.75 @@ -1438,7 +1441,7 @@ static inline int generic_pud_range(stru
    6.76  		return -ENOMEM;
    6.77  	do {
    6.78  		next = pud_addr_end(addr, end);
    6.79 -		err = generic_pmd_range(mm, pud, addr, next, fn, data);
    6.80 +		err = apply_to_pmd_range(mm, pud, addr, next, fn, data);
    6.81  		if (err)
    6.82  			break;
    6.83  	} while (pud++, addr = next, addr != end);
    6.84 @@ -1449,8 +1452,8 @@ static inline int generic_pud_range(stru
    6.85   * Scan a region of virtual memory, filling in page tables as necessary
    6.86   * and calling a provided function on each leaf page table.
    6.87   */
    6.88 -int generic_page_range(struct mm_struct *mm, unsigned long addr,
    6.89 -		       unsigned long size, pte_fn_t fn, void *data)
    6.90 +int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
    6.91 +			unsigned long size, pte_fn_t fn, void *data)
    6.92  {
    6.93  	pgd_t *pgd;
    6.94  	unsigned long next;
    6.95 @@ -1461,12 +1464,13 @@ int generic_page_range(struct mm_struct 
    6.96  	pgd = pgd_offset(mm, addr);
    6.97  	do {
    6.98  		next = pgd_addr_end(addr, end);
    6.99 -		err = generic_pud_range(mm, pgd, addr, next, fn, data);
   6.100 +		err = apply_to_pud_range(mm, pgd, addr, next, fn, data);
   6.101  		if (err)
   6.102  			break;
   6.103  	} while (pgd++, addr = next, addr != end);
   6.104  	return err;
   6.105  }
   6.106 +EXPORT_SYMBOL_GPL(apply_to_page_range);
   6.107  #endif
   6.108  
   6.109  /*