[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 5/9] xen: introduce assign_pages_nr
Introduce new interface assign_pages_nr to deal with when page number is not in a power-of-two, which will save the trouble each time user needs to split the size in a power of 2 to use assign_pages. Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx> --- changes v2: - introduce new interface assign_pages_nr --- xen/common/page_alloc.c | 26 +++++++++++++++++--------- xen/include/xen/mm.h | 10 ++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 8c00262c04..e244d2e52e 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2301,14 +2301,14 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) } -int assign_pages( +int assign_pages_nr( struct domain *d, struct page_info *pg, - unsigned int order, + unsigned int nr_pfns, unsigned int memflags) { int rc = 0; - unsigned long i; + unsigned int i; spin_lock(&d->page_alloc_lock); @@ -2324,7 +2324,7 @@ int assign_pages( { unsigned int extra_pages = 0; - for ( i = 0; i < (1ul << order); i++ ) + for ( i = 0; i < nr_pfns; i++ ) { ASSERT(!(pg[i].count_info & ~PGC_extra)); if ( pg[i].count_info & PGC_extra ) @@ -2333,18 +2333,18 @@ int assign_pages( ASSERT(!extra_pages || ((memflags & MEMF_no_refcount) && - extra_pages == 1u << order)); + extra_pages == nr_pfns)); } #endif if ( pg[0].count_info & PGC_extra ) { - d->extra_pages += 1u << order; + d->extra_pages += nr_pfns; memflags &= ~MEMF_no_refcount; } else if ( !(memflags & MEMF_no_refcount) ) { - unsigned int tot_pages = domain_tot_pages(d) + (1 << order); + unsigned int tot_pages = domain_tot_pages(d) + nr_pfns; if ( unlikely(tot_pages > d->max_pages) ) { @@ -2356,10 +2356,10 @@ int assign_pages( } if ( !(memflags & MEMF_no_refcount) && - unlikely(domain_adjust_tot_pages(d, 1 << order) == (1 << order)) ) + unlikely(domain_adjust_tot_pages(d, nr_pfns) == nr_pfns) ) get_knownalive_domain(d); - for ( i = 0; i < (1 << order); i++ ) + for ( i = 0; i < nr_pfns; i++ ) { ASSERT(page_get_owner(&pg[i]) == NULL); page_set_owner(&pg[i], d); @@ -2374,6 +2374,14 @@ int assign_pages( return rc; } +int assign_pages( + struct domain *d, + struct page_info *pg, + unsigned int order, + unsigned int memflags) +{ + return assign_pages_nr(d, pg, (1U << order), memflags); +} struct page_info *alloc_domheap_pages( struct domain *d, unsigned int order, unsigned int memflags) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index df25e55966..25d970e857 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -131,12 +131,18 @@ int query_page_offline(mfn_t mfn, uint32_t *status); void heap_init_late(void); -int assign_pages( +int assign_pages_nr( struct domain *d, struct page_info *pg, - unsigned int order, + unsigned int nr_pfns, unsigned int memflags); + int assign_pages( + struct domain *d, + struct page_info *pg, + unsigned int order, + unsigned int memflags); + /* Dump info to serial console */ void arch_dump_shared_mem_info(void); -- 2.25.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |