ia64/xen-unstable

changeset 16191:f9772037c2e7

[IA64] Prevent softlock when destroying VTi domain

Prevent softlock up when VTi domain destruction by making
relinquish_memory() continuable. It was assumed that
mm_teardown() frees most of page_list so that the list which
is passed to relinquish_memory() is short. However the
assumption isn't true for VTi domain case because qemu-dm
maps all the domain pages. To avoid softlock up message,
make relinquish_memory() continuable.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Tue Oct 23 10:21:31 2007 -0600 (2007-10-23)
parents d105b8c30b7d
children 2ad8550033cb
files xen/arch/ia64/xen/domain.c xen/include/asm-ia64/domain.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Mon Oct 22 13:57:08 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Tue Oct 23 10:21:31 2007 -0600
     1.3 @@ -584,7 +584,9 @@ int arch_domain_create(struct domain *d)
     1.4  		goto fail_nomem;
     1.5  
     1.6  	memset(&d->arch.mm, 0, sizeof(d->arch.mm));
     1.7 +	d->arch.relres = RELRES_not_started;
     1.8  	d->arch.mm_teardown_offset = 0;
     1.9 +	INIT_LIST_HEAD(&d->arch.relmem_list);
    1.10  
    1.11  	if ((d->arch.mm.pgd = pgd_alloc(&d->arch.mm)) == NULL)
    1.12  	    goto fail_nomem;
    1.13 @@ -1495,13 +1497,14 @@ int arch_set_info_guest(struct vcpu *v, 
    1.14  	return rc;
    1.15  }
    1.16  
    1.17 -static void relinquish_memory(struct domain *d, struct list_head *list)
    1.18 +static int relinquish_memory(struct domain *d, struct list_head *list)
    1.19  {
    1.20      struct list_head *ent;
    1.21      struct page_info *page;
    1.22  #ifndef __ia64__
    1.23      unsigned long     x, y;
    1.24  #endif
    1.25 +    int               ret = 0;
    1.26  
    1.27      /* Use a recursive lock, as we may enter 'free_domheap_page'. */
    1.28      spin_lock_recursive(&d->page_alloc_lock);
    1.29 @@ -1514,6 +1517,7 @@ static void relinquish_memory(struct dom
    1.30          {
    1.31              /* Couldn't get a reference -- someone is freeing this page. */
    1.32              ent = ent->next;
    1.33 +            list_move_tail(&page->list, &d->arch.relmem_list);
    1.34              continue;
    1.35          }
    1.36  
    1.37 @@ -1550,35 +1554,72 @@ static void relinquish_memory(struct dom
    1.38          /* Follow the list chain and /then/ potentially free the page. */
    1.39          ent = ent->next;
    1.40          BUG_ON(get_gpfn_from_mfn(page_to_mfn(page)) != INVALID_M2P_ENTRY);
    1.41 +        list_move_tail(&page->list, &d->arch.relmem_list);
    1.42          put_page(page);
    1.43 +
    1.44 +        if (hypercall_preempt_check()) {
    1.45 +                ret = -EAGAIN;
    1.46 +                goto out;
    1.47 +        }
    1.48      }
    1.49  
    1.50 +    list_splice_init(&d->arch.relmem_list, list);
    1.51 +
    1.52 + out:
    1.53      spin_unlock_recursive(&d->page_alloc_lock);
    1.54 +    return ret;
    1.55  }
    1.56  
    1.57  int domain_relinquish_resources(struct domain *d)
    1.58  {
    1.59 -    int ret;
    1.60 -    /* Relinquish guest resources for VT-i domain. */
    1.61 -    if (d->arch.is_vti)
    1.62 -	    vmx_relinquish_guest_resources(d);
    1.63 -
    1.64 -    /* Tear down shadow mode stuff. */
    1.65 -    ret = mm_teardown(d);
    1.66 -    if (ret != 0)
    1.67 -        return ret;
    1.68 +	int ret = 0;
    1.69  
    1.70 -    /* Relinquish every page of memory. */
    1.71 -    relinquish_memory(d, &d->xenpage_list);
    1.72 -    relinquish_memory(d, &d->page_list);
    1.73 +	switch (d->arch.relres) {
    1.74 +	case RELRES_not_started:
    1.75 +		/* Relinquish guest resources for VT-i domain. */
    1.76 +		if (d->arch.is_vti)
    1.77 +			vmx_relinquish_guest_resources(d);
    1.78 +		d->arch.relres = RELRES_mm_teardown;
    1.79 +		/*fallthrough*/
    1.80  
    1.81 -    if (d->arch.is_vti && d->arch.sal_data)
    1.82 -	    xfree(d->arch.sal_data);
    1.83 +	case RELRES_mm_teardown:
    1.84 +		/* Tear down shadow mode stuff. */
    1.85 +		ret = mm_teardown(d);
    1.86 +		if (ret != 0)
    1.87 +			return ret;
    1.88 +		d->arch.relres = RELRES_xen;
    1.89 +		/* fallthrough */
    1.90  
    1.91 -    /* Free page used by xen oprofile buffer */
    1.92 -    free_xenoprof_pages(d);
    1.93 +	case RELRES_xen:
    1.94 +		/* Relinquish every xen page of memory. */
    1.95 +		ret = relinquish_memory(d, &d->xenpage_list);
    1.96 +		if (ret != 0)
    1.97 +			return ret;
    1.98 +		d->arch.relres = RELRES_dom;
    1.99 +		/* fallthrough */
   1.100  
   1.101 -    return 0;
   1.102 +	case RELRES_dom:
   1.103 +		/* Relinquish every domain page of memory. */
   1.104 +		ret = relinquish_memory(d, &d->page_list);
   1.105 +		if (ret != 0)
   1.106 +			return ret;
   1.107 +		d->arch.relres = RELRES_done;
   1.108 +		/* fallthrough */    
   1.109 +
   1.110 +	case RELRES_done:
   1.111 +		break;
   1.112 +
   1.113 +	default:
   1.114 +		BUG();
   1.115 +	}
   1.116 +
   1.117 +	if (d->arch.is_vti && d->arch.sal_data)
   1.118 +		xfree(d->arch.sal_data);
   1.119 +
   1.120 +	/* Free page used by xen oprofile buffer */
   1.121 +	free_xenoprof_pages(d);
   1.122 +
   1.123 +	return 0;
   1.124  }
   1.125  
   1.126  unsigned long
     2.1 --- a/xen/include/asm-ia64/domain.h	Mon Oct 22 13:57:08 2007 -0600
     2.2 +++ b/xen/include/asm-ia64/domain.h	Tue Oct 23 10:21:31 2007 -0600
     2.3 @@ -192,7 +192,17 @@ struct arch_domain {
     2.4  #endif
     2.5  
     2.6      /* for domctl_destroy_domain continuation */
     2.7 +    enum {
     2.8 +        RELRES_not_started,
     2.9 +        RELRES_mm_teardown,
    2.10 +        RELRES_xen,
    2.11 +        RELRES_dom,
    2.12 +        RELRES_done,
    2.13 +    } relres;
    2.14 +    /* Continuable mm_teardown() */
    2.15      unsigned long mm_teardown_offset;
    2.16 +    /* Continuable domain_relinquish_resources() */
    2.17 +    struct list_head relmem_list;
    2.18  };
    2.19  #define INT_ENABLE_OFFSET(v) 		  \
    2.20      (sizeof(vcpu_info_t) * (v)->vcpu_id + \