Skip to contentSkip to conversation

Fix Xen panic with oprofile

PATCH New Niraj Tolia 1 participant 1 message Dec 2, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix Xen panic with oprofile

The attached patch fixes a Xen panic when a domain is shutdown before oprofile is stopped. Without this patch, free_xenoprof_pages() is called before the domain is destroyed and that, in turn, prevents oprofile from cleaning up pages shared with guests. Shutting down a domain without terminating oprofile therefore causes a Xen panic at a later point in time.

The patch was generated against Xen 3.3.0 but will cleanly apply to both xen-3.3-testing and xen-unstable. It has only been tested on x86_32 but the ia64 portion of it should (hopefully) be obvious.

Note that I needed to backport the patch from [1] to get samples on my processor (Xeon X5355) but, as the patch doesn't seem to have gone into mainline yet [2], I am holding off on submitting it here.

Cheers,
Niraj

[1] http://lkml.org/lkml/2008/11/11/62
[2] http://lkml.org/lkml/2008/11/17/282

xen/arch/ia64/xen/domain.c +0 -3
diff -r 18eff064c628 xen/arch/ia64/xen/domain.c
@@ -1673,9 +1673,6 @@ int domain_relinquish_resources(struct d
 	if (is_hvm_domain(d) && d->arch.sal_data)
 		xfree(d->arch.sal_data);
 
-	/* Free page used by xen oprofile buffer */
-	free_xenoprof_pages(d);
-
 	return 0;
 }
 
xen/arch/x86/domain.c +0 -3
diff -r 18eff064c628 xen/arch/x86/domain.c
@@ -1817,9 +1817,6 @@ int domain_relinquish_resources(struct d
         BUG();
     }
 
-    /* Free page used by xen oprofile buffer. */
-    free_xenoprof_pages(d);
-
     if ( is_hvm_domain(d) )
         hvm_domain_relinquish_resources(d);
 
xen/common/domain.c +3 -0
diff -r 18eff064c628 xen/common/domain.c
@@ -534,6 +534,9 @@ static void complete_domain_destroy(stru
 
     sched_destroy_domain(d);
 
+    /* Free page used by xen oprofile buffer. */
+    free_xenoprof_pages(d);
+
     for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- )
         if ( (v = d->vcpu[i]) != NULL )
             free_vcpu_struct(v);