From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dongxiao Xu Subject: [PATCH v9 4/6] x86: enable CQM monitoring for each domain RMID Date: Wed, 19 Feb 2014 14:32:42 +0800 Message-ID: <1392791564-37170-5-git-send-email-dongxiao.xu@intel.com> References: <1392791564-37170-1-git-send-email-dongxiao.xu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1392791564-37170-1-git-send-email-dongxiao.xu@intel.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, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com, JBeulich@suse.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org If the CQM service is attached to a domain, its related RMID will be set to hardware for monitoring when the domain's vcpu is scheduled in. When the domain's vcpu is scheduled out, RMID 0 (system reserved) will be set for monitoring. Reviewed-by: Andrew Cooper Signed-off-by: Jiongxi Li Signed-off-by: Dongxiao Xu --- xen/arch/x86/domain.c | 5 +++++ xen/arch/x86/pqos.c | 14 ++++++++++++++ xen/include/asm-x86/msr-index.h | 1 + xen/include/asm-x86/pqos.h | 1 + 4 files changed, 21 insertions(+) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 2656204..9eeedf0 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1372,6 +1372,8 @@ static void __context_switch(void) { memcpy(&p->arch.user_regs, stack_regs, CTXT_SWITCH_STACK_BYTES); vcpu_save_fpu(p); + if ( system_supports_cqm() && cqm->used_rmid ) + cqm_assoc_rmid(0); p->arch.ctxt_switch_from(p); } @@ -1396,6 +1398,9 @@ static void __context_switch(void) } vcpu_restore_fpu_eager(n); n->arch.ctxt_switch_to(n); + + if ( system_supports_cqm() && n->domain->arch.pqos_cqm_rmid > 0 ) + cqm_assoc_rmid(n->domain->arch.pqos_cqm_rmid); } gdt = !is_pv_32on64_vcpu(n) ? per_cpu(gdt_table, cpu) : diff --git a/xen/arch/x86/pqos.c b/xen/arch/x86/pqos.c index 2cde56e..7369e10 100644 --- a/xen/arch/x86/pqos.c +++ b/xen/arch/x86/pqos.c @@ -62,6 +62,7 @@ static void __init parse_pqos_param(char *s) custom_param("pqos", parse_pqos_param); struct pqos_cqm __read_mostly *cqm = NULL; +static uint64_t __read_mostly rmid_mask; static void __init init_cqm(void) { @@ -135,6 +136,8 @@ static void __init init_qos_monitor(void) cpuid_count(0xf, 0, &eax, &ebx, &ecx, &qm_features); + rmid_mask = ~(~0ull << get_count_order(ebx)); + if ( opt_cqm && (qm_features & QOS_MONITOR_TYPE_L3) ) init_cqm(); } @@ -248,6 +251,17 @@ void get_cqm_info(const cpumask_t *cpu_cqmdata_map) } +void cqm_assoc_rmid(unsigned int rmid) +{ + uint64_t val; + uint64_t new_val; + + rdmsrl(MSR_IA32_PQR_ASSOC, val); + new_val = (val & ~rmid_mask) | (rmid & rmid_mask); + if ( val != new_val ) + wrmsrl(MSR_IA32_PQR_ASSOC, new_val); +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h index e3ff10c..13800e6 100644 --- a/xen/include/asm-x86/msr-index.h +++ b/xen/include/asm-x86/msr-index.h @@ -492,5 +492,6 @@ /* Platform QoS register */ #define MSR_IA32_QOSEVTSEL 0x00000c8d #define MSR_IA32_QMC 0x00000c8e +#define MSR_IA32_PQR_ASSOC 0x00000c8f #endif /* __ASM_MSR_INDEX_H */ diff --git a/xen/include/asm-x86/pqos.h b/xen/include/asm-x86/pqos.h index 4372af6..87820d5 100644 --- a/xen/include/asm-x86/pqos.h +++ b/xen/include/asm-x86/pqos.h @@ -54,5 +54,6 @@ void init_platform_qos(void); int alloc_cqm_rmid(struct domain *d); void free_cqm_rmid(struct domain *d); void get_cqm_info(const cpumask_t *cpu_cqmdata_map); +void cqm_assoc_rmid(unsigned int rmid); #endif -- 1.7.9.5