From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: [PATCH v4 14/17] x86/VPMU: Save VPMU state for PV guests during context switch Date: Tue, 21 Jan 2014 14:08:59 -0500 Message-ID: <1390331342-3967-15-git-send-email-boris.ostrovsky@oracle.com> References: <1390331342-3967-1-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1390331342-3967-1-git-send-email-boris.ostrovsky@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: keir@xen.org, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, eddie.dong@intel.com, dietmar.hahn@ts.fujitsu.com, JBeulich@suse.com, jun.nakajima@intel.com, boris.ostrovsky@oracle.com List-Id: xen-devel@lists.xenproject.org Save VPMU state during context switch for both HVM and PV guests unless we are in PMU privileged mode (i.e. dom0 is doing all profiling) and the switched out domain is not the control domain. The latter condition is needed because me may have just turned the privileged PMU mode on and thus need to save last domain. Signed-off-by: Boris Ostrovsky --- xen/arch/x86/domain.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 25572d5..124c0e7 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1444,17 +1444,16 @@ void context_switch(struct vcpu *prev, struct vcpu *next) } if (prev != next) - update_runstate_area(prev); - - if ( is_hvm_vcpu(prev) ) { - if (prev != next) + update_runstate_area(prev); + if ( !(vpmu_mode & XENPMU_MODE_PRIV) || + !is_control_domain(prev->domain) ) vpmu_save(prev); - - if ( !list_empty(&prev->arch.hvm_vcpu.tm_list) ) - pt_save_timer(prev); } + if ( is_hvm_vcpu(prev) && !list_empty(&prev->arch.hvm_vcpu.tm_list) ) + pt_save_timer(prev); + local_irq_disable(); set_current(next); @@ -1491,7 +1490,7 @@ void context_switch(struct vcpu *prev, struct vcpu *next) (next->domain->domain_id != 0)); } - if (is_hvm_vcpu(next) && (prev != next) ) + if ( (prev != next) && !(vpmu_mode & XENPMU_MODE_PRIV) ) /* Must be done with interrupts enabled */ vpmu_load(next); -- 1.8.1.4