From: Alex Williamson Subject: [PATCH] Don't assume node0 is the first memory node Date: Tue, 29 May 2007 12:16:40 -0600 Message-ID: <1180462600.6756.26.camel@lappy> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: xen-ia64-devel List-Id: xen-devel@lists.xenproject.org init_heap_pages() makes the assumption that node0 will be the first memory node. On bigger boxes this is not necessarily true. Instead of pinning _heap0 and avail0 to nid 0, let's use them for the first node that we free heap pages to. Keir, please apply. Thanks, Alex Signed-off-by: Alex Williamson --- diff -r 2b14a1f22eec xen/common/page_alloc.c --- a/xen/common/page_alloc.c Fri May 25 09:43:21 2007 -0600 +++ b/xen/common/page_alloc.c Tue May 29 12:08:31 2007 -0600 @@ -524,14 +524,6 @@ void init_heap_pages( ASSERT(zone < NR_ZONES); - if ( unlikely(avail[0] == NULL) ) - { - /* Start-of-day memory node 0 initialisation. */ - init_heap_block(&_heap0); - _heap[0] = &_heap0; - avail[0] = avail0; - } - if ( likely(page_to_mfn(pg) != 0) ) nid_prev = phys_to_nid(page_to_maddr(pg-1)); else @@ -543,10 +535,24 @@ void init_heap_pages( if ( !avail[nid_curr] ) { - avail[nid_curr] = xmalloc_array(unsigned long, NR_ZONES); - memset(avail[nid_curr], 0, NR_ZONES * sizeof(long)); - _heap[nid_curr] = xmalloc(heap_by_zone_and_order_t); - init_heap_block(_heap[nid_curr]); + static int first_node = 1; + + if ( unlikely(first_node) ) + { + /* Start-of-day first memory node initialisation. */ + init_heap_block(&_heap0); + _heap[nid_curr] = &_heap0; + avail[nid_curr] = avail0; + + first_node = 0; + } + else + { + avail[nid_curr] = xmalloc_array(unsigned long, NR_ZONES); + memset(avail[nid_curr], 0, NR_ZONES * sizeof(long)); + _heap[nid_curr] = xmalloc(heap_by_zone_and_order_t); + init_heap_block(_heap[nid_curr]); + } } /*