[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 (resend) 03/27] xen/vmap: Introduce vmap_size() and use it
From: Julien Grall <jgrall@xxxxxxxxxx> vunmap() and vfree() currently duplicate the (small) logic to find the size of an vmap area. In a follow-up patch, we will want to introduce another one (this time externally). So introduce a new helper vmap_size() that will return the number of pages in the area starting at the given address. Take the opportunity to replace the open-coded version. Note that vfree() was storing the type of the area in a local variable. But this seems to have never been used (even when it was introduced). Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx> Signed-off-by: Elias El Yandouzi <eliasely@xxxxxxxxxx> ---- Changes in v2: * Patch added diff --git a/xen/common/vmap.c b/xen/common/vmap.c index fc5c70da4d..171271fae3 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -245,14 +245,21 @@ void *vmap(const mfn_t *mfn, unsigned int nr) return __vmap(mfn, 1, nr, 1, PAGE_HYPERVISOR, VMAP_DEFAULT); } -void vunmap(const void *va) +unsigned int vmap_size(const void *va) { - unsigned long addr = (unsigned long)va; unsigned int pages = vm_size(va, VMAP_DEFAULT); if ( !pages ) pages = vm_size(va, VMAP_XEN); + return pages; +} + +void vunmap(const void *va) +{ + unsigned long addr = (unsigned long)va; + unsigned pages = vmap_size(va); + #ifndef _PAGE_NONE destroy_xen_mappings(addr, addr + PAGE_SIZE * pages); #else /* Avoid tearing down intermediate page tables. */ @@ -328,17 +335,11 @@ void vfree(void *va) unsigned int i, pages; struct page_info *pg; PAGE_LIST_HEAD(pg_list); - enum vmap_region type = VMAP_DEFAULT; if ( !va ) return; - pages = vm_size(va, type); - if ( !pages ) - { - type = VMAP_XEN; - pages = vm_size(va, type); - } + pages = vmap_size(va); ASSERT(pages); for ( i = 0; i < pages; i++ ) diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index 2b7369e062..24c85de490 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -25,6 +25,9 @@ void vfree(void *va); void __iomem *ioremap(paddr_t pa, size_t len); +/* Return the number of pages in the mapping starting at address 'va' */ +unsigned int vmap_size(const void *va); + static inline void iounmap(void __iomem *va) { unsigned long addr = (unsigned long)(void __force *)va; -- 2.40.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |