ia64/xen-unstable

changeset 18308:32aa43364f5d

page scrub: Serialise softirq with a new lock.
Avoids holding up acquiring page_scrub_lock in free_domheap_pages().

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Aug 11 12:20:11 2008 +0100 (2008-08-11)
parents ce085fc0d2e4
children 794bbae4f25b
files xen/common/page_alloc.c
line diff
     1.1 --- a/xen/common/page_alloc.c	Mon Aug 11 11:27:40 2008 +0100
     1.2 +++ b/xen/common/page_alloc.c	Mon Aug 11 12:20:11 2008 +0100
     1.3 @@ -950,9 +950,10 @@ static void page_scrub_softirq(void)
     1.4      void             *p;
     1.5      int               i;
     1.6      s_time_t          start = NOW();
     1.7 +    static spinlock_t serialise_lock = SPIN_LOCK_UNLOCKED;
     1.8  
     1.9      /* free_heap_pages() does not parallelise well. Serialise this function. */
    1.10 -    if ( !spin_trylock(&page_scrub_lock) )
    1.11 +    if ( !spin_trylock(&serialise_lock) )
    1.12      {
    1.13          set_timer(&this_cpu(page_scrub_timer), NOW() + MILLISECS(1));
    1.14          return;
    1.15 @@ -960,10 +961,12 @@ static void page_scrub_softirq(void)
    1.16  
    1.17      /* Aim to do 1ms of work every 10ms. */
    1.18      do {
    1.19 +        spin_lock(&page_scrub_lock);
    1.20 +
    1.21          if ( unlikely((ent = page_scrub_list.next) == &page_scrub_list) )
    1.22          {
    1.23              spin_unlock(&page_scrub_lock);
    1.24 -            return;
    1.25 +            goto out;
    1.26          }
    1.27          
    1.28          /* Peel up to 16 pages from the list. */
    1.29 @@ -979,6 +982,8 @@ static void page_scrub_softirq(void)
    1.30          page_scrub_list.next = ent->next;
    1.31          scrub_pages -= (i+1);
    1.32  
    1.33 +        spin_unlock(&page_scrub_lock);
    1.34 +
    1.35          /* Working backwards, scrub each page in turn. */
    1.36          while ( ent != &page_scrub_list )
    1.37          {
    1.38 @@ -991,9 +996,10 @@ static void page_scrub_softirq(void)
    1.39          }
    1.40      } while ( (NOW() - start) < MILLISECS(1) );
    1.41  
    1.42 -    spin_unlock(&page_scrub_lock);
    1.43 +    set_timer(&this_cpu(page_scrub_timer), NOW() + MILLISECS(10));
    1.44  
    1.45 -    set_timer(&this_cpu(page_scrub_timer), NOW() + MILLISECS(10));
    1.46 + out:
    1.47 +    spin_unlock(&serialise_lock);
    1.48  }
    1.49  
    1.50  static void page_scrub_timer_fn(void *unused)