[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 2/3] xen: introduce function merge_free_trunks
Separated from free_heap_pages(), will be used by idle vcpu scrubbing. Signed-off-by: Bob Liu <bob.liu@xxxxxxxxxx> --- xen/common/page_alloc.c | 118 +++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index c184f86..ab293c8 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -831,11 +831,73 @@ static int reserve_offlined_page(struct page_info *head) return count; } +static void merge_free_trunks(struct page_info *pg, unsigned int order, + unsigned int node, unsigned int zone, bool_t need_scrub) +{ + unsigned long mask; + + ASSERT(spin_is_locked(&heap_lock)); + + /* Merge chunks as far as possible. */ + while ( order < MAX_ORDER ) + { + mask = 1UL << order; + + if ( (page_to_mfn(pg) & mask) ) + { + /* Merge with predecessor block? */ + if ( !mfn_valid(page_to_mfn(pg-mask)) || + !page_state_is(pg-mask, free) || + (PFN_ORDER(pg-mask) != order) || + (phys_to_nid(page_to_maddr(pg-mask)) != node) ) + break; + /* If we need scrub, only merge with PGC_need_scrub pages */ + if ( need_scrub ) + { + if ( !test_bit(_PGC_need_scrub, &(pg-mask)->count_info) ) + break; + } + else + { + if ( test_bit(_PGC_need_scrub, &(pg-mask)->count_info) ) + break; + } + pg -= mask; + page_list_del(pg, &heap(node, zone, order)); + } + else + { + /* Merge with successor block? */ + if ( !mfn_valid(page_to_mfn(pg+mask)) || + !page_state_is(pg+mask, free) || + (PFN_ORDER(pg+mask) != order) || + (phys_to_nid(page_to_maddr(pg+mask)) != node) ) + break; + if ( need_scrub ) + { + if ( !test_bit(_PGC_need_scrub, &(pg+mask)->count_info) ) + break; + } + else + { + if ( test_bit(_PGC_need_scrub, &(pg+mask)->count_info) ) + break; + } + page_list_del(pg + mask, &heap(node, zone, order)); + } + + order++; + } + + PFN_ORDER(pg) = order; + page_list_add_tail(pg, &heap(node, zone, order)); +} + /* Free 2^@order set of pages. */ static void free_heap_pages( struct page_info *pg, unsigned int order, bool_t need_scrub) { - unsigned long mask, mfn = page_to_mfn(pg); + unsigned long mfn = page_to_mfn(pg); unsigned int i, node = phys_to_nid(page_to_maddr(pg)), tainted = 0; unsigned int zone = page_to_zone(pg); @@ -891,59 +953,7 @@ static void free_heap_pages( } } - /* Merge chunks as far as possible. */ - while ( order < MAX_ORDER ) - { - mask = 1UL << order; - - if ( (page_to_mfn(pg) & mask) ) - { - /* Merge with predecessor block? */ - if ( !mfn_valid(page_to_mfn(pg-mask)) || - !page_state_is(pg-mask, free) || - (PFN_ORDER(pg-mask) != order) || - (phys_to_nid(page_to_maddr(pg-mask)) != node) ) - break; - /* If we need scrub, only merge with PGC_need_scrub pages */ - if ( need_scrub ) - { - if ( !test_bit(_PGC_need_scrub, &(pg-mask)->count_info) ) - break; - } - else - { - if ( test_bit(_PGC_need_scrub, &(pg-mask)->count_info) ) - break; - } - pg -= mask; - page_list_del(pg, &heap(node, zone, order)); - } - else - { - /* Merge with successor block? */ - if ( !mfn_valid(page_to_mfn(pg+mask)) || - !page_state_is(pg+mask, free) || - (PFN_ORDER(pg+mask) != order) || - (phys_to_nid(page_to_maddr(pg+mask)) != node) ) - break; - if ( need_scrub ) - { - if ( !test_bit(_PGC_need_scrub, &(pg+mask)->count_info) ) - break; - } - else - { - if ( test_bit(_PGC_need_scrub, &(pg+mask)->count_info) ) - break; - } - page_list_del(pg + mask, &heap(node, zone, order)); - } - - order++; - } - - PFN_ORDER(pg) = order; - page_list_add_tail(pg, &heap(node, zone, order)); + merge_free_trunks(pg, order, node, zone, need_scrub); if ( tainted ) reserve_offlined_page(pg); -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |