[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Track free pages live rather than count pages in all nodes/zones
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1260258921 0 # Node ID 3122518646d3ac44e4d0c76ac83228acc4d31dbe # Parent 66ff18dd385841b534efd24fe3a3e33abdbd98ad Track free pages live rather than count pages in all nodes/zones Trying to fix a livelock condition in tmem that occurs only when the system is totally out of memory requires the ability to easily determine if all zones in all nodes are empty, and this must be checked at a fairly high frequency. So to avoid walking all the zones in all the nodes each time, I'd like a fast way to determine if "free_pages" is zero. This patch tracks the sum of the free pages in all nodes/zones. Since I think the value is modified only when heap_lock is held, it need not be atomic. I don't know this for sure, but suspect this will be useful in other future memory utilization code, e.g. page sharing. This has had limited testing, though I did drive free memory down to zero and up and down a few times with debug on and no asserts were triggered. Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx> --- xen/common/page_alloc.c | 11 +++++++++++ xen/include/xen/mm.h | 1 + 2 files changed, 12 insertions(+) diff -r 66ff18dd3858 -r 3122518646d3 xen/common/page_alloc.c --- a/xen/common/page_alloc.c Tue Dec 08 07:51:30 2009 +0000 +++ b/xen/common/page_alloc.c Tue Dec 08 07:55:21 2009 +0000 @@ -222,6 +222,7 @@ static heap_by_zone_and_order_t *_heap[M #define heap(node, zone, order) ((*_heap[node])[zone][order]) static unsigned long *avail[MAX_NUMNODES]; +static long total_avail_pages; static DEFINE_SPINLOCK(heap_lock); @@ -350,6 +351,8 @@ static struct page_info *alloc_heap_page ASSERT(avail[node][zone] >= request); avail[node][zone] -= request; + total_avail_pages -= request; + ASSERT(total_avail_pages >= 0); spin_unlock(&heap_lock); @@ -445,6 +448,8 @@ static int reserve_offlined_page(struct continue; avail[node][zone]--; + total_avail_pages--; + ASSERT(total_avail_pages >= 0); page_list_add_tail(cur_head, test_bit(_PGC_broken, &cur_head->count_info) ? @@ -497,6 +502,7 @@ static void free_heap_pages( spin_lock(&heap_lock); avail[node][zone] += 1 << order; + total_avail_pages += 1 << order; /* Merge chunks as far as possible. */ while ( order < MAX_ORDER ) @@ -834,6 +840,11 @@ static unsigned long avail_heap_pages( return free_pages; } +unsigned long total_free_pages(void) +{ + return total_avail_pages; +} + void __init end_boot_allocator(void) { unsigned int i; diff -r 66ff18dd3858 -r 3122518646d3 xen/include/xen/mm.h --- a/xen/include/xen/mm.h Tue Dec 08 07:51:30 2009 +0000 +++ b/xen/include/xen/mm.h Tue Dec 08 07:55:21 2009 +0000 @@ -62,6 +62,7 @@ unsigned int online_page(unsigned long m unsigned int online_page(unsigned long mfn, uint32_t *status); int offline_page(unsigned long mfn, int broken, uint32_t *status); int query_page_offline(unsigned long mfn, uint32_t *status); +unsigned long total_free_pages(void); void scrub_heap_pages(void); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |