From: Boris Ostrovsky Subject: [PATCH v9 18/20] x86/VPMU: Save VPMU state for PV guests during context switch Date: Fri, 8 Aug 2014 12:55:44 -0400 Message-ID: <1407516946-17833-19-git-send-email-boris.ostrovsky@oracle.com> References: <1407516946-17833-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: <1407516946-17833-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: jbeulich@suse.com, kevin.tian@intel.com, suravee.suthikulpanit@amd.com Cc: keir@xen.org, andrew.cooper3@citrix.com, tim@xen.org, xen-devel@lists.xen.org, 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). Signed-off-by: Boris Ostrovsky --- xen/arch/x86/domain.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index a810d1c..47469ec 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1478,17 +1478,15 @@ void context_switch(struct vcpu *prev, struct vcpu *next) } if ( prev != next ) - _update_runstate_area(prev); - - if ( is_hvm_vcpu(prev) ) { - if ( (prev != next) && (vpmu_mode & XENPMU_MODE_SELF) ) + _update_runstate_area(prev); + if ( vpmu_mode & XENPMU_MODE_SELF ) 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); @@ -1526,12 +1524,12 @@ void context_switch(struct vcpu *prev, struct vcpu *next) !is_hardware_domain(next->domain)); } - if ( is_hvm_vcpu(next) && (prev != next) && (vpmu_mode & XENPMU_MODE_SELF) ) + context_saved(prev); + + if ( (prev != next) && (vpmu_mode & XENPMU_MODE_SELF) ) /* Must be done with interrupts enabled */ vpmu_load(next); - context_saved(prev); - if ( prev != next ) _update_runstate_area(next); -- 1.8.1.4