From: "Niraj Tolia" Subject: [PATCH] Fix Xen panic with oprofile Date: Tue, 2 Dec 2008 00:52:00 -0800 Message-ID: <7e45e2ac0812020052n179d5a9aw490cc776affa7ab7@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 Developers , xen-ia64-devel@lists.xensource.com Cc: "Santos, Jose Renato G" , "Monchiero, Matteo" List-Id: xen-devel@lists.xenproject.org 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 Signed-off-by: Niraj Tolia diff -r 18eff064c628 xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Fri Aug 22 10:45:19 2008 +0100 +++ b/xen/arch/ia64/xen/domain.c Mon Dec 01 23:52:14 2008 -0800 @@ -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; } diff -r 18eff064c628 xen/arch/x86/domain.c --- a/xen/arch/x86/domain.c Fri Aug 22 10:45:19 2008 +0100 +++ b/xen/arch/x86/domain.c Mon Dec 01 23:52:14 2008 -0800 @@ -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); diff -r 18eff064c628 xen/common/domain.c --- a/xen/common/domain.c Fri Aug 22 10:45:19 2008 +0100 +++ b/xen/common/domain.c Mon Dec 01 23:52:14 2008 -0800 @@ -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);