From: "Jan Beulich" Subject: [PATCH] x86: eliminate domain cleanup hack Date: Thu, 30 Oct 2008 09:48:11 +0000 Message-ID: <490990EB.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org ... in favor of using the preemptable flavors of the respective functions. Signed-off-by: Jan Beulich Index: 2008-10-27/xen/arch/x86/domain.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/arch/x86/domain.c 2008-10-29 17:10:03.0000000= 00 +0100 +++ 2008-10-27/xen/arch/x86/domain.c 2008-10-29 17:10:41.000000000 = +0100 @@ -1639,32 +1639,23 @@ static int relinquish_memory( } =20 if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) - put_page_and_type(page); + ret =3D put_page_and_type_preemptible(page, 1); + switch ( ret ) + { + case 0: + break; + case -EAGAIN: + case -EINTR: + set_bit(_PGT_pinned, &page->u.inuse.type_info); + put_page(page); + goto out; + default: + BUG(); + } =20 if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) put_page(page); =20 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - /* - * Forcibly drop reference counts of page tables above top most = (which - * were skipped to prevent long latencies due to deep recursion - = see - * the special treatment in free_lX_table()). - */ - y =3D page->u.inuse.type_info; - if ( (type < PGT_root_page_table) && - unlikely(((y + PGT_type_mask) & - (PGT_type_mask|PGT_validated)) =3D=3D type) ) - { - BUG_ON((y & PGT_count_mask) >=3D - (page->count_info & PGC_count_mask)); - while ( y & PGT_count_mask ) - { - put_page_and_type(page); - y =3D page->u.inuse.type_info; - } - } -#endif - /* * Forcibly invalidate top-most, still valid page tables at this = point * to break circular 'linear page table' references as well as = clean up @@ -1685,8 +1676,23 @@ static int relinquish_memory( x & ~(PGT_validated|PGT_partial)); if ( likely(y =3D=3D x) ) { - if ( free_page_type(page, x, 0) !=3D 0 ) + /* No need for atomic update of type_info here: noone = else updates it. */ + switch ( ret =3D free_page_type(page, x, 1) ) + { + case 0: + break; + case -EINTR: + page->u.inuse.type_info |=3D PGT_validated; + put_page(page); + ret =3D -EAGAIN; + goto out; + case -EAGAIN: + page->u.inuse.type_info |=3D PGT_partial; + put_page(page); + goto out; + default: BUG(); + } if ( x & PGT_partial ) page->u.inuse.type_info--; break; @@ -1833,11 +1839,6 @@ int domain_relinquish_resources(struct d /* fallthrough */ =20 case RELMEM_done: -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - ret =3D relinquish_memory(d, &d->page_list, PGT_l1_page_table); - if ( ret ) - return ret; -#endif break; =20 default: Index: 2008-10-27/xen/arch/x86/mm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/arch/x86/mm.c 2008-10-28 14:42:09.000000000 = +0100 +++ 2008-10-27/xen/arch/x86/mm.c 2008-10-28 14:53:16.000000000 = +0100 @@ -1343,7 +1343,7 @@ static void free_l1_table(struct page_in =20 static int free_l2_table(struct page_info *page, int preemptible) { -#if defined(CONFIG_COMPAT) || defined(DOMAIN_DESTRUCT_AVOID_RECURSION) +#ifdef CONFIG_COMPAT struct domain *d =3D page_get_owner(page); #endif unsigned long pfn =3D page_to_mfn(page); @@ -1351,11 +1351,6 @@ static int free_l2_table(struct page_inf unsigned int i =3D page->nr_validated_ptes - 1; int err =3D 0; =20 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - if ( d->arch.relmem =3D=3D RELMEM_l3 ) - return 0; -#endif - pl2e =3D map_domain_page(pfn); =20 ASSERT(page->nr_validated_ptes); @@ -1385,11 +1380,6 @@ static int free_l3_table(struct page_inf unsigned int i =3D page->nr_validated_ptes - !page->partial_pte; int rc =3D 0; =20 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - if ( d->arch.relmem =3D=3D RELMEM_l4 ) - return 0; -#endif - pl3e =3D map_domain_page(pfn); =20 do { Index: 2008-10-27/xen/include/asm-x86/config.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/include/asm-x86/config.h 2008-10-29 = 17:09:06.000000000 +0100 +++ 2008-10-27/xen/include/asm-x86/config.h 2008-10-28 14:53:16.0000000= 00 +0100 @@ -41,14 +41,6 @@ #define CONFIG_HOTPLUG 1 #define CONFIG_HOTPLUG_CPU 1 =20 -/* - * Avoid deep recursion when tearing down pagetables during domain = destruction, - * causing dom0 to become unresponsive and Xen to miss time-critical = softirq - * deadlines. This will ultimately be replaced by built-in preemptibility = of - * get_page_type(). - */ -#define DOMAIN_DESTRUCT_AVOID_RECURSION 1 - #define HZ 100 =20 #define OPT_CONSOLE_STR "vga"