ia64/xen-unstable

changeset 13025:c3ff06093028

[XEN] Boot allocator searches from earliest registered
memory region instead of 0.

Based on a patch from Jes Sorensen <jes@sgi.com> which
massively improves boot time on SGI Altix systems.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Dec 14 12:02:30 2006 +0000 (2006-12-14)
parents 21609e7f5a49
children 79315be2c9b9
files xen/common/page_alloc.c
line diff
     1.1 --- a/xen/common/page_alloc.c	Thu Dec 14 11:39:40 2006 +0000
     1.2 +++ b/xen/common/page_alloc.c	Thu Dec 14 12:02:30 2006 +0000
     1.3 @@ -136,7 +136,6 @@ static void map_alloc(unsigned long firs
     1.4      }
     1.5  }
     1.6  
     1.7 -
     1.8  static void map_free(unsigned long first_page, unsigned long nr_pages)
     1.9  {
    1.10      unsigned long start_off, end_off, curr_idx, end_idx;
    1.11 @@ -171,6 +170,8 @@ static void map_free(unsigned long first
    1.12   * BOOT-TIME ALLOCATOR
    1.13   */
    1.14  
    1.15 +static unsigned long first_valid_mfn = ~0UL;
    1.16 +
    1.17  /* Initialise allocator to handle up to @max_page pages. */
    1.18  paddr_t init_boot_allocator(paddr_t bitmap_start)
    1.19  {
    1.20 @@ -203,6 +204,8 @@ void init_boot_pages(paddr_t ps, paddr_t
    1.21      if ( pe <= ps )
    1.22          return;
    1.23  
    1.24 +    first_valid_mfn = min_t(unsigned long, ps >> PAGE_SHIFT, first_valid_mfn);
    1.25 +
    1.26      map_free(ps >> PAGE_SHIFT, (pe - ps) >> PAGE_SHIFT);
    1.27  
    1.28      /* Check new pages against the bad-page list. */
    1.29 @@ -256,16 +259,17 @@ unsigned long alloc_boot_pages_at(unsign
    1.30  
    1.31  unsigned long alloc_boot_pages(unsigned long nr_pfns, unsigned long pfn_align)
    1.32  {
    1.33 -    unsigned long pg, i = 0;
    1.34 +    unsigned long pg;
    1.35  
    1.36 -    for ( pg = 0; (pg + nr_pfns) < max_page; pg += pfn_align )
    1.37 +    pg = first_valid_mfn & ~(pfn_align-1);
    1.38 +    while ( (pg + nr_pfns) < max_page )
    1.39      {
    1.40 -        i = alloc_boot_pages_at(nr_pfns, pg);
    1.41 -        if (i != 0)
    1.42 +        if ( alloc_boot_pages_at(nr_pfns, pg) != 0 )
    1.43              break;
    1.44 +        pg += pfn_align;
    1.45      }
    1.46  
    1.47 -    return i;
    1.48 +    return pg;
    1.49  }
    1.50  
    1.51  
    1.52 @@ -301,7 +305,7 @@ void end_boot_allocator(void)
    1.53                  INIT_LIST_HEAD(&heap[i][j][k]);
    1.54  
    1.55      /* Pages that are free now go to the domain sub-allocator. */
    1.56 -    for ( i = 0; i < max_page; i++ )
    1.57 +    for ( i = first_valid_mfn; i < max_page; i++ )
    1.58      {
    1.59          curr_free = next_free;
    1.60          next_free = !allocated_in_map(i+1);
    1.61 @@ -324,7 +328,7 @@ void end_boot_allocator(void)
    1.62  void init_heap_pages(
    1.63      unsigned int zone, struct page_info *pg, unsigned long nr_pages)
    1.64  {
    1.65 -    unsigned int nid_curr,nid_prev;
    1.66 +    unsigned int nid_curr, nid_prev;
    1.67      unsigned long i;
    1.68  
    1.69      ASSERT(zone < NR_ZONES);
    1.70 @@ -478,37 +482,37 @@ void free_heap_pages(
    1.71  void scrub_heap_pages(void)
    1.72  {
    1.73      void *p;
    1.74 -    unsigned long pfn;
    1.75 +    unsigned long mfn;
    1.76  
    1.77      printk("Scrubbing Free RAM: ");
    1.78  
    1.79 -    for ( pfn = 0; pfn < max_page; pfn++ )
    1.80 +    for ( mfn = first_valid_mfn; mfn < max_page; mfn++ )
    1.81      {
    1.82          /* Every 100MB, print a progress dot. */
    1.83 -        if ( (pfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
    1.84 +        if ( (mfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
    1.85              printk(".");
    1.86  
    1.87          process_pending_timers();
    1.88  
    1.89          /* Quick lock-free check. */
    1.90 -        if ( allocated_in_map(pfn) )
    1.91 +        if ( allocated_in_map(mfn) )
    1.92              continue;
    1.93  
    1.94          spin_lock_irq(&heap_lock);
    1.95  
    1.96          /* Re-check page status with lock held. */
    1.97 -        if ( !allocated_in_map(pfn) )
    1.98 +        if ( !allocated_in_map(mfn) )
    1.99          {
   1.100 -            if ( IS_XEN_HEAP_FRAME(mfn_to_page(pfn)) )
   1.101 +            if ( IS_XEN_HEAP_FRAME(mfn_to_page(mfn)) )
   1.102              {
   1.103 -                p = page_to_virt(mfn_to_page(pfn));
   1.104 +                p = page_to_virt(mfn_to_page(mfn));
   1.105                  memguard_unguard_range(p, PAGE_SIZE);
   1.106                  clear_page(p);
   1.107                  memguard_guard_range(p, PAGE_SIZE);
   1.108              }
   1.109              else
   1.110              {
   1.111 -                p = map_domain_page(pfn);
   1.112 +                p = map_domain_page(mfn);
   1.113                  clear_page(p);
   1.114                  unmap_domain_page(p);
   1.115              }