ia64/xen-unstable

changeset 18749:9e5cf6778a6d

x86: eliminate domain cleanup hack in favor of using the preemptable
flavors of the respective functions.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Oct 30 14:37:48 2008 +0000 (2008-10-30)
parents 112e81ae5824
children ed30f4efb728
files xen/arch/x86/domain.c xen/arch/x86/mm.c xen/include/asm-x86/config.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Thu Oct 30 13:33:40 2008 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Thu Oct 30 14:37:48 2008 +0000
     1.3 @@ -1640,32 +1640,23 @@ static int relinquish_memory(
     1.4          }
     1.5  
     1.6          if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
     1.7 -            put_page_and_type(page);
     1.8 +            ret = put_page_and_type_preemptible(page, 1);
     1.9 +        switch ( ret )
    1.10 +        {
    1.11 +        case 0:
    1.12 +            break;
    1.13 +        case -EAGAIN:
    1.14 +        case -EINTR:
    1.15 +            set_bit(_PGT_pinned, &page->u.inuse.type_info);
    1.16 +            put_page(page);
    1.17 +            goto out;
    1.18 +        default:
    1.19 +            BUG();
    1.20 +        }
    1.21  
    1.22          if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
    1.23              put_page(page);
    1.24  
    1.25 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION
    1.26 -        /*
    1.27 -         * Forcibly drop reference counts of page tables above top most (which
    1.28 -         * were skipped to prevent long latencies due to deep recursion - see
    1.29 -         * the special treatment in free_lX_table()).
    1.30 -         */
    1.31 -        y = page->u.inuse.type_info;
    1.32 -        if ( (type < PGT_root_page_table) &&
    1.33 -             unlikely(((y + PGT_type_mask) &
    1.34 -                       (PGT_type_mask|PGT_validated)) == type) )
    1.35 -        {
    1.36 -            BUG_ON((y & PGT_count_mask) >=
    1.37 -                   (page->count_info & PGC_count_mask));
    1.38 -            while ( y & PGT_count_mask )
    1.39 -            {
    1.40 -                put_page_and_type(page);
    1.41 -                y = page->u.inuse.type_info;
    1.42 -            }
    1.43 -        }
    1.44 -#endif
    1.45 -
    1.46          /*
    1.47           * Forcibly invalidate top-most, still valid page tables at this point
    1.48           * to break circular 'linear page table' references as well as clean up
    1.49 @@ -1686,8 +1677,23 @@ static int relinquish_memory(
    1.50                          x & ~(PGT_validated|PGT_partial));
    1.51              if ( likely(y == x) )
    1.52              {
    1.53 -                if ( free_page_type(page, x, 0) != 0 )
    1.54 +                /* No need for atomic update of type_info here: noone else updates it. */
    1.55 +                switch ( ret = free_page_type(page, x, 1) )
    1.56 +                {
    1.57 +                case 0:
    1.58 +                    break;
    1.59 +                case -EINTR:
    1.60 +                    page->u.inuse.type_info |= PGT_validated;
    1.61 +                    put_page(page);
    1.62 +                    ret = -EAGAIN;
    1.63 +                    goto out;
    1.64 +                case -EAGAIN:
    1.65 +                    page->u.inuse.type_info |= PGT_partial;
    1.66 +                    put_page(page);
    1.67 +                    goto out;
    1.68 +                default:
    1.69                      BUG();
    1.70 +                }
    1.71                  if ( x & PGT_partial )
    1.72                      page->u.inuse.type_info--;
    1.73                  break;
    1.74 @@ -1834,11 +1840,6 @@ int domain_relinquish_resources(struct d
    1.75          /* fallthrough */
    1.76  
    1.77      case RELMEM_done:
    1.78 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION
    1.79 -        ret = relinquish_memory(d, &d->page_list, PGT_l1_page_table);
    1.80 -        if ( ret )
    1.81 -            return ret;
    1.82 -#endif
    1.83          break;
    1.84  
    1.85      default:
     2.1 --- a/xen/arch/x86/mm.c	Thu Oct 30 13:33:40 2008 +0000
     2.2 +++ b/xen/arch/x86/mm.c	Thu Oct 30 14:37:48 2008 +0000
     2.3 @@ -1343,7 +1343,7 @@ static void free_l1_table(struct page_in
     2.4  
     2.5  static int free_l2_table(struct page_info *page, int preemptible)
     2.6  {
     2.7 -#if defined(CONFIG_COMPAT) || defined(DOMAIN_DESTRUCT_AVOID_RECURSION)
     2.8 +#ifdef CONFIG_COMPAT
     2.9      struct domain *d = page_get_owner(page);
    2.10  #endif
    2.11      unsigned long pfn = page_to_mfn(page);
    2.12 @@ -1351,11 +1351,6 @@ static int free_l2_table(struct page_inf
    2.13      unsigned int  i = page->nr_validated_ptes - 1;
    2.14      int err = 0;
    2.15  
    2.16 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION
    2.17 -    if ( d->arch.relmem == RELMEM_l3 )
    2.18 -        return 0;
    2.19 -#endif
    2.20 -
    2.21      pl2e = map_domain_page(pfn);
    2.22  
    2.23      ASSERT(page->nr_validated_ptes);
    2.24 @@ -1385,11 +1380,6 @@ static int free_l3_table(struct page_inf
    2.25      unsigned int  i = page->nr_validated_ptes - !page->partial_pte;
    2.26      int rc = 0;
    2.27  
    2.28 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION
    2.29 -    if ( d->arch.relmem == RELMEM_l4 )
    2.30 -        return 0;
    2.31 -#endif
    2.32 -
    2.33      pl3e = map_domain_page(pfn);
    2.34  
    2.35      do {
     3.1 --- a/xen/include/asm-x86/config.h	Thu Oct 30 13:33:40 2008 +0000
     3.2 +++ b/xen/include/asm-x86/config.h	Thu Oct 30 14:37:48 2008 +0000
     3.3 @@ -41,14 +41,6 @@
     3.4  #define CONFIG_HOTPLUG 1
     3.5  #define CONFIG_HOTPLUG_CPU 1
     3.6  
     3.7 -/*
     3.8 - * Avoid deep recursion when tearing down pagetables during domain destruction,
     3.9 - * causing dom0 to become unresponsive and Xen to miss time-critical softirq
    3.10 - * deadlines. This will ultimately be replaced by built-in preemptibility of
    3.11 - * get_page_type().
    3.12 - */
    3.13 -#define DOMAIN_DESTRUCT_AVOID_RECURSION 1
    3.14 -
    3.15  #define HZ 100
    3.16  
    3.17  #define OPT_CONSOLE_STR "vga"