direct-io.hg

changeset 15176:f0772865c85a

xen: Remove assumption that first NUMA node to be discovered is node0.

Based on a patch by Alex Williamson.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed May 30 09:51:38 2007 +0100 (2007-05-30)
parents c49987e71dae
children 33242afccb32
files xen/common/page_alloc.c
line diff
     1.1 --- a/xen/common/page_alloc.c	Fri May 25 17:26:26 2007 +0100
     1.2 +++ b/xen/common/page_alloc.c	Wed May 30 09:51:38 2007 +0100
     1.3 @@ -320,21 +320,39 @@ unsigned long __init alloc_boot_pages(
     1.4  #define pfn_dom_zone_type(_pfn) (fls(_pfn) - 1)
     1.5  
     1.6  typedef struct list_head heap_by_zone_and_order_t[NR_ZONES][MAX_ORDER+1];
     1.7 -static heap_by_zone_and_order_t _heap0;
     1.8  static heap_by_zone_and_order_t *_heap[MAX_NUMNODES];
     1.9  #define heap(node, zone, order) ((*_heap[node])[zone][order])
    1.10  
    1.11 -static unsigned long avail0[NR_ZONES];
    1.12  static unsigned long *avail[MAX_NUMNODES];
    1.13  
    1.14  static DEFINE_SPINLOCK(heap_lock);
    1.15  
    1.16 -static void init_heap_block(heap_by_zone_and_order_t *heap_block)
    1.17 +static void init_node_heap(int node)
    1.18  {
    1.19 +    /* First node to be discovered has its heap metadata statically alloced. */
    1.20 +    static heap_by_zone_and_order_t _heap_static;
    1.21 +    static unsigned long avail_static[NR_ZONES];
    1.22 +    static unsigned long first_node_initialised;
    1.23 +
    1.24      int i, j;
    1.25 +
    1.26 +    if ( !test_and_set_bit(0, &first_node_initialised) )
    1.27 +    {
    1.28 +        _heap[node] = &_heap_static;
    1.29 +        avail[node] = avail_static;
    1.30 +    }
    1.31 +    else
    1.32 +    {
    1.33 +        _heap[node] = xmalloc(heap_by_zone_and_order_t);
    1.34 +        avail[node] = xmalloc_array(unsigned long, NR_ZONES);
    1.35 +        BUG_ON(!_heap[node] || !avail[node]);
    1.36 +    }
    1.37 +
    1.38 +    memset(avail[node], 0, NR_ZONES * sizeof(long));
    1.39 +
    1.40      for ( i = 0; i < NR_ZONES; i++ )
    1.41          for ( j = 0; j <= MAX_ORDER; j++ )
    1.42 -            INIT_LIST_HEAD(&(*heap_block)[i][j]);
    1.43 +            INIT_LIST_HEAD(&(*_heap[node])[i][j]);
    1.44  }
    1.45  
    1.46  /* Allocate 2^@order contiguous pages. */
    1.47 @@ -524,14 +542,6 @@ void init_heap_pages(
    1.48  
    1.49      ASSERT(zone < NR_ZONES);
    1.50  
    1.51 -    if ( unlikely(avail[0] == NULL) )
    1.52 -    {
    1.53 -        /* Start-of-day memory node 0 initialisation. */
    1.54 -        init_heap_block(&_heap0);
    1.55 -        _heap[0] = &_heap0;
    1.56 -        avail[0] = avail0;
    1.57 -    }
    1.58 -
    1.59      if ( likely(page_to_mfn(pg) != 0) )
    1.60          nid_prev = phys_to_nid(page_to_maddr(pg-1));
    1.61      else
    1.62 @@ -541,13 +551,8 @@ void init_heap_pages(
    1.63      {
    1.64          nid_curr = phys_to_nid(page_to_maddr(pg+i));
    1.65  
    1.66 -        if ( !avail[nid_curr] )
    1.67 -        {
    1.68 -            avail[nid_curr] = xmalloc_array(unsigned long, NR_ZONES);
    1.69 -            memset(avail[nid_curr], 0, NR_ZONES * sizeof(long));
    1.70 -            _heap[nid_curr] = xmalloc(heap_by_zone_and_order_t);
    1.71 -            init_heap_block(_heap[nid_curr]);
    1.72 -        }
    1.73 +        if ( unlikely(!avail[nid_curr]) )
    1.74 +            init_node_heap(nid_curr);
    1.75  
    1.76          /*
    1.77           * free pages of the same node, or if they differ, but are on a