From: Dongxiao Xu <dongxiao.xu@intel.com>
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
Subject: [PATCH v10 4/6] x86: enable CQM monitoring for each domain RMID
Date: Wed, 26 Mar 2014 14:35:20 +0800 [thread overview]
Message-ID: <1395815722-143165-5-git-send-email-dongxiao.xu@intel.com> (raw)
In-Reply-To: <1395815722-143165-1-git-send-email-dongxiao.xu@intel.com>
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 <andrew.cooper3@citrix.com>
Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
Signed-off-by: Jiongxi Li <jiongxi.li@intel.com>
---
xen/arch/x86/domain.c | 5 +++++
xen/arch/x86/pqos/cqm.c | 21 +++++++++++++++++++++
xen/include/asm-x86/msr-index.h | 1 +
xen/include/asm-x86/pqos.h | 6 ++++++
4 files changed, 33 insertions(+)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 3ea9402..e256cbb 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1380,6 +1380,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->rmid_inuse )
+ cqm_assoc_rmid(0);
p->arch.ctxt_switch_from(p);
}
@@ -1404,6 +1406,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/cqm.c b/xen/arch/x86/pqos/cqm.c
index 4913975..7a936e0 100644
--- a/xen/arch/x86/pqos/cqm.c
+++ b/xen/arch/x86/pqos/cqm.c
@@ -24,6 +24,7 @@
#include <asm/pqos.h>
struct pqos_cqm *__read_mostly cqm = NULL;
+static DEFINE_PER_CPU(struct pqr_assoc, pqr_assoc);
static int cqm_add_socket(int socket)
{
@@ -260,6 +261,26 @@ void get_cqm_info(const cpumask_t *cpu_cqmdata_map)
on_selected_cpus(cpu_cqmdata_map, read_cqm_data, NULL, 1);
}
+void cqm_assoc_rmid(unsigned int rmid)
+{
+ uint64_t val;
+ uint64_t new_val;
+
+ if ( !this_cpu(pqr_assoc).initialized )
+ {
+ rdmsrl(MSR_IA32_PQR_ASSOC, this_cpu(pqr_assoc).val);
+ this_cpu(pqr_assoc).initialized = 1;
+ }
+ val = this_cpu(pqr_assoc).val;
+
+ new_val = (val & ~cqm->rmid_mask) | (rmid & cqm->rmid_mask);
+ if ( val != new_val )
+ {
+ wrmsrl(MSR_IA32_PQR_ASSOC, new_val);
+ this_cpu(pqr_assoc).val = 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 847aeb9..1fc90a6 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -485,5 +485,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 55b5187..83c6ac6 100644
--- a/xen/include/asm-x86/pqos.h
+++ b/xen/include/asm-x86/pqos.h
@@ -47,6 +47,11 @@ struct pqos_cqm {
};
extern struct pqos_cqm *cqm;
+struct pqr_assoc {
+ uint64_t val;
+ bool_t initialized;
+};
+
static inline bool_t system_supports_cqm(void)
{
return !!cqm;
@@ -58,5 +63,6 @@ void __init init_cqm(unsigned int rmid_max, unsigned long rmid_mask);
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
next prev parent reply other threads:[~2014-03-26 6:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-26 6:35 [PATCH v10 0/6] enable Cache QoS Monitoring (CQM) feature Dongxiao Xu
2014-03-26 6:35 ` [PATCH v10 1/6] x86: detect and initialize Cache QoS Monitoring feature Dongxiao Xu
2014-03-31 14:21 ` Jan Beulich
2014-03-31 15:33 ` Xu, Dongxiao
2014-03-31 15:42 ` Jan Beulich
2014-04-02 2:17 ` Xu, Dongxiao
2014-04-02 8:36 ` Jan Beulich
2014-04-02 12:40 ` Xu, Dongxiao
2014-04-02 14:48 ` Jan Beulich
2014-04-03 3:54 ` Xu, Dongxiao
2014-04-03 8:18 ` Jan Beulich
2014-04-03 8:27 ` Xu, Dongxiao
2014-04-03 8:46 ` Jan Beulich
2014-04-03 11:04 ` Xu, Dongxiao
2014-03-26 6:35 ` [PATCH v10 2/6] x86: dynamically attach/detach CQM service for a guest Dongxiao Xu
2014-04-02 15:24 ` Jan Beulich
2014-04-03 4:49 ` Xu, Dongxiao
2014-03-26 6:35 ` [PATCH v10 3/6] x86: collect CQM information from all sockets Dongxiao Xu
2014-04-02 15:35 ` Jan Beulich
2014-03-26 6:35 ` Dongxiao Xu [this message]
2014-03-26 6:35 ` [PATCH v10 5/6] xsm: add platform QoS related xsm policies Dongxiao Xu
2014-03-26 6:35 ` [PATCH v10 6/6] tools: enable Cache QoS Monitoring feature for libxl/libxc Dongxiao Xu
2014-03-27 15:13 ` Ian Campbell
2014-03-28 0:53 ` Xu, Dongxiao
2014-03-28 9:43 ` Ian Campbell
2014-04-03 11:31 ` Xu, Dongxiao
2014-04-03 12:52 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395815722-143165-5-git-send-email-dongxiao.xu@intel.com \
--to=dongxiao.xu@intel.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).