Skip to contentSkip to conversation

enable Cache QoS Monitoring (CQM) feature

PATCH Superseded Dongxiao Xu 3 participants 33 messages Dec 5, 2013 – Jan 28, 2014

v6 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v6 cover enable Cache QoS Monitoring (CQM) feature

Changes from v5:
- Address comments from Dario Faggioli, including:
* Define a new libxl_cqminfo structure to avoid reference of xc structure in libxl functions.
* Use LOGE() instead of the LIBXL__LOG() functions.

Changes from v4:
- When comparing xl cqm parameter, use strcmp instead of strncmp, otherwise, "xl pqos-attach cqmabcd domid" will be considered as a valid command line.
- Address comments from Andrew Cooper, including:
* Adjust the pqos parameter parsing function.
* Modify the pqos related documentation.
* Add a check for opt_cqm_max_rmid in initialization code.
* Do not IPI CPU that is in same socket with current CPU.
- Address comments from Dario Faggioli, including:
* Fix an typo in export symbols.
* Return correct libxl error code for qos related functions.
* Abstract the error printing logic into a function.
- Address comment from Daniel De Graaf, including:
* Add return value in for pqos related check.
- Address comments from Konrad Rzeszutek Wilk, including:
* Modify the GPLv2 related file header, remove the address.

Changes from v3:
- Use structure to better organize CQM related global variables.
- Address comments from Andrew Cooper, including:
* Remove the domain creation flag for CQM RMID allocation.
* Adjust the boot parameter format, use custom_param().
* Add documentation for the new added boot parameter.
* Change QoS type flag to be uint64_t.
* Initialize the per socket cpu bitmap in system boot time.
* Remove get_cqm_avail() function.
* Misc of format changes.
- Address comment from Daniel De Graaf, including:
* Use avc_current_has_perm() for XEN2__PQOS_OP that belongs to SECCLASS_XEN2.

Changes from v2:
- Address comments from Andrew Cooper, including:
* Merging tools stack changes into one patch.
* Reduce the IPI number to one per socket.
* Change structures for CQM data exchange between tools and Xen.
* Misc of format/variable/function name changes.
- Address comments from Konrad Rzeszutek Wilk, including:
* Simplify the error printing logic.
* Add xsm check for the new added hypercalls.

Changes from v1:
- Address comments from Andrew Cooper, including:
* Change function names, e.g., alloc_cqm_rmid(), system_supports_cqm(), etc.
* Change some structure element order to save packing cost.
* Correct some function's return value.
* Some programming styles change.
* ...

Future generations of Intel Xeon processor may offer monitoring capability in each logical processor to measure specific quality-of-service metric, for example, the Cache QoS Monitoring to get L3 cache occupancy. Detailed information please refer to Intel SDM chapter 17.14.

Cache QoS Monitoring provides a layer of abstraction between applications and logical processors through the use of Resource Monitoring IDs (RMIDs). In Xen design, each guest in the system can be assigned an RMID independently, while RMID=0 is reserved for monitoring domains that doesn't enable CQM service. When any of the domain's vcpu is scheduled on a logical processor, the domain's RMID will be activated by programming the value into one specific MSR, and when the vcpu is scheduled out, a RMID=0 will be programmed into that MSR. The Cache QoS Hardware tracks cache utilization of memory accesses according to the RMIDs and reports monitored data via a counter register. With this solution, we can get the knowledge how much L3 cache is used by a certain guest.

To attach CQM service to a certain guest, two approaches are provided:
1) Create the guest with "pqos_cqm=1" set in configuration file.
2) Use "xl pqos-attach cqm domid" for a running guest.

To detached CQM service from a guest, users can:
1) Use "xl pqos-detach cqm domid" for a running guest.
2) Also destroying a guest will detach the CQM service.

To get the L3 cache usage, users can use the command of:

$ xl pqos-list cqm (domid)

The below data is just an example showing how the CQM related data is exposed to end user.

[root@localhost]# xl pqos-list cqm
Name               ID  SocketID        L3C_Usage       SocketID        L3C_Usage
Domain-0            0         0         20127744              1         25231360
ExampleHVMDomain    1         0          3211264              1         10551296

RMID count 56 RMID available 53

Dongxiao Xu (7):
x86: detect and initialize Cache QoS Monitoring feature
x86: dynamically attach/detach CQM service for a guest
x86: initialize per socket cpu map
x86: collect CQM information from all sockets
x86: enable CQM monitoring for each domain RMID
xsm: add platform QoS related xsm policies
tools: enable Cache QoS Monitoring feature for libxl/libxc

 docs/misc/xen-command-line.markdown          |    7 +
 tools/flask/policy/policy/modules/xen/xen.if |    2 +-
 tools/flask/policy/policy/modules/xen/xen.te |    5 +-
 tools/libxc/xc_domain.c                      |   47 +++++
 tools/libxc/xenctrl.h                        |   11 ++
 tools/libxl/Makefile                         |    3 +-
 tools/libxl/libxl.h                          |    6 +
 tools/libxl/libxl_pqos.c                     |  163 +++++++++++++++++
 tools/libxl/libxl_types.idl                  |   13 ++
 tools/libxl/xl.h                             |    3 +
 tools/libxl/xl_cmdimpl.c                     |  133 ++++++++++++++
 tools/libxl/xl_cmdtable.c                    |   15 ++
 xen/arch/x86/Makefile                        |    1 +
 xen/arch/x86/cpu/intel.c                     |    6 +
 xen/arch/x86/domain.c                        |    8 +
 xen/arch/x86/domctl.c                        |   40 +++++
 xen/arch/x86/pqos.c                          |  242 ++++++++++++++++++++++++++
 xen/arch/x86/setup.c                         |    3 +
 xen/arch/x86/smp.c                           |    7 +-
 xen/arch/x86/smpboot.c                       |   19 +-
 xen/arch/x86/sysctl.c                        |   65 +++++++
 xen/include/asm-x86/cpufeature.h             |    1 +
 xen/include/asm-x86/domain.h                 |    2 +
 xen/include/asm-x86/msr-index.h              |    5 +
 xen/include/asm-x86/pqos.h                   |   51 ++++++
 xen/include/asm-x86/smp.h                    |    2 +
 xen/include/public/domctl.h                  |   20 +++
 xen/include/public/sysctl.h                  |   10 ++
 xen/include/xen/cpumask.h                    |    1 +
 xen/xsm/flask/hooks.c                        |    8 +
 xen/xsm/flask/policy/access_vectors          |   17 +-
 31 files changed, 907 insertions(+), 9 deletions(-)
 create mode 100644 tools/libxl/libxl_pqos.c
 create mode 100644 xen/arch/x86/pqos.c
 create mode 100644 xen/include/asm-x86/pqos.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v6 1/7 x86: detect and initialize Cache QoS Monitoring feature

Detect platform QoS feature status and enumerate the resource types, one of which is to monitor the L3 cache occupancy.

Also introduce a Xen grub command line parameter to control the QoS feature status.

---
 docs/misc/xen-command-line.markdown |    7 ++
 xen/arch/x86/Makefile               |    1 +
 xen/arch/x86/cpu/intel.c            |    6 ++
 xen/arch/x86/pqos.c                 |  130 +++++++++++++++++++++++++++++++++++
 xen/arch/x86/setup.c                |    3 +
 xen/include/asm-x86/cpufeature.h    |    1 +
 xen/include/asm-x86/pqos.h          |   38 ++++++++++
 7 files changed, 186 insertions(+)
 create mode 100644 xen/arch/x86/pqos.c
 create mode 100644 xen/include/asm-x86/pqos.h
docs/misc/xen-command-line.markdown +7 -0
index 15aa404..7751ffe 100644
@@ -770,6 +770,13 @@ This option can be specified more than once (up to 8 times at present).
 ### ple\_window
 > `= <integer>`
 
+### pqos (Intel)
+> `= List of ( <boolean> | cqm:<boolean> | cqm_max_rmid:<integer> )`
+
+> Default: `pqos=1,cqm:1,cqm_max_rmid:255`
+
+Configure platform QoS services.
+
 ### reboot
 > `= t[riple] | k[bd] | n[o] [, [w]arm | [c]old]`
 
xen/arch/x86/Makefile +1 -0
index d502bdf..54962e0 100644
@@ -58,6 +58,7 @@ obj-y += crash.o
 obj-y += tboot.o
 obj-y += hpet.o
 obj-y += xstate.o
+obj-y += pqos.o
 
 obj-$(crash_debug) += gdbstub.o
 
xen/arch/x86/cpu/intel.c +6 -0
index 27fe762..f0d83ea 100644
@@ -230,6 +230,12 @@ static void __devinit init_intel(struct cpuinfo_x86 *c)
 	     ( c->cpuid_level >= 0x00000006 ) &&
 	     ( cpuid_eax(0x00000006) & (1u<<2) ) )
 		set_bit(X86_FEATURE_ARAT, c->x86_capability);
+
+	/* Check platform QoS monitoring capability */
+	if ((c->cpuid_level >= 0x00000007) &&
+	    (cpuid_ebx(0x00000007) & (1u<<12)))
+		set_bit(X86_FEATURE_QOSM, c->x86_capability);
+
 }
 
 static struct cpu_dev intel_cpu_dev __cpuinitdata = {
xen/arch/x86/pqos.c new file +130 -0

130 lines not on this page · raw message

xen/arch/x86/setup.c +3 -0
index 5bf4ee0..95418e4 100644
@@ -48,6 +48,7 @@
 #include <asm/setup.h>
 #include <xen/cpu.h>
 #include <asm/nmi.h>
+#include <asm/pqos.h>
 
 /* opt_nosmp: If true, secondary processors are ignored. */
 static bool_t __initdata opt_nosmp;
@@ -1402,6 +1403,8 @@ void __init __start_xen(unsigned long mbi_p)
 
     domain_unpause_by_systemcontroller(dom0);
 
+    init_platform_qos();
+
     reset_stack_and_jump(init_done);
 }
 
xen/include/asm-x86/cpufeature.h +1 -0
index 1cfaf94..ca59668 100644
@@ -147,6 +147,7 @@
 #define X86_FEATURE_ERMS	(7*32+ 9) /* Enhanced REP MOVSB/STOSB */
 #define X86_FEATURE_INVPCID	(7*32+10) /* Invalidate Process Context ID */
 #define X86_FEATURE_RTM 	(7*32+11) /* Restricted Transactional Memory */
+#define X86_FEATURE_QOSM	(7*32+12) /* Platform QoS monitoring capability */
 #define X86_FEATURE_NO_FPU_SEL 	(7*32+13) /* FPU CS/DS stored as zero */
 #define X86_FEATURE_SMAP	(7*32+20) /* Supervisor Mode Access Prevention */
 
xen/include/asm-x86/pqos.h new file +38 -0
new file mode 100644
index 0000000..da925db
@@ -0,0 +1,38 @@
+/*
+ * pqos.h: Platform QoS related service for guest.
+ *
+ * Copyright (c) 2013, Intel Corporation
+ * Author: Jiongxi Li  <[email protected]>
+ * Author: Dongxiao Xu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+#ifndef ASM_PQOS_H
+#define ASM_PQOS_H
+
+#include <public/xen.h>
+
+/* QoS Resource Type Enumeration */
+#define QOS_MONITOR_TYPE_L3            0x2
+
+/* QoS Monitoring Event ID */
+#define QOS_MONITOR_EVTID_L3           0x1
+
+struct pqos_cqm {
+    unsigned int min_rmid;
+    unsigned int max_rmid;
+    unsigned int upscaling_factor;
+    domid_t *rmid_to_dom;
+};
+extern struct pqos_cqm *cqm;
+
+void init_platform_qos(void);
+
+#endif
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature

Quoted 125 lines · Dongxiao Xu

Detect platform QoS feature status and enumerate the resource types, one of which is to monitor the L3 cache occupancy.

Also introduce a Xen grub command line parameter to control the QoS feature status.

---
 docs/misc/xen-command-line.markdown |    7 ++
 xen/arch/x86/Makefile               |    1 +
 xen/arch/x86/cpu/intel.c            |    6 ++
 xen/arch/x86/pqos.c                 |  130 +++++++++++++++++++++++++++++++++++
 xen/arch/x86/setup.c                |    3 +
 xen/include/asm-x86/cpufeature.h    |    1 +
 xen/include/asm-x86/pqos.h          |   38 ++++++++++
 7 files changed, 186 insertions(+)
 create mode 100644 xen/arch/x86/pqos.c
 create mode 100644 xen/include/asm-x86/pqos.h
docs/misc/xen-command-line.markdown +7 -0
index 15aa404..7751ffe 100644
@@ -770,6 +770,13 @@ This option can be specified more than once (up to 8 times at present).
 ### ple\_window
 > `= <integer>`
 
+### pqos (Intel)
+> `= List of ( <boolean> | cqm:<boolean> | cqm_max_rmid:<integer> )`
+
+> Default: `pqos=1,cqm:1,cqm_max_rmid:255`
+
+Configure platform QoS services.
+
 ### reboot
 > `= t[riple] | k[bd] | n[o] [, [w]arm | [c]old]`
 
xen/arch/x86/Makefile +1 -0
index d502bdf..54962e0 100644
@@ -58,6 +58,7 @@ obj-y += crash.o
 obj-y += tboot.o
 obj-y += hpet.o
 obj-y += xstate.o
+obj-y += pqos.o
 
 obj-$(crash_debug) += gdbstub.o
 
xen/arch/x86/cpu/intel.c +6 -0
index 27fe762..f0d83ea 100644
@@ -230,6 +230,12 @@ static void __devinit init_intel(struct cpuinfo_x86 *c)
 	     ( c->cpuid_level >= 0x00000006 ) &&
 	     ( cpuid_eax(0x00000006) & (1u<<2) ) )
 		set_bit(X86_FEATURE_ARAT, c->x86_capability);
+
+	/* Check platform QoS monitoring capability */
+	if ((c->cpuid_level >= 0x00000007) &&
+	    (cpuid_ebx(0x00000007) & (1u<<12)))
+		set_bit(X86_FEATURE_QOSM, c->x86_capability);
+
 }
 
 static struct cpu_dev intel_cpu_dev __cpuinitdata = {
xen/arch/x86/pqos.c new file +51 -0
new file mode 100644
index 0000000..d78048a
@@ -0,0 +1,130 @@
+/*
+ * pqos.c: Platform QoS related service for guest.
+ *
+ * Copyright (c) 2013, Intel Corporation
+ * Author: Jiongxi Li  <[email protected]>
+ * Author: Dongxiao Xu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+#include <asm/processor.h>
+#include <xen/init.h>
+#include <asm/pqos.h>
+
+static bool_t __initdata opt_pqos = 1;
+static bool_t __initdata opt_cqm = 1;
+static unsigned int __initdata opt_cqm_max_rmid = 255;
+
+static void __init parse_pqos_param(char *s)
+{
+    char *ss, *val_str;
+    int val;
+
+    do {
+        ss = strchr(s, ',');
+        if ( ss )
+            *ss = '\0';
+
+        val = parse_bool(s);
+        if ( val >= 0 )
+            opt_pqos = val;
+        else
+        {
+            val = !!strncmp(s, "no-", 3);
+            if ( !val )
+                s += 3;
+
+            val_str = strchr(s, ':');
+            if ( val_str )
+                *val_str++ = '\0';
+
+            if ( val_str && !strcmp(s, "cqm") &&
+                 (val = parse_bool(val_str)) >= 0 )
+                opt_cqm = val;
+            else if ( val_str && !strcmp(s, "cqm_max_rmid") )

xen/arch/x86/pqos.c line 61

Quoted 10 lines
xen/arch/x86/pqos.c new file +10 -0
+                opt_cqm_max_rmid = simple_strtoul(val_str, NULL, 0);
+        }
+
+        s = ss + 1;
+    } while ( ss );
+}
+
+custom_param("pqos", parse_pqos_param);
+
+struct pqos_cqm *cqm;

This is not static, so does not live in the BSS. It needs initialising to NULL, so system_supports_cqm() from the following patch doesn't erroneously report true before init_cqm() is called.

~Andrew

Quoted 146 lines
xen/arch/x86/pqos.c new file +69 -0
+
+static void __init init_cqm(void)
+{
+    unsigned int rmid;
+    unsigned int eax, edx;
+
+    if ( !opt_cqm_max_rmid )
+        return;
+
+    cqm = xzalloc(struct pqos_cqm);
+    if ( !cqm )
+        return;
+
+    cpuid_count(0xf, 1, &eax, &cqm->upscaling_factor, &cqm->max_rmid, &edx);
+    if ( !(edx & QOS_MONITOR_EVTID_L3) )
+    {
+        xfree(cqm);
+        return;
+    }
+
+    cqm->min_rmid = 1;
+    cqm->max_rmid = min(opt_cqm_max_rmid, cqm->max_rmid);
+
+    cqm->rmid_to_dom = xmalloc_array(domid_t, cqm->max_rmid + 1);
+    if ( !cqm->rmid_to_dom )
+    {
+        xfree(cqm);
+        return;
+    }
+
+    /* Reserve RMID 0 for all domains not being monitored */
+    cqm->rmid_to_dom[0] = DOMID_XEN;
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+        cqm->rmid_to_dom[rmid] = DOMID_INVALID;
+
+    printk(XENLOG_INFO "Cache QoS Monitoring Enabled.\n");
+}
+
+static void __init init_qos_monitor(void)
+{
+    unsigned int qm_features;
+    unsigned int eax, ebx, ecx;
+
+    if ( !(boot_cpu_has(X86_FEATURE_QOSM)) )
+        return;
+
+    cpuid_count(0xf, 0, &eax, &ebx, &ecx, &qm_features);
+
+    if ( opt_cqm && (qm_features & QOS_MONITOR_TYPE_L3) )
+        init_cqm();
+}
+
+void __init init_platform_qos(void)
+{
+    if ( !opt_pqos )
+        return;
+
+    init_qos_monitor();
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/x86/setup.c +3 -0
index 5bf4ee0..95418e4 100644
@@ -48,6 +48,7 @@
 #include <asm/setup.h>
 #include <xen/cpu.h>
 #include <asm/nmi.h>
+#include <asm/pqos.h>
 
 /* opt_nosmp: If true, secondary processors are ignored. */
 static bool_t __initdata opt_nosmp;
@@ -1402,6 +1403,8 @@ void __init __start_xen(unsigned long mbi_p)
 
     domain_unpause_by_systemcontroller(dom0);
 
+    init_platform_qos();
+
     reset_stack_and_jump(init_done);
 }
 
xen/include/asm-x86/cpufeature.h +1 -0
index 1cfaf94..ca59668 100644
@@ -147,6 +147,7 @@
 #define X86_FEATURE_ERMS	(7*32+ 9) /* Enhanced REP MOVSB/STOSB */
 #define X86_FEATURE_INVPCID	(7*32+10) /* Invalidate Process Context ID */
 #define X86_FEATURE_RTM 	(7*32+11) /* Restricted Transactional Memory */
+#define X86_FEATURE_QOSM	(7*32+12) /* Platform QoS monitoring capability */
 #define X86_FEATURE_NO_FPU_SEL 	(7*32+13) /* FPU CS/DS stored as zero */
 #define X86_FEATURE_SMAP	(7*32+20) /* Supervisor Mode Access Prevention */
 
xen/include/asm-x86/pqos.h new file +38 -0
new file mode 100644
index 0000000..da925db
@@ -0,0 +1,38 @@
+/*
+ * pqos.h: Platform QoS related service for guest.
+ *
+ * Copyright (c) 2013, Intel Corporation
+ * Author: Jiongxi Li  <[email protected]>
+ * Author: Dongxiao Xu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+#ifndef ASM_PQOS_H
+#define ASM_PQOS_H
+
+#include <public/xen.h>
+
+/* QoS Resource Type Enumeration */
+#define QOS_MONITOR_TYPE_L3            0x2
+
+/* QoS Monitoring Event ID */
+#define QOS_MONITOR_EVTID_L3           0x1
+
+struct pqos_cqm {
+    unsigned int min_rmid;
+    unsigned int max_rmid;
+    unsigned int upscaling_factor;
+    domid_t *rmid_to_dom;
+};
+extern struct pqos_cqm *cqm;
+
+void init_platform_qos(void);
+
+#endif
#3 lore raw

Re: [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 1 line · Dongxiao Xu

+struct pqos_cqm *cqm;

This is not static, so does not live in the BSS. It needs initialising to NULL, so system_supports_cqm() from the following patch doesn't erroneously report true before init_cqm() is called.

Since when is such data not in .bss, even more so with -fno-common in place?

Jan

#4 lore raw

Re: [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature

In reply to Dongxiao Xu

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c) · line 238

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/cpu/intel.c +6 -0
@@ -230,6 +230,12 @@ static void __devinit init_intel(struct cpuinfo_x86 *c)
 	     ( c->cpuid_level >= 0x00000006 ) &&
 	     ( cpuid_eax(0x00000006) & (1u<<2) ) )
 		set_bit(X86_FEATURE_ARAT, c->x86_capability);
+
+	/* Check platform QoS monitoring capability */
+	if ((c->cpuid_level >= 0x00000007) &&
+	    (cpuid_ebx(0x00000007) & (1u<<12)))
+		set_bit(X86_FEATURE_QOSM, c->x86_capability);
+

This is redundant with generic_identify() setting the respective c->x86_capability[] element.

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c) · line 239

Quoted 1 line
xen/arch/x86/cpu/intel.c +1 -0
+struct pqos_cqm *cqm;

__read_mostly?

Quoted 7 lines
xen/arch/x86/cpu/intel.c +7 -0
+
+static void __init init_cqm(void)
+{
+    unsigned int rmid;
+    unsigned int eax, edx;
+
+    if ( !opt_cqm_max_rmid )

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c)

Quoted 10 lines
xen/arch/x86/cpu/intel.c +10 -0
+        return;
+
+    cqm = xzalloc(struct pqos_cqm);
+    if ( !cqm )
+        return;
+
+    cpuid_count(0xf, 1, &eax, &cqm->upscaling_factor, &cqm->max_rmid, &edx);
+    if ( !(edx & QOS_MONITOR_EVTID_L3) )
+    {
+        xfree(cqm);

"cqm" is a global variable and - afaict - the only way for other entities to tell whether the functionality is enabled. Hence shouldn't you clear the variable here (and similarly further down)? Otherwise the variable should perhaps be static.

Jan

#5 lore raw

Re: [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature

Quoted 28 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, January 20, 2014 9:01 PM
To: Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c) · line 238

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/cpu/intel.c +6 -0
@@ -230,6 +230,12 @@ static void __devinit init_intel(struct cpuinfo_x86 *c)
 	     ( c->cpuid_level >= 0x00000006 ) &&
 	     ( cpuid_eax(0x00000006) & (1u<<2) ) )
 		set_bit(X86_FEATURE_ARAT, c->x86_capability);
+
+	/* Check platform QoS monitoring capability */
+	if ((c->cpuid_level >= 0x00000007) &&
+	    (cpuid_ebx(0x00000007) & (1u<<12)))
+		set_bit(X86_FEATURE_QOSM, c->x86_capability);
+

This is redundant with generic_identify() setting the respective c->x86_capability[] element.

Quoted 3 lines

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c) · line 239

Quoted 1 line
xen/arch/x86/cpu/intel.c +1 -0
+struct pqos_cqm *cqm;

__read_mostly?

cqm->rmid_to_dom will be updated time to time.

Quoted 16 lines
Quoted 5 lines
xen/arch/x86/cpu/intel.c +4 -0
+
+static void __init init_cqm(void)
+{
+    unsigned int rmid;

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c)

Quoted 10 lines
xen/arch/x86/cpu/intel.c +10 -0
+    unsigned int eax, edx;
+
+    if ( !opt_cqm_max_rmid )
+        return;
+
+    cqm = xzalloc(struct pqos_cqm);
+    if ( !cqm )
+        return;
+
+    cpuid_count(0xf, 1, &eax, &cqm->upscaling_factor, &cqm->max_rmid,

&edx);

Quoted 8 lines

xen/arch/x86/cpu/intel.c

Quoted 3 lines
xen/arch/x86/cpu/intel.c +3 -0
+    if ( !(edx & QOS_MONITOR_EVTID_L3) )
+    {
+        xfree(cqm);

"cqm" is a global variable and - afaict - the only way for other entities to tell whether the functionality is enabled. Hence shouldn't you clear the variable here (and similarly further down)? Otherwise the variable should perhaps be static.

Yes, will correct it in following patches.

Quoted 2 lines

Jan

#6 lore raw

Re: [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature

Quoted 29 lines
Quoted 29 lines
Quoted 1 line · Dongxiao

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, January 20, 2014 9:01 PM
To: Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c) · line 238

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/cpu/intel.c +6 -0
@@ -230,6 +230,12 @@ static void __devinit init_intel(struct cpuinfo_x86 *c)
 	     ( c->cpuid_level >= 0x00000006 ) &&
 	     ( cpuid_eax(0x00000006) & (1u<<2) ) )
 		set_bit(X86_FEATURE_ARAT, c->x86_capability);
+
+	/* Check platform QoS monitoring capability */
+	if ((c->cpuid_level >= 0x00000007) &&
+	    (cpuid_ebx(0x00000007) & (1u<<12)))
+		set_bit(X86_FEATURE_QOSM, c->x86_capability);
+

This is redundant with generic_identify() setting the respective c->x86_capability[] element.

Quoted 4 lines
Quoted 3 lines

xen/arch/x86/cpu/intel.c static void __devinit init_intel(struct cpuinfo_x86 *c) · line 239

Quoted 1 line
xen/arch/x86/cpu/intel.c +1 -0
+struct pqos_cqm *cqm;

__read_mostly?

cqm->rmid_to_dom will be updated time to time.

But the attribute applies to the variable itself, not what it points to.

Jan

#7 lore raw

PATCH v6 2/7 x86: dynamically attach/detach CQM service for a guest

In reply to Dongxiao Xu

Add hypervisor side support for dynamically attach and detach CQM services for a certain guest.

When attach CQM service for a guest, system will allocate an RMID for it. When detach or guest is shutdown, the RMID will be retrieved back for future use.

---
 xen/arch/x86/domain.c        |    3 +++
 xen/arch/x86/domctl.c        |   40 +++++++++++++++++++++++++++++++++
 xen/arch/x86/pqos.c          |   51 ++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/domain.h |    2 ++
 xen/include/asm-x86/pqos.h   |    5 +++++
 xen/include/public/domctl.h  |   11 +++++++++
 6 files changed, 112 insertions(+)
xen/arch/x86/domain.c +3 -0
index a3868f9..90e52a2 100644
@@ -60,6 +60,7 @@
 #include <xen/numa.h>
 #include <xen/iommu.h>
 #include <compat/vcpu.h>
+#include <asm/pqos.h>
 
 DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
 DEFINE_PER_CPU(unsigned long, cr4);
@@ -612,6 +613,8 @@ void arch_domain_destroy(struct domain *d)
 
     free_xenheap_page(d->shared_info);
     cleanup_domain_irq_mapping(d);
+
+    free_cqm_rmid(d);
 }
 
 unsigned long pv_guest_cr4_fixup(const struct vcpu *v, unsigned long guest_cr4)
xen/arch/x86/domctl.c +40 -0
index f7e4586..7007990 100644
@@ -35,6 +35,7 @@
 #include <asm/mem_sharing.h>
 #include <asm/xstate.h>
 #include <asm/debugger.h>
+#include <asm/pqos.h>
 
 static int gdbsx_guest_mem_io(
     domid_t domid, struct xen_domctl_gdbsx_memio *iop)
@@ -1223,6 +1224,45 @@ long arch_do_domctl(
     }
     break;
 
+    case XEN_DOMCTL_attach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+                ret = -EEXIST;
+            else
+            {
+                ret = alloc_cqm_rmid(d);
+                if ( ret < 0 )
+                    ret = -EUSERS;
+            }
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;
+
+    case XEN_DOMCTL_detach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+            {
+                free_cqm_rmid(d);
+                ret = 0;
+            }
+            else
+                ret = -ENOENT;
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;
+
     default:
         ret = iommu_do_domctl(domctl, d, u_domctl);
         break;
xen/arch/x86/pqos.c +51 -0

69 lines not on this page · raw message

xen/include/asm-x86/domain.h +2 -0
index 9d39061..9487251 100644
@@ -313,6 +313,8 @@ struct arch_domain
     spinlock_t e820_lock;
     struct e820entry *e820;
     unsigned int nr_e820;
+
+    unsigned int pqos_cqm_rmid;       /* CQM RMID assigned to the domain */
 } __cacheline_aligned;
 
 #define has_arch_pdevs(d)    (!list_empty(&(d)->arch.pdev_list))
xen/include/asm-x86/pqos.h +5 -0
index da925db..16c4882 100644
@@ -16,6 +16,7 @@
  */
 #ifndef ASM_PQOS_H
 #define ASM_PQOS_H
+#include <xen/sched.h>
 
 #include <public/xen.h>
 
@@ -35,4 +36,8 @@ extern struct pqos_cqm *cqm;
 
 void init_platform_qos(void);
 
+bool_t system_supports_cqm(void);
+int alloc_cqm_rmid(struct domain *d);
+void free_cqm_rmid(struct domain *d);
+
 #endif
xen/include/public/domctl.h +11 -0
index 01a3652..d53e216 100644
@@ -869,6 +869,14 @@ struct xen_domctl_set_max_evtchn {
 typedef struct xen_domctl_set_max_evtchn xen_domctl_set_max_evtchn_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_set_max_evtchn_t);
 
+struct xen_domctl_qos_type {
+#define _XEN_DOMCTL_pqos_cqm      0
+#define XEN_DOMCTL_pqos_cqm       (1U<<_XEN_DOMCTL_pqos_cqm)
+    uint64_t flags;
+};
+typedef struct xen_domctl_qos_type xen_domctl_qos_type_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_qos_type_t);
+
 struct xen_domctl {
     uint32_t cmd;
 #define XEN_DOMCTL_createdomain                   1
@@ -938,6 +946,8 @@ struct xen_domctl {
 #define XEN_DOMCTL_setnodeaffinity               68
 #define XEN_DOMCTL_getnodeaffinity               69
 #define XEN_DOMCTL_set_max_evtchn                70
+#define XEN_DOMCTL_attach_pqos                   71
+#define XEN_DOMCTL_detach_pqos                   72
 #define XEN_DOMCTL_gdbsx_guestmemio            1000
 #define XEN_DOMCTL_gdbsx_pausevcpu             1001
 #define XEN_DOMCTL_gdbsx_unpausevcpu           1002
@@ -998,6 +1008,7 @@ struct xen_domctl {
         struct xen_domctl_set_broken_page_p2m set_broken_page_p2m;
         struct xen_domctl_gdbsx_pauseunp_vcpu gdbsx_pauseunp_vcpu;
         struct xen_domctl_gdbsx_domstatus   gdbsx_domstatus;
+        struct xen_domctl_qos_type          qos_type;
         uint8_t                             pad[128];
     } u;
 };
Signature · 1 line
1.7.9.5
#8 lore raw

Re: [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest

Quoted 8 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/domctl.c +3 -0
@@ -1223,6 +1224,45 @@ long arch_do_domctl(
     }
     break;
 
+    case XEN_DOMCTL_attach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )

xen/arch/x86/domctl.c long arch_do_domctl( · line 1239

Quoted 10 lines
xen/arch/x86/domctl.c +10 -0
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+                ret = -EEXIST;
+            else
+            {
+                ret = alloc_cqm_rmid(d);
+                if ( ret < 0 )
+                    ret = -EUSERS;

Why don't you have the function return a sensible error code (which presumably might also end up being other than -EUSERS, e.g. -ENOMEM).

Quoted 15 lines
xen/arch/x86/domctl.c +15 -0
+            }
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;
+
+    case XEN_DOMCTL_detach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+            {

xen/arch/x86/domctl.c long arch_do_domctl( · line 1264

Quoted 10 lines
xen/arch/x86/domctl.c +10 -0
+                free_cqm_rmid(d);
+                ret = 0;
+            }
+            else
+                ret = -ENOENT;
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;

For consistency, both of the above would better be changed to a single series of if()/else if().../else.

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 126

Quoted 3 lines
xen/arch/x86/pqos.c +3 -0
+bool_t system_supports_cqm(void)
+{
+    return !!cqm;

So here we go (wrt the remark on patch 1).

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 137

Quoted 11 lines
xen/arch/x86/pqos.c +11 -0
+}
+
+int alloc_cqm_rmid(struct domain *d)
+{
+    int rc = 0;
+    unsigned int rmid;
+    unsigned long flags;
+
+    ASSERT(system_supports_cqm());
+
+    spin_lock_irqsave(&cqm_lock, flags);

Why not just spin_lock()? Briefly scanning over the following patches doesn't point out anything that might require this to be an IRQ-safe lock.

Quoted 8 lines
xen/arch/x86/pqos.c +8 -0
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+    {
+        if ( cqm->rmid_to_dom[rmid] != DOMID_INVALID)
+            continue;
+
+        cqm->rmid_to_dom[rmid] = d->domain_id;
+        break;
+    }

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 155

Quoted 10 lines
xen/arch/x86/pqos.c +10 -0
+    spin_unlock_irqrestore(&cqm_lock, flags);
+
+    /* No CQM RMID available, assign RMID=0 by default */
+    if ( rmid > cqm->max_rmid )
+    {
+        rmid = 0;
+        rc = -1;
+    }
+
+    d->arch.pqos_cqm_rmid = rmid;

Is it really safe to do this and the freeing below outside of the lock?

Jan

#9 lore raw

Re: [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest

Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
(quoted diff) +0 -0
@@ -1223,6 +1224,45 @@ long arch_do_domctl(
     }
     break;
 
Quoted 16 lines

xen/arch/x86/domctl.c long arch_do_domctl( · line 1239

Quoted 13 lines
xen/arch/x86/domctl.c +13 -0
+    case XEN_DOMCTL_attach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+                ret = -EEXIST;
+            else
+            {
+                ret = alloc_cqm_rmid(d);
+                if ( ret < 0 )
+                    ret = -EUSERS;

Why don't you have the function return a sensible error code (which presumably might also end up being other than -EUSERS, e.g. -ENOMEM).

-EUSERS is correct here. This failure like this means "all the available system rmid's are already being used by other domains".

~Andrew

Quoted 72 lines
Quoted 16 lines
xen/arch/x86/domctl.c +15 -0
+            }
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;
+
+    case XEN_DOMCTL_detach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+            {

xen/arch/x86/domctl.c long arch_do_domctl( · line 1264

Quoted 10 lines
xen/arch/x86/domctl.c +10 -0
+                free_cqm_rmid(d);
+                ret = 0;
+            }
+            else
+                ret = -ENOENT;
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;

For consistency, both of the above would better be changed to a single series of if()/else if().../else.

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 126

Quoted 3 lines
xen/arch/x86/pqos.c +3 -0
+bool_t system_supports_cqm(void)
+{
+    return !!cqm;

So here we go (wrt the remark on patch 1).

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 137

Quoted 11 lines
xen/arch/x86/pqos.c +11 -0
+}
+
+int alloc_cqm_rmid(struct domain *d)
+{
+    int rc = 0;
+    unsigned int rmid;
+    unsigned long flags;
+
+    ASSERT(system_supports_cqm());
+
+    spin_lock_irqsave(&cqm_lock, flags);

Why not just spin_lock()? Briefly scanning over the following patches doesn't point out anything that might require this to be an IRQ-safe lock.

Quoted 8 lines
xen/arch/x86/pqos.c +8 -0
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+    {
+        if ( cqm->rmid_to_dom[rmid] != DOMID_INVALID)
+            continue;
+
+        cqm->rmid_to_dom[rmid] = d->domain_id;
+        break;
+    }

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 155

Quoted 10 lines
xen/arch/x86/pqos.c +10 -0
+    spin_unlock_irqrestore(&cqm_lock, flags);
+
+    /* No CQM RMID available, assign RMID=0 by default */
+    if ( rmid > cqm->max_rmid )
+    {
+        rmid = 0;
+        rc = -1;
+    }
+
+    d->arch.pqos_cqm_rmid = rmid;

Is it really safe to do this and the freeing below outside of the lock?

Jan

#10 lore raw

Re: [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest

Quoted 24 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
(quoted diff) +0 -0
@@ -1223,6 +1224,45 @@ long arch_do_domctl(
     }
     break;
 
Quoted 16 lines

xen/arch/x86/domctl.c long arch_do_domctl( · line 1239

Quoted 13 lines
xen/arch/x86/domctl.c +13 -0
+    case XEN_DOMCTL_attach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+                ret = -EEXIST;
+            else
+            {
+                ret = alloc_cqm_rmid(d);
+                if ( ret < 0 )
+                    ret = -EUSERS;

Why don't you have the function return a sensible error code (which presumably might also end up being other than -EUSERS, e.g. -ENOMEM).

Quoted 2 lines

-EUSERS is correct here. This failure like this means "all the available system rmid's are already being used by other domains".

I didn't mean to say anything to the contrary with _current_ code. As with any alloc type function, a future change may involve other than just a RMID allocation, and hence -ENOMEM may become possible.

Jan

#11 lore raw

Re: [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest

In reply to Jan Beulich
Quoted 25 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, January 20, 2014 9:14 PM
To: Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest

Quoted 14 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/domctl.c +9 -0
@@ -1223,6 +1224,45 @@ long arch_do_domctl(
     }
     break;
 
+    case XEN_DOMCTL_attach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+                ret = -EEXIST;
+            else
Quoted 8 lines

xen/arch/x86/domctl.c long arch_do_domctl( · line 1239

Quoted 4 lines
xen/arch/x86/domctl.c +4 -0
+            {
+                ret = alloc_cqm_rmid(d);
+                if ( ret < 0 )
+                    ret = -EUSERS;

Why don't you have the function return a sensible error code (which presumably might also end up being other than -EUSERS, e.g. -ENOMEM).

For the assignment of RMID, I don't think there will be error of ENOMEM, so I think EUSER will be better here?

Quoted 27 lines
Quoted 16 lines
xen/arch/x86/domctl.c +15 -0
+            }
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;
+
+    case XEN_DOMCTL_detach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+            {

xen/arch/x86/domctl.c long arch_do_domctl( · line 1264

Quoted 10 lines
xen/arch/x86/domctl.c +10 -0
+                free_cqm_rmid(d);
+                ret = 0;
+            }
+            else
+                ret = -ENOENT;
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;
Quoted 2 lines

For consistency, both of the above would better be changed to a single series of if()/else if().../else.

Will re-format in following patch.

Quoted 6 lines

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 126

Quoted 4 lines
xen/arch/x86/pqos.c +3 -0
+bool_t system_supports_cqm(void)
+{
+    return !!cqm;

So here we go (wrt the remark on patch 1).

Yes

Quoted 16 lines

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 137

Quoted 12 lines
xen/arch/x86/pqos.c +11 -0
+}
+
+int alloc_cqm_rmid(struct domain *d)
+{
+    int rc = 0;
+    unsigned int rmid;
+    unsigned long flags;
+
+    ASSERT(system_supports_cqm());
+
+    spin_lock_irqsave(&cqm_lock, flags);

Why not just spin_lock()? Briefly scanning over the following patches doesn't point out anything that might require this to be an IRQ-safe lock.

Will change it to simple spin_lock().

Quoted 14 lines
Quoted 14 lines
xen/arch/x86/pqos.c +13 -0
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+    {
+        if ( cqm->rmid_to_dom[rmid] != DOMID_INVALID)
+            continue;
+
+        cqm->rmid_to_dom[rmid] = d->domain_id;
+        break;
+    }
+    spin_unlock_irqrestore(&cqm_lock, flags);
+
+    /* No CQM RMID available, assign RMID=0 by default */
+    if ( rmid > cqm->max_rmid )
+    {
Quoted 8 lines

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 155

Quoted 5 lines
xen/arch/x86/pqos.c +5 -0
+        rmid = 0;
+        rc = -1;
+    }
+
+    d->arch.pqos_cqm_rmid = rmid;

Is it really safe to do this and the freeing below outside of the lock?

Could you help to elaborate the race condition here?

Per my understanding, there can't be any competition over who owns the entry. Besides, setting it back to DOMID_INVALID won't race with the allocation loop.

Thanks,
Dongxiao

Quoted 2 lines

Jan

#12 lore raw

Re: [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest

Quoted 24 lines
Quoted 15 lines
Quoted 15 lines · Dongxiao
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/domctl.c +9 -0
@@ -1223,6 +1224,45 @@ long arch_do_domctl(
     }
     break;
 
+    case XEN_DOMCTL_attach_pqos:
+    {
+        if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
+        {
+            if ( !system_supports_cqm() )
+                ret = -ENODEV;
+            else if ( d->arch.pqos_cqm_rmid > 0 )
+                ret = -EEXIST;
+            else
Quoted 8 lines

xen/arch/x86/domctl.c long arch_do_domctl( · line 1239

Quoted 4 lines
xen/arch/x86/domctl.c +4 -0
+            {
+                ret = alloc_cqm_rmid(d);
+                if ( ret < 0 )
+                    ret = -EUSERS;

Why don't you have the function return a sensible error code (which presumably might also end up being other than -EUSERS, e.g. -ENOMEM).

Quoted 2 lines

For the assignment of RMID, I don't think there will be error of ENOMEM, so I think EUSER will be better here?

-EUSER is certainly fine here, but that wasn't my point. My point was that alloc_cqm_rmid() should return a proper error code (right now only -EUSER, but _potentially_ there could be others in the future, _for example_ -ENOMEM), and that error code should simply get passed up here.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
xen/arch/x86/pqos.c +13 -0
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+    {
+        if ( cqm->rmid_to_dom[rmid] != DOMID_INVALID)
+            continue;
+
+        cqm->rmid_to_dom[rmid] = d->domain_id;
+        break;
+    }
+    spin_unlock_irqrestore(&cqm_lock, flags);
+
+    /* No CQM RMID available, assign RMID=0 by default */
+    if ( rmid > cqm->max_rmid )
+    {
Quoted 8 lines

xen/arch/x86/pqos.c void __init init_platform_qos(void) · line 155

Quoted 5 lines
xen/arch/x86/pqos.c +5 -0
+        rmid = 0;
+        rc = -1;
+    }
+
+    d->arch.pqos_cqm_rmid = rmid;

Is it really safe to do this and the freeing below outside of the lock?

Quoted 1 line

Could you help to elaborate the race condition here?

I wasn't saying there is one. I was asking whether you thought about whether there might be one. After all, from simply looking at it I get the impression that two racing calls to this function might end up leaking one of the two RMIDs (second instance blindly overwriting what the first instance stored).

Jan

#13 lore raw

PATCH v6 3/7 x86: initialize per socket cpu map

In reply to Dongxiao Xu

For each socket in the system, we create a separate bitmap to tag its related CPUs. This per socket bitmap will be initialized on system start up, and adjusted when CPU is dynamically online/offline.

---
 xen/arch/x86/smp.c        |    7 ++++++-
 xen/arch/x86/smpboot.c    |   19 +++++++++++++++++--
 xen/include/asm-x86/smp.h |    2 ++
 xen/include/xen/cpumask.h |    1 +
 4 files changed, 26 insertions(+), 3 deletions(-)
xen/arch/x86/smp.c +6 -1
index 0433f30..7959447 100644
@@ -283,6 +283,9 @@ void smp_send_call_function_mask(const cpumask_t *mask)
 
 void __stop_this_cpu(void)
 {
+    int cpu = smp_processor_id();
+    int socket = cpu_to_socket(cpu);
+
     ASSERT(!local_irq_is_enabled());
 
     disable_local_APIC();
@@ -296,7 +299,9 @@ void __stop_this_cpu(void)
     clts();
     asm volatile ( "fninit" );
 
-    cpumask_clear_cpu(smp_processor_id(), &cpu_online_map);
+    cpumask_clear_cpu(cpu, &cpu_online_map);
+    if ( socket >= 0 )
+        cpumask_clear_cpu(cpu, &socket_cpu_map[socket]);
 }
 
 static void stop_this_cpu(void *dummy)
xen/arch/x86/smpboot.c +17 -2
index 9f81c7b..bfebc2b 100644
@@ -59,6 +59,9 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask);
 cpumask_t cpu_online_map __read_mostly;
 EXPORT_SYMBOL(cpu_online_map);
 
+cpumask_t socket_cpu_map[MAX_NUM_SOCKETS] __read_mostly;
+EXPORT_SYMBOL(socket_cpu_map);
+
 struct cpuinfo_x86 cpu_data[NR_CPUS];
 
 u32 x86_cpu_to_apicid[NR_CPUS] __read_mostly =
@@ -319,6 +322,7 @@ void start_secondary(void *unused)
      * want to limit the things done here to the most necessary things.
      */
     unsigned int cpu = booting_cpu;
+    int socket;
 
     set_processor_id(cpu);
     set_current(idle_vcpu[cpu]);
@@ -381,6 +385,9 @@ void start_secondary(void *unused)
     cpumask_set_cpu(cpu, &cpu_online_map);
     unlock_vector_lock();
 
+    if ( (socket = cpu_to_socket(cpu)) >= 0 )
+        cpumask_set_cpu(cpu, &socket_cpu_map[socket]);
+
     init_percpu_time();
 
     /* We can take interrupts now: we're officially "up". */
@@ -788,8 +795,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 
 void __init smp_prepare_boot_cpu(void)
 {
-    cpumask_set_cpu(smp_processor_id(), &cpu_online_map);
-    cpumask_set_cpu(smp_processor_id(), &cpu_present_map);
+    int cpu = smp_processor_id();
+    int socket = cpu_to_socket(cpu);
+
+    cpumask_set_cpu(cpu, &cpu_online_map);
+    cpumask_set_cpu(cpu, &cpu_present_map);
+    if ( socket >= 0 )
+        cpumask_set_cpu(cpu, &socket_cpu_map[socket]);
 }
 
 static void
@@ -819,6 +831,7 @@ remove_siblinginfo(int cpu)
 void __cpu_disable(void)
 {
     int cpu = smp_processor_id();
+    int socket = cpu_to_socket(cpu);
 
     set_cpu_state(CPU_STATE_DYING);
 
@@ -836,6 +849,8 @@ void __cpu_disable(void)
     /* It's now safe to remove this processor from the online map */
     cpumask_clear_cpu(cpu, cpupool0->cpu_valid);
     cpumask_clear_cpu(cpu, &cpu_online_map);
+    if ( socket >= 0 )
+        cpumask_clear_cpu(cpu, &socket_cpu_map[socket]);
     fixup_irqs();
 
     if ( cpu_disable_scheduler(cpu) )
xen/include/asm-x86/smp.h +2 -0
index 81f8610..f47fa1b 100644
@@ -57,6 +57,8 @@ int hard_smp_processor_id(void);
 
 void __stop_this_cpu(void);
 
+#define MAX_NUM_SOCKETS 256
+
 #endif /* !__ASSEMBLY__ */
 
 #endif
xen/include/xen/cpumask.h +1 -0
index 850b4a2..883a52a 100644
@@ -419,6 +419,7 @@ static inline void free_cpumask_var(cpumask_var_t mask)
 extern cpumask_t cpu_possible_map;
 extern cpumask_t cpu_online_map;
 extern cpumask_t cpu_present_map;
+extern cpumask_t socket_cpu_map[];
 
 #if NR_CPUS > 1
 #define num_online_cpus()	cpumask_weight(&cpu_online_map)
Signature · 1 line
1.7.9.5
#14 lore raw

Re: [PATCH v6 3/7] x86: initialize per socket cpu map

Quoted 4 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu

For each socket in the system, we create a separate bitmap to tag its related CPUs. This per socket bitmap will be initialized on system start up, and adjusted when CPU is dynamically online/offline.

There's no reasoning here at all why cpu_sibling_mask and cpu_core_mask aren't sufficient.

xen/arch/x86/smpboot.c DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask); · line 63

Quoted 8 lines
xen/arch/x86/smpboot.c +2 -0
@@ -59,6 +59,9 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask);
 cpumask_t cpu_online_map __read_mostly;
 EXPORT_SYMBOL(cpu_online_map);
 
+cpumask_t socket_cpu_map[MAX_NUM_SOCKETS] __read_mostly;
+EXPORT_SYMBOL(socket_cpu_map);

And _if_ we really need it, then it should be done in a better way than via a statically sized array, the size of which can't even be overridden on the build and/or hypervisor command line.

And there shouldn't be EXPORT_SYMBOL() in new, not directly cloned hypervisor code either.

Jan

#15 lore raw

Re: [PATCH v6 3/7] x86: initialize per socket cpu map

Quoted 10 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, January 20, 2014 9:27 PM
To: Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 3/7] x86: initialize per socket cpu map

Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu

For each socket in the system, we create a separate bitmap to tag its related CPUs. This per socket bitmap will be initialized on system start up, and adjusted when CPU is dynamically online/offline.

There's no reasoning here at all why cpu_sibling_mask and cpu_core_mask aren't sufficient.

The new mask is to mark socket CPUs, and they may be different with cpu_sibling_mask and cpu_core_mask...

Quoted 8 lines

xen/arch/x86/smpboot.c DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t,

Quoted 4 lines
xen/arch/x86/smpboot.c +0 -0
@@ -59,6 +59,9 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t,

cpu_core_mask);

Quoted 3 lines
xen/arch/x86/smpboot.c +0 -0
 cpumask_t cpu_online_map __read_mostly;
 EXPORT_SYMBOL(cpu_online_map);
 
Quoted 6 lines

xen/arch/x86/smpboot.c DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask); · line 63

Quoted 2 lines
xen/arch/x86/smpboot.c +2 -0
+cpumask_t socket_cpu_map[MAX_NUM_SOCKETS] __read_mostly;
+EXPORT_SYMBOL(socket_cpu_map);

And _if_ we really need it, then it should be done in a better way than via a statically sized array, the size of which can't even be overridden on the build and/or hypervisor command line.

I saw current Xen code uses a lot of such static macros, e.g., NR_CPUS.
This reminds me one thing, can we define the MAX_NUM_SOCKETS as NR_CPUS? Since the socket number could not exceeds the CPU number.

Quoted 3 lines

And there shouldn't be EXPORT_SYMBOL() in new, not directly cloned hypervisor code either.

Okay, will remove it in following patch.

Thanks,
Dongxiao

Quoted 2 lines

Jan

#16 lore raw

Re: [PATCH v6 3/7] x86: initialize per socket cpu map

Quoted 7 lines
Quoted 7 lines
Quoted 1 line · Dongxiao

From: Jan Beulich [mailto:[email protected]]

Quoted 4 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu

For each socket in the system, we create a separate bitmap to tag its related CPUs. This per socket bitmap will be initialized on system start up, and adjusted when CPU is dynamically online/offline.

Quoted 5 lines
Quoted 2 lines

There's no reasoning here at all why cpu_sibling_mask and cpu_core_mask aren't sufficient.

The new mask is to mark socket CPUs, and they may be different with cpu_sibling_mask and cpu_core_mask...

Sorry, I don't follow: cpu_core_mask represents all cores sitting on the same socket as the "owning" CPU. How's that different from "marking socket CPUs"?

Quoted 7 lines
Quoted 7 lines

xen/arch/x86/smpboot.c DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t,

Quoted 3 lines
xen/arch/x86/smpboot.c +0 -0
@@ -59,6 +59,9 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t,

cpu_core_mask);

Quoted 3 lines
xen/arch/x86/smpboot.c +0 -0
 cpumask_t cpu_online_map __read_mostly;
 EXPORT_SYMBOL(cpu_online_map);
 
Quoted 8 lines
Quoted 6 lines

xen/arch/x86/smpboot.c DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask); · line 63

Quoted 2 lines
xen/arch/x86/smpboot.c +2 -0
+cpumask_t socket_cpu_map[MAX_NUM_SOCKETS] __read_mostly;
+EXPORT_SYMBOL(socket_cpu_map);

And _if_ we really need it, then it should be done in a better way than via a statically sized array, the size of which can't even be overridden on the build and/or hypervisor command line.

I saw current Xen code uses a lot of such static macros, e.g., NR_CPUS.

For one, the number of these has been decreasing over time.

And then NR_CPUS _can_ be controlled from the make command line.

Quoted 2 lines

This reminds me one thing, can we define the MAX_NUM_SOCKETS as NR_CPUS? Since the socket number could not exceeds the CPU number.

That might be an option, but only if this construct is really needed in the first place.

Jan

#17 lore raw

PATCH v6 4/7 x86: collect CQM information from all sockets

In reply to Dongxiao Xu

Collect CQM information (L3 cache occupancy) from all sockets. Upper layer application can parse the data structure to get the information of guest's L3 cache occupancy on certain sockets.

---
 xen/arch/x86/pqos.c             |   49 +++++++++++++++++++++++++++++
 xen/arch/x86/sysctl.c           |   65 +++++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/msr-index.h |    4 +++
 xen/include/asm-x86/pqos.h      |    7 +++++
 xen/include/public/domctl.h     |    9 ++++++
 xen/include/public/sysctl.h     |   10 ++++++
 6 files changed, 144 insertions(+)
xen/arch/x86/pqos.c +49 -0
index 67d733e..f585c10 100644
@@ -15,6 +15,7 @@
  * more details.
  */
 #include <asm/processor.h>
+#include <asm/msr.h>
 #include <xen/init.h>
 #include <xen/spinlock.h>
 #include <asm/pqos.h>
@@ -126,6 +127,12 @@ bool_t system_supports_cqm(void)
     return !!cqm;
 }
 
+unsigned int get_cqm_count(void)
+{
+    ASSERT(system_supports_cqm());
+    return cqm->max_rmid + 1;
+}
+
 int alloc_cqm_rmid(struct domain *d)
 {
     int rc = 0;
@@ -170,6 +177,48 @@ void free_cqm_rmid(struct domain *d)
     d->arch.pqos_cqm_rmid = 0;
 }
 
+static void read_cqm_data(void *arg)
+{
+    uint64_t cqm_data;
+    unsigned int rmid;
+    int socket = cpu_to_socket(smp_processor_id());
+    struct xen_socket_cqmdata *data = arg;
+    unsigned long flags, i;
+
+    ASSERT(system_supports_cqm());
+
+    if ( socket < 0 )
+        return;
+
+    spin_lock_irqsave(&cqm_lock, flags);
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+    {
+        if ( cqm->rmid_to_dom[rmid] == DOMID_INVALID )
+            continue;
+
+        wrmsr(MSR_IA32_QOSEVTSEL, QOS_MONITOR_EVTID_L3, rmid);
+        rdmsrl(MSR_IA32_QMC, cqm_data);
+
+        i = socket * (cqm->max_rmid + 1) + rmid;
+        data[i].valid = !(cqm_data & IA32_QM_CTR_ERROR_MASK);
+        if ( data[i].valid )
+        {
+            data[i].l3c_occupancy = cqm_data * cqm->upscaling_factor;
+            data[i].socket = socket;
+            data[i].domid = cqm->rmid_to_dom[rmid];
+        }
+    }
+    spin_unlock_irqrestore(&cqm_lock, flags);
+}
+
+void get_cqm_info(cpumask_t *cpu_cqmdata_map, struct xen_socket_cqmdata *data)
+{
+    /* Read CQM data in current CPU */
+    read_cqm_data(data);
+    /* Issue IPI to other CPUs to read CQM data */
+    on_selected_cpus(cpu_cqmdata_map, read_cqm_data, data, 1);
+}
+
 /*
  * Local variables:
  * mode: C
xen/arch/x86/sysctl.c +65 -0

83 lines not on this page · raw message

xen/include/asm-x86/msr-index.h +4 -0
index e597a28..46ef165 100644
@@ -488,4 +488,8 @@
 /* Geode defined MSRs */
 #define MSR_GEODE_BUSCONT_CONF0		0x00001900
 
+/* Platform QoS register */
+#define MSR_IA32_QOSEVTSEL             0x00000c8d
+#define MSR_IA32_QMC                   0x00000c8e
+
 #endif /* __ASM_MSR_INDEX_H */
xen/include/asm-x86/pqos.h +7 -0
index 16c4882..b1298b9 100644
@@ -17,6 +17,8 @@
 #ifndef ASM_PQOS_H
 #define ASM_PQOS_H
 #include <xen/sched.h>
+#include <xen/cpumask.h>
+#include <public/domctl.h>
 
 #include <public/xen.h>
 
@@ -34,10 +36,15 @@ struct pqos_cqm {
 };
 extern struct pqos_cqm *cqm;
 
+/* IA32_QM_CTR */
+#define IA32_QM_CTR_ERROR_MASK         (0x3ul << 62)
+
 void init_platform_qos(void);
 
 bool_t system_supports_cqm(void);
 int alloc_cqm_rmid(struct domain *d);
 void free_cqm_rmid(struct domain *d);
+unsigned int get_cqm_count(void);
+void get_cqm_info(cpumask_t *cpu_cqmdata_map, struct xen_socket_cqmdata *data);
 
 #endif
xen/include/public/domctl.h +9 -0
index d53e216..563aeaf 100644
@@ -877,6 +877,15 @@ struct xen_domctl_qos_type {
 typedef struct xen_domctl_qos_type xen_domctl_qos_type_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_qos_type_t);
 
+struct xen_socket_cqmdata {
+    uint64_t l3c_occupancy;
+    uint32_t socket;
+    domid_t  domid;
+    uint8_t  valid;
+};
+typedef struct xen_socket_cqmdata xen_socket_cqmdata_t;
+DEFINE_XEN_GUEST_HANDLE(xen_socket_cqmdata_t);
+
 struct xen_domctl {
     uint32_t cmd;
 #define XEN_DOMCTL_createdomain                   1
xen/include/public/sysctl.h +10 -0
index 8437d31..cf240a7 100644
@@ -632,6 +632,14 @@ struct xen_sysctl_coverage_op {
 typedef struct xen_sysctl_coverage_op xen_sysctl_coverage_op_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_coverage_op_t);
 
+/* XEN_SYSCTL_getcqminfo */
+struct xen_sysctl_getcqminfo {
+    XEN_GUEST_HANDLE_64(xen_socket_cqmdata_t) buffer; /* OUT */
+    uint32_t              num_sockets;    /* IN/OUT */
+    uint32_t              num_rmids;       /* OUT */
+};
+typedef struct xen_sysctl_getcqminfo xen_sysctl_getcqminfo_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcqminfo_t);
 
 struct xen_sysctl {
     uint32_t cmd;
@@ -654,6 +662,7 @@ struct xen_sysctl {
 #define XEN_SYSCTL_cpupool_op                    18
 #define XEN_SYSCTL_scheduler_op                  19
 #define XEN_SYSCTL_coverage_op                   20
+#define XEN_SYSCTL_getcqminfo                    21
     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
     union {
         struct xen_sysctl_readconsole       readconsole;
@@ -675,6 +684,7 @@ struct xen_sysctl {
         struct xen_sysctl_cpupool_op        cpupool_op;
         struct xen_sysctl_scheduler_op      scheduler_op;
         struct xen_sysctl_coverage_op       coverage_op;
+        struct xen_sysctl_getcqminfo        getcqminfo;
         uint8_t                             pad[128];
     } u;
 };
Signature · 1 line
1.7.9.5
#18 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 15 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/pqos.c +6 -0
@@ -126,6 +127,12 @@ bool_t system_supports_cqm(void)
     return !!cqm;
 }
 
+unsigned int get_cqm_count(void)
+{
+    ASSERT(system_supports_cqm());
+    return cqm->max_rmid + 1;
+}
+
 int alloc_cqm_rmid(struct domain *d)
 {
     int rc = 0;

xen/arch/x86/pqos.c void free_cqm_rmid(struct domain *d) · line 186

Quoted 10 lines
xen/arch/x86/pqos.c +7 -0
@@ -170,6 +177,48 @@ void free_cqm_rmid(struct domain *d)
     d->arch.pqos_cqm_rmid = 0;
 }
 
+static void read_cqm_data(void *arg)
+{
+    uint64_t cqm_data;
+    unsigned int rmid;
+    int socket = cpu_to_socket(smp_processor_id());
+    struct xen_socket_cqmdata *data = arg;
+    unsigned long flags, i;

Either i can be "unsigned int" ...

Quoted 6 lines
xen/arch/x86/pqos.c +6 -0
+
+    ASSERT(system_supports_cqm());
+
+    if ( socket < 0 )
+        return;
+

xen/arch/x86/pqos.c void free_cqm_rmid(struct domain *d) · line 202

Quoted 10 lines
xen/arch/x86/pqos.c +10 -0
+    spin_lock_irqsave(&cqm_lock, flags);
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+    {
+        if ( cqm->rmid_to_dom[rmid] == DOMID_INVALID )
+            continue;
+
+        wrmsr(MSR_IA32_QOSEVTSEL, QOS_MONITOR_EVTID_L3, rmid);
+        rdmsrl(MSR_IA32_QMC, cqm_data);
+
+        i = socket * (cqm->max_rmid + 1) + rmid;

... or this calculation needs one of the two operands of * cast to "unsigned long".

xen/arch/x86/pqos.c void free_cqm_rmid(struct domain *d) · line 212

Quoted 10 lines
xen/arch/x86/pqos.c +10 -0
+        data[i].valid = !(cqm_data & IA32_QM_CTR_ERROR_MASK);
+        if ( data[i].valid )
+        {
+            data[i].l3c_occupancy = cqm_data * cqm->upscaling_factor;
+            data[i].socket = socket;
+            data[i].domid = cqm->rmid_to_dom[rmid];
+        }
+    }
+    spin_unlock_irqrestore(&cqm_lock, flags);
+}

Also, please clarify why the locking here is necessary: You don't seem to be modifying global data, and the only possibly mutable thing you read is cqm->rmid_to_dom[]. A race on that one with an addition/deletion doesn't appear to be problematic though.

xen/arch/x86/pqos.c void free_cqm_rmid(struct domain *d) · line 214

Quoted 1 line
xen/arch/x86/pqos.c +1 -0
+void get_cqm_info(cpumask_t *cpu_cqmdata_map, struct xen_socket_cqmdata *data)

const cpumask_t *

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 128

Quoted 6 lines
xen/arch/x86/sysctl.c +6 -0
+    case XEN_SYSCTL_getcqminfo:
+    {
+        struct xen_socket_cqmdata *info;
+        uint32_t num_sockets;
+        uint32_t num_rmids;
+        cpumask_t cpu_cqmdata_map;

Unless absolutely avoidable, not CPU masks on the stack please.

Quoted 4 lines
xen/arch/x86/sysctl.c +4 -0
+
+        if ( !system_supports_cqm() )
+        {
+            ret = -ENODEV;

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 142

Quoted 10 lines
xen/arch/x86/sysctl.c +10 -0
+            break;
+        }
+
+        select_socket_cpu(&cpu_cqmdata_map);
+
+        num_sockets = min((unsigned int)cpumask_weight(&cpu_cqmdata_map) + 1,
+                          sysctl->u.getcqminfo.num_sockets);
+        num_rmids = get_cqm_count();
+        info = xzalloc_array(struct xen_socket_cqmdata,
+                             num_rmids * num_sockets);

While unlikely right now, you ought to consider the case of this multiplication overflowing.

Also - how does the caller know how big the buffer needs to be? Only num_sockets can be restricted by it...

And what's worse - you allow the caller to limit num_sockets and allocate info based on this limited value, but you don't restrict cpu_cqmdata_map to just the socket covered, i.e. if the caller specified a lower number, then you'll corrupt memory.

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 152

Quoted 10 lines
xen/arch/x86/sysctl.c +10 -0
+        if ( !info )
+        {
+            ret = -ENOMEM;
+            break;
+        }
+
+        get_cqm_info(&cpu_cqmdata_map, info);
+
+        if ( copy_to_guest_offset(sysctl->u.getcqminfo.buffer,
+                                  0, info, num_rmids * num_sockets) )

If the offset is zero anyway, why do you use copy_to_guest_offset() rather than copy_to_guest()?

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 162

Quoted 10 lines
xen/arch/x86/sysctl.c +10 -0
+        {
+            ret = -EFAULT;
+            xfree(info);
+            break;
+        }
+
+        sysctl->u.getcqminfo.num_rmids = num_rmids;
+        sysctl->u.getcqminfo.num_sockets = num_sockets;
+
+        if ( copy_to_guest(u_sysctl, sysctl, 1) )

__copy_to_guest() is sufficient here.

Jan

#19 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 49 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, January 20, 2014 9:52 PM
To: Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 15 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/pqos.c +6 -0
@@ -126,6 +127,12 @@ bool_t system_supports_cqm(void)
     return !!cqm;
 }
 
+unsigned int get_cqm_count(void)
+{
+    ASSERT(system_supports_cqm());
+    return cqm->max_rmid + 1;
+}
+
 int alloc_cqm_rmid(struct domain *d)
 {
     int rc = 0;

xen/arch/x86/pqos.c void free_cqm_rmid(struct domain *d) · line 186

Quoted 10 lines
xen/arch/x86/pqos.c +7 -0
@@ -170,6 +177,48 @@ void free_cqm_rmid(struct domain *d)
     d->arch.pqos_cqm_rmid = 0;
 }
 
+static void read_cqm_data(void *arg)
+{
+    uint64_t cqm_data;
+    unsigned int rmid;
+    int socket = cpu_to_socket(smp_processor_id());
+    struct xen_socket_cqmdata *data = arg;
+    unsigned long flags, i;

Either i can be "unsigned int" ...

Quoted 11 lines
xen/arch/x86/pqos.c +11 -0
+
+    ASSERT(system_supports_cqm());
+
+    if ( socket < 0 )
+        return;
+
+    spin_lock_irqsave(&cqm_lock, flags);
+    for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
+    {
+        if ( cqm->rmid_to_dom[rmid] == DOMID_INVALID )
+            continue;
Quoted 8 lines

xen/arch/x86/pqos.c void free_cqm_rmid(struct domain *d) · line 202

Quoted 5 lines
xen/arch/x86/pqos.c +5 -0
+
+        wrmsr(MSR_IA32_QOSEVTSEL, QOS_MONITOR_EVTID_L3, rmid);
+        rdmsrl(MSR_IA32_QMC, cqm_data);
+
+        i = socket * (cqm->max_rmid + 1) + rmid;

... or this calculation needs one of the two operands of * cast to "unsigned long".

Will adopt this way in following patch.

Quoted 12 lines

xen/arch/x86/pqos.c void free_cqm_rmid(struct domain *d) · line 212

Quoted 11 lines
xen/arch/x86/pqos.c +10 -0
+        data[i].valid = !(cqm_data & IA32_QM_CTR_ERROR_MASK);
+        if ( data[i].valid )
+        {
+            data[i].l3c_occupancy = cqm_data * cqm->upscaling_factor;
+            data[i].socket = socket;
+            data[i].domid = cqm->rmid_to_dom[rmid];
+        }
+    }
+    spin_unlock_irqrestore(&cqm_lock, flags);
+}
Quoted 4 lines

Also, please clarify why the locking here is necessary: You don't seem to be modifying global data, and the only possibly mutable thing you read is cqm->rmid_to_dom[]. A race on that one with an addition/deletion doesn't appear to be problematic though.

Will use the spin_lock() in following patch.

Quoted 6 lines

Review void free_cqm_rmid(struct domain *d) · line 213

Quoted 2 lines
(quoted diff) +1 -0
+void get_cqm_info(cpumask_t *cpu_cqmdata_map, struct

xen_socket_cqmdata *data)

const cpumask_t *

Quoted 8 lines

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 128

Quoted 6 lines
xen/arch/x86/sysctl.c +6 -0
+    case XEN_SYSCTL_getcqminfo:
+    {
+        struct xen_socket_cqmdata *info;
+        uint32_t num_sockets;
+        uint32_t num_rmids;
+        cpumask_t cpu_cqmdata_map;

Unless absolutely avoidable, not CPU masks on the stack please.

Okay, will allocate it by "xzalloc" function.

Quoted 20 lines

xen/arch/x86/sysctl.c long arch_do_sysctl(

Quoted 11 lines
xen/arch/x86/sysctl.c +10 -0
+
+        if ( !system_supports_cqm() )
+        {
+            ret = -ENODEV;
+            break;
+        }
+
+        select_socket_cpu(&cpu_cqmdata_map);
+
+        num_sockets = min((unsigned

int)cpumask_weight(&cpu_cqmdata_map) + 1,

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 142

Quoted 4 lines
xen/arch/x86/sysctl.c +4 -0
+                          sysctl->u.getcqminfo.num_sockets);
+        num_rmids = get_cqm_count();
+        info = xzalloc_array(struct xen_socket_cqmdata,
+                             num_rmids * num_sockets);

While unlikely right now, you ought to consider the case of this multiplication overflowing.

Quoted 7 lines

Also - how does the caller know how big the buffer needs to be? Only num_sockets can be restricted by it...

And what's worse - you allow the caller to limit num_sockets and allocate info based on this limited value, but you don't restrict cpu_cqmdata_map to just the socket covered, i.e. if the caller specified a lower number, then you'll corrupt memory.

Currently the caller (libxc) sets big num_rmid and num_sockets which are the maximum values that could be available inside the hypervisor.
If you think this approach is not enough to ensure the security, what about the caller (libxc) issue an hypercall to get the two values from hypervisor, then allocating the same size of num_rmid and num_sockets?

Quoted 6 lines

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

Do you mean we check the size of the total size, and allocate MFNs one by one, then vmap them?

Quoted 14 lines

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 152

Quoted 11 lines
xen/arch/x86/sysctl.c +10 -0
+        if ( !info )
+        {
+            ret = -ENOMEM;
+            break;
+        }
+
+        get_cqm_info(&cpu_cqmdata_map, info);
+
+        if ( copy_to_guest_offset(sysctl->u.getcqminfo.buffer,
+                                  0, info, num_rmids * num_sockets) )

If the offset is zero anyway, why do you use copy_to_guest_offset() rather than copy_to_guest()?

Okay.

Quoted 13 lines

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 162

Quoted 11 lines
xen/arch/x86/sysctl.c +10 -0
+        {
+            ret = -EFAULT;
+            xfree(info);
+            break;
+        }
+
+        sysctl->u.getcqminfo.num_rmids = num_rmids;
+        sysctl->u.getcqminfo.num_sockets = num_sockets;
+
+        if ( copy_to_guest(u_sysctl, sysctl, 1) )

__copy_to_guest() is sufficient here.

Okay.

Thanks,
Dongxiao

Quoted 2 lines

Jan

#20 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 9 lines · Dongxiao
Quoted 8 lines

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 128

Quoted 7 lines
xen/arch/x86/sysctl.c +6 -0
+    case XEN_SYSCTL_getcqminfo:
+    {
+        struct xen_socket_cqmdata *info;
+        uint32_t num_sockets;
+        uint32_t num_rmids;
+        cpumask_t cpu_cqmdata_map;

Unless absolutely avoidable, not CPU masks on the stack please.

Okay, will allocate it by "xzalloc" function.

cpumask_var_t mask;
{z}alloc_cpumask_var(&mask);
...
free_cpumask_var(mask);

This will switch between a long on the stack and an allocated structure depending on whether Xen is compiled with fewer or more than 64 pcpu.

Quoted 29 lines
Quoted 19 lines

xen/arch/x86/sysctl.c long arch_do_sysctl(

Quoted 11 lines
xen/arch/x86/sysctl.c +10 -0
+
+        if ( !system_supports_cqm() )
+        {
+            ret = -ENODEV;
+            break;
+        }
+
+        select_socket_cpu(&cpu_cqmdata_map);
+
+        num_sockets = min((unsigned

int)cpumask_weight(&cpu_cqmdata_map) + 1,

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 142

Quoted 4 lines
xen/arch/x86/sysctl.c +4 -0
+                          sysctl->u.getcqminfo.num_sockets);
+        num_rmids = get_cqm_count();
+        info = xzalloc_array(struct xen_socket_cqmdata,
+                             num_rmids * num_sockets);

While unlikely right now, you ought to consider the case of this multiplication overflowing.

Quoted 7 lines

Also - how does the caller know how big the buffer needs to be? Only num_sockets can be restricted by it...

And what's worse - you allow the caller to limit num_sockets and allocate info based on this limited value, but you don't restrict cpu_cqmdata_map to just the socket covered, i.e. if the caller specified a lower number, then you'll corrupt memory.

Currently the caller (libxc) sets big num_rmid and num_sockets which are the maximum values that could be available inside the hypervisor.
If you think this approach is not enough to ensure the security, what about the caller (libxc) issue an hypercall to get the two values from hypervisor, then allocating the same size of num_rmid and num_sockets?

Quoted 6 lines
Quoted 5 lines

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

Do you mean we check the size of the total size, and allocate MFNs one by one, then vmap them?

I still think this is barking mad as a method of getting this quantity of data from Xen to the toolstack in a repeated fashon.

Xen should allocate a per-socket buffer at the start of day (or perhaps on first use of CQM), and the CQM monitoring tool gets to map those per-socket buffers read-only.

This way, all processing of the CQM data happens in dom0 userspace, not in Xen in hypercall context; All Xen has to do is periodically dump the MSRs into the pages.

~Andrew

#21 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 6 lines · Dongxiao
Quoted 5 lines

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

Do you mean we check the size of the total size, and allocate MFNs one by

one, then vmap them?

I still think this is barking mad as a method of getting this quantity of data from Xen to the toolstack in a repeated fashon.

Quoted 7 lines

Xen should allocate a per-socket buffer at the start of day (or perhaps on first use of CQM), and the CQM monitoring tool gets to map those per-socket buffers read-only.

This way, all processing of the CQM data happens in dom0 userspace, not in Xen in hypercall context; All Xen has to do is periodically dump the MSRs into the pages.

Indeed - if the nature of the data is such that it can be exposed read-only to suitably privileged entities, then this would be the much better interface.

Jan

#22 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 27 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, January 28, 2014 11:04 PM
To: Andrew Cooper; Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 17 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 6 lines · Dongxiao
Quoted 5 lines

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

Do you mean we check the size of the total size, and allocate MFNs one by

one, then vmap them?

I still think this is barking mad as a method of getting this quantity of data from Xen to the toolstack in a repeated fashon.

Xen should allocate a per-socket buffer at the start of day (or perhaps on first use of CQM), and the CQM monitoring tool gets to map those per-socket buffers read-only.

Quoted 7 lines
Quoted 3 lines

This way, all processing of the CQM data happens in dom0 userspace, not in Xen in hypercall context; All Xen has to do is periodically dump the MSRs into the pages.

Indeed - if the nature of the data is such that it can be exposed read-only to suitably privileged entities, then this would be the much better interface.

If the data fetching is not hypercall driven, do you have a recommendation on how frequent Xen dumps the MSRs into the share page?

Thanks,
Dongxiao

Quoted 2 lines

Jan

#23 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 30 lines · Dongxiao
Quoted 30 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, January 28, 2014 11:04 PM
To: Andrew Cooper; Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

Quoted 20 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 6 lines · Dongxiao
Quoted 5 lines

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

Do you mean we check the size of the total size, and allocate MFNs one by

one, then vmap them?

I still think this is barking mad as a method of getting this quantity of data from Xen to the toolstack in a repeated fashon.

Xen should allocate a per-socket buffer at the start of day (or perhaps on first use of CQM), and the CQM monitoring tool gets to map those per-socket buffers read-only.

This way, all processing of the CQM data happens in dom0 userspace, not in Xen in hypercall context; All Xen has to do is periodically dump the MSRs into the pages.

Quoted 7 lines
Quoted 3 lines

Indeed - if the nature of the data is such that it can be exposed read-only to suitably privileged entities, then this would be the much better interface.

If the data fetching is not hypercall driven, do you have a recommendation on how frequent Xen dumps the MSRs into the share page?

Thanks,
Dongxiao

There is nothing preventing a hypercall existing which does a synchronous prompt to dump data right now, but that is substantially less overhead than then having the hypercall go and then rotate a matrix of data so it can be consumed in a form convenient for userspace.

Other solutions involve having a single read/write control page where the toolstack could set a bit indicating "please dump the msr when next convenient" and the rmid context switching code could do a test_and_clear() bit on it, which even solves the problem of "which core on some other socket do I decide to interrupt".

~Andrew

#24 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

In reply to Xu, Dongxiao
Quoted 23 lines
Quoted 23 lines
Quoted 1 line · Dongxiao

From: Jan Beulich [mailto:[email protected]]

Quoted 20 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 6 lines · Dongxiao
Quoted 5 lines

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

Do you mean we check the size of the total size, and allocate MFNs one by

one, then vmap them?

I still think this is barking mad as a method of getting this quantity of data from Xen to the toolstack in a repeated fashon.

Xen should allocate a per-socket buffer at the start of day (or perhaps on first use of CQM), and the CQM monitoring tool gets to map those per-socket buffers read-only.

This way, all processing of the CQM data happens in dom0 userspace, not in Xen in hypercall context; All Xen has to do is periodically dump the MSRs into the pages.

Quoted 6 lines
Quoted 3 lines

Indeed - if the nature of the data is such that it can be exposed read-only to suitably privileged entities, then this would be the much better interface.

If the data fetching is not hypercall driven, do you have a recommendation on how frequent Xen dumps the MSRs into the share page?

Perhaps an "update the shared pages" hypercall should be made then prior to reading the shared space?

Jan

#25 lore raw

Re: [PATCH v6 4/7] x86: collect CQM information from all sockets

In reply to Xu, Dongxiao
Quoted 10 lines
Quoted 10 lines
Quoted 1 line · Dongxiao

From: Jan Beulich [mailto:[email protected]]

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/sysctl.c +6 -0
+    case XEN_SYSCTL_getcqminfo:
+    {
+        struct xen_socket_cqmdata *info;
+        uint32_t num_sockets;
+        uint32_t num_rmids;
+        cpumask_t cpu_cqmdata_map;
Quoted 3 lines
Quoted 1 line

Unless absolutely avoidable, not CPU masks on the stack please.

Okay, will allocate it by "xzalloc" function.

Hopefully this was just a thinko - zalloc_cpumask_var() is what you want to use.

Quoted 18 lines
Quoted 10 lines
Quoted 1 line

+ num_sockets = min((unsigned

int)cpumask_weight(&cpu_cqmdata_map) + 1,

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 142

Quoted 4 lines
xen/arch/x86/sysctl.c +4 -0
+                          sysctl->u.getcqminfo.num_sockets);
+        num_rmids = get_cqm_count();
+        info = xzalloc_array(struct xen_socket_cqmdata,
+                             num_rmids * num_sockets);

While unlikely right now, you ought to consider the case of this multiplication overflowing.

Quoted 7 lines

Also - how does the caller know how big the buffer needs to be? Only num_sockets can be restricted by it...

And what's worse - you allow the caller to limit num_sockets and allocate info based on this limited value, but you don't restrict cpu_cqmdata_map to just the socket covered, i.e. if the caller specified a lower number, then you'll corrupt memory.

Quoted 5 lines

Currently the caller (libxc) sets big num_rmid and num_sockets which are the maximum values that could be available inside the hypervisor.
If you think this approach is not enough to ensure the security, what about the caller (libxc) issue an hypercall to get the two values from hypervisor, then allocating the same size of num_rmid and num_sockets?

Yes, that's the first half of it. And then _both_ values, as they're determining the array dimensions, need to be passed back into the "actual" call, and the hypervisor will need to take care not to exceed these array dimensions.

Quoted 8 lines
Quoted 5 lines

And finally, I think the total size of the buffer here can easily exceed a page, i.e. this then ends up being a non-order-0 allocation, which may _never_ succeed (i.e. the operation is then rendered useless). I guest it'd be better to e.g. vmap() the MFNs underlying the guest buffer.

Do you mean we check the size of the total size, and allocate MFNs one by one, then vmap them?

That would also be a possibility, but isn't what I wrote above (as being less resource efficient, but easier to implement).

Jan

#26 lore raw

PATCH v6 5/7 x86: enable CQM monitoring for each domain RMID

In reply to Dongxiao Xu

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.

---
 xen/arch/x86/domain.c           |    5 +++++
 xen/arch/x86/pqos.c             |   12 ++++++++++++
 xen/include/asm-x86/msr-index.h |    1 +
 xen/include/asm-x86/pqos.h      |    1 +
 4 files changed, 19 insertions(+)
xen/arch/x86/domain.c +5 -0
index 90e52a2..79bc83c 100644
@@ -1366,6 +1366,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_assoc_rmid(0);
         p->arch.ctxt_switch_from(p);
     }
 
@@ -1390,6 +1392,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) :
xen/arch/x86/pqos.c +12 -0
index f585c10..c51d285 100644
@@ -60,6 +60,8 @@ static void __init parse_pqos_param(char *s)
 
 custom_param("pqos", parse_pqos_param);
 
+static uint64_t rmid_mask;
+
 struct pqos_cqm *cqm;
 static DEFINE_SPINLOCK(cqm_lock);
 
@@ -110,6 +112,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();
 }
@@ -219,6 +223,14 @@ void get_cqm_info(cpumask_t *cpu_cqmdata_map, struct xen_socket_cqmdata *data)
     on_selected_cpus(cpu_cqmdata_map, read_cqm_data, data, 1);
 }
 
+void cqm_assoc_rmid(unsigned int rmid)
+{
+    uint64_t val;
+
+    rdmsrl(MSR_IA32_PQR_ASSOC, val);
+    wrmsrl(MSR_IA32_PQR_ASSOC, (val & ~(rmid_mask)) | (rmid & rmid_mask));
+}
+
 /*
  * Local variables:
  * mode: C
xen/include/asm-x86/msr-index.h +1 -0
index 46ef165..45f4918 100644
@@ -491,5 +491,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 */
xen/include/asm-x86/pqos.h +1 -0
index b1298b9..5d53b7e 100644
@@ -46,5 +46,6 @@ int alloc_cqm_rmid(struct domain *d);
 void free_cqm_rmid(struct domain *d);
 unsigned int get_cqm_count(void);
 void get_cqm_info(cpumask_t *cpu_cqmdata_map, struct xen_socket_cqmdata *data);
+void cqm_assoc_rmid(unsigned int rmid);
 
 #endif
Signature · 1 line
1.7.9.5
#27 lore raw

Re: [PATCH v6 5/7] x86: enable CQM monitoring for each domain RMID

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/domain.c +2 -0
@@ -1366,6 +1366,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_assoc_rmid(0);
         p->arch.ctxt_switch_from(p);
     }
 

xen/arch/x86/domain.c static void __context_switch(void) · line 1400

Quoted 9 lines
xen/arch/x86/domain.c +3 -0
@@ -1390,6 +1392,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) :

The two uses here clearly call for system_supports_cqm() to be an inline function (the more that the variable checked in that function is already global anyway).

Further, cqm_assoc_rmid() being an RDMSR plus WRMSR, you surely will want to optimize the case of p's and n's RMIDs being identical. Or at the very least make sure you _never_ call that function if all domains run with RMID 0.

xen/arch/x86/domain.c static void __init parse_pqos_param(char *s) · line 63

Quoted 5 lines
xen/arch/x86/domain.c +1 -0
@@ -60,6 +60,8 @@ static void __init parse_pqos_param(char *s)
 
 custom_param("pqos", parse_pqos_param);
 
+static uint64_t rmid_mask;

__read_mostly?

xen/arch/x86/domain.c static void __init parse_pqos_param(char *s)

Quoted 6 lines
xen/arch/x86/domain.c +6 -0
+void cqm_assoc_rmid(unsigned int rmid)
+{
+    uint64_t val;
+
+    rdmsrl(MSR_IA32_PQR_ASSOC, val);
+    wrmsrl(MSR_IA32_PQR_ASSOC, (val & ~(rmid_mask)) | (rmid & rmid_mask));

Stray parentheses around a simple variable.

Jan

#28 lore raw

Re: [PATCH v6 5/7] x86: enable CQM monitoring for each domain RMID

Quoted 30 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, January 20, 2014 9:58 PM
To: Xu, Dongxiao
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 5/7] x86: enable CQM monitoring for each domain RMID

xen/arch/x86/domain.c static void __context_switch(void) · line 1367

Quoted 6 lines
Quoted 1 line
Quoted 1 line · Dongxiao Xu
xen/arch/x86/domain.c +0 -0
@@ -1366,6 +1366,8 @@ static void __context_switch(void)
     {
         memcpy(&p->arch.user_regs, stack_regs,

CTXT_SWITCH_STACK_BYTES);

xen/arch/x86/domain.c static void __context_switch(void) · line 1396

Quoted 12 lines
xen/arch/x86/domain.c +4 -0
         vcpu_save_fpu(p);
+        if ( system_supports_cqm() )
+            cqm_assoc_rmid(0);
         p->arch.ctxt_switch_from(p);
     }
 
@@ -1390,6 +1392,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 )

Quoted 8 lines

xen/arch/x86/domain.c static void __context_switch(void) · line 1400

Quoted 4 lines
xen/arch/x86/domain.c +1 -0
+            cqm_assoc_rmid(n->domain->arch.pqos_cqm_rmid);
     }
 
     gdt = !is_pv_32on64_vcpu(n) ? per_cpu(gdt_table, cpu) :

The two uses here clearly call for system_supports_cqm() to be an inline function (the more that the variable checked in that function is already global anyway).

Okay.

Quoted 5 lines

Further, cqm_assoc_rmid() being an RDMSR plus WRMSR, you surely will want to optimize the case of p's and n's RMIDs being identical. Or at the very least make sure you _never_ call that function if all domains run with RMID 0.

Okay.

Quoted 8 lines

xen/arch/x86/domain.c static void __init parse_pqos_param(char *s) · line 63

Quoted 6 lines
xen/arch/x86/domain.c +1 -0
@@ -60,6 +60,8 @@ static void __init parse_pqos_param(char *s)
 
 custom_param("pqos", parse_pqos_param);
 
+static uint64_t rmid_mask;

__read_mostly?

Okay.

Quoted 10 lines

xen/arch/x86/domain.c static void __init parse_pqos_param(char *s)

Quoted 7 lines
xen/arch/x86/domain.c +6 -0
+void cqm_assoc_rmid(unsigned int rmid)
+{
+    uint64_t val;
+
+    rdmsrl(MSR_IA32_PQR_ASSOC, val);
+    wrmsrl(MSR_IA32_PQR_ASSOC, (val & ~(rmid_mask)) | (rmid &

rmid_mask));

Stray parentheses around a simple variable.

Okay.

Will reflect your suggestions in next version patch.

Thanks,
Dongxiao

Quoted 2 lines

Jan

#29 lore raw

PATCH v6 6/7 xsm: add platform QoS related xsm policies

In reply to Dongxiao Xu

Add xsm policies for attach/detach pqos services and get CQM info hypercalls.

---
 tools/flask/policy/policy/modules/xen/xen.if |    2 +-
 tools/flask/policy/policy/modules/xen/xen.te |    5 ++++-
 xen/xsm/flask/hooks.c                        |    8 ++++++++
 xen/xsm/flask/policy/access_vectors          |   17 ++++++++++++++---
 4 files changed, 27 insertions(+), 5 deletions(-)
tools/flask/policy/policy/modules/xen/xen.if +1 -1
index dedc035..1f683af 100644
@@ -49,7 +49,7 @@ define(`create_domain_common', `
 			getdomaininfo hypercall setvcpucontext setextvcpucontext
 			getscheduler getvcpuinfo getvcpuextstate getaddrsize
 			getaffinity setaffinity };
-	allow $1 $2:domain2 { set_cpuid settsc setscheduler setclaim  set_max_evtchn };
+	allow $1 $2:domain2 { set_cpuid settsc setscheduler setclaim set_max_evtchn pqos_op };
 	allow $1 $2:security check_context;
 	allow $1 $2:shadow enable;
 	allow $1 $2:mmu { map_read map_write adjust memorymap physmap pinpage mmuext_op };
tools/flask/policy/policy/modules/xen/xen.te +4 -1
index bb59fe8..115fcfe 100644
@@ -64,6 +64,9 @@ allow dom0_t xen_t:xen {
 	getidle debug getcpuinfo heap pm_op mca_op lockprof cpupool_op tmem_op
 	tmem_control getscheduler setscheduler
 };
+allow dom0_t xen_t:xen2 {
+	pqos_op
+};
 allow dom0_t xen_t:mmu memorymap;
 
 # Allow dom0 to use these domctls on itself. For domctls acting on other
@@ -76,7 +79,7 @@ allow dom0_t dom0_t:domain {
 	getpodtarget setpodtarget set_misc_info set_virq_handler
 };
 allow dom0_t dom0_t:domain2 {
-	set_cpuid gettsc settsc setscheduler set_max_evtchn
+	set_cpuid gettsc settsc setscheduler set_max_evtchn pqos_op
 };
 allow dom0_t dom0_t:resource { add remove };
 
xen/xsm/flask/hooks.c +8 -0
index b1e2593..ec065b0 100644
@@ -730,6 +730,10 @@ static int flask_domctl(struct domain *d, int cmd)
     case XEN_DOMCTL_set_max_evtchn:
         return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__SET_MAX_EVTCHN);
 
+    case XEN_DOMCTL_attach_pqos:
+    case XEN_DOMCTL_detach_pqos:
+        return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__PQOS_OP);
+
     default:
         printk("flask_domctl: Unknown op %d\n", cmd);
         return -EPERM;
@@ -785,6 +789,10 @@ static int flask_sysctl(int cmd)
     case XEN_SYSCTL_numainfo:
         return domain_has_xen(current->domain, XEN__PHYSINFO);
 
+    case XEN_SYSCTL_getcqminfo:
+        return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2,
+                                    XEN2__PQOS_OP, NULL);
+
     default:
         printk("flask_sysctl: Unknown op %d\n", cmd);
         return -EPERM;
xen/xsm/flask/policy/access_vectors +14 -3
index 1fbe241..91af8b2 100644
@@ -3,9 +3,9 @@
 #
 # class class_name { permission_name ... }
 
-# Class xen consists of dom0-only operations dealing with the hypervisor itself.
-# Unless otherwise specified, the source is the domain executing the hypercall,
-# and the target is the xen initial sid (type xen_t).
+# Class xen and xen2 consists of dom0-only operations dealing with the
+# hypervisor itself. Unless otherwise specified, the source is the domain
+# executing the hypercall, and the target is the xen initial sid (type xen_t).
 class xen
 {
 # XENPF_settime
@@ -75,6 +75,14 @@ class xen
     setscheduler
 }
 
+# This is a continuation of class xen, since only 32 permissions can be
+# defined per class
+class xen2
+{
+# XEN_SYSCTL_getcqminfo
+    pqos_op
+}
+
 # Classes domain and domain2 consist of operations that a domain performs on
 # another domain or on itself.  Unless otherwise specified, the source is the
 # domain executing the hypercall, and the target is the domain being operated on
@@ -196,6 +204,9 @@ class domain2
     setclaim
 # XEN_DOMCTL_set_max_evtchn
     set_max_evtchn
+# XEN_DOMCTL_attach_pqos
+# XEN_DOMCTL_detach_pqos
+    pqos_op
 }
 
 # Similar to class domain, but primarily contains domctls related to HVM domains
Signature · 1 line
1.7.9.5
#30 lore raw

PATCH v6 7/7 tools: enable Cache QoS Monitoring feature for libxl/libxc

In reply to Dongxiao Xu

Introduced two new xl commands to attach/detach CQM service for a guest

$ xl pqos-attach cqm domid
$ xl pqos-detach cqm domid

Introduce one new xl command to retrive guest CQM information

$ xl pqos-list cqm (domid)
---
 tools/libxc/xc_domain.c     |   47 +++++++++++++
 tools/libxc/xenctrl.h       |   11 +++
 tools/libxl/Makefile        |    3 +-
 tools/libxl/libxl.h         |    6 ++
 tools/libxl/libxl_pqos.c    |  163 +++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_types.idl |   13 ++++
 tools/libxl/xl.h            |    3 +
 tools/libxl/xl_cmdimpl.c    |  133 +++++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdtable.c   |   15 ++++
 9 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxl/libxl_pqos.c
tools/libxc/xc_domain.c +47 -0
index 1ccafc5..769fae3 100644
@@ -1776,6 +1776,53 @@ int xc_domain_set_max_evtchn(xc_interface *xch, uint32_t domid,
     return do_domctl(xch, &domctl);
 }
 
+int xc_domain_pqos_attach(xc_interface *xch, uint32_t domid, uint64_t flags)
+{
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_attach_pqos;
+    domctl.domain = (domid_t)domid;
+    domctl.u.qos_type.flags = flags;
+    return do_domctl(xch, &domctl);
+}
+
+int xc_domain_pqos_detach(xc_interface *xch, uint32_t domid, uint64_t flags)
+{
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_detach_pqos;
+    domctl.domain = (domid_t)domid;
+    domctl.u.qos_type.flags = flags;
+    return do_domctl(xch, &domctl);
+}
+
+int xc_domain_getcqminfolist(xc_interface *xch, sysctl_cqminfo_t *info)
+{
+    int ret = 0;
+    xen_socket_cqmdata_t *data = info->cqmdata;
+    DECLARE_SYSCTL;
+
+    DECLARE_HYPERCALL_BOUNCE(data,
+        info->num_rmids * info->num_sockets * sizeof(*data),
+        XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+    if ( xc_hypercall_bounce_pre(xch, data) )
+        return -1;
+
+    sysctl.cmd = XEN_SYSCTL_getcqminfo;
+    set_xen_guest_handle(sysctl.u.getcqminfo.buffer, data);
+
+    if ( xc_sysctl(xch, &sysctl) < 0 )
+        ret = -1;
+    else
+    {
+        info->num_sockets = sysctl.u.getcqminfo.num_sockets;
+        info->num_rmids = sysctl.u.getcqminfo.num_rmids;
+    }
+
+    xc_hypercall_bounce_post(xch, data);
+
+    return ret;
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxc/xenctrl.h +11 -0
index 4ac6b8a..a16f72e 100644
@@ -2395,4 +2395,15 @@ int xc_kexec_load(xc_interface *xch, uint8_t type, uint16_t arch,
  */
 int xc_kexec_unload(xc_interface *xch, int type);
 
+struct xc_sysctl_getcqminfo
+{
+    uint32_t num_rmids;
+    uint32_t num_sockets;
+    xen_socket_cqmdata_t *cqmdata;
+};
+typedef struct xc_sysctl_getcqminfo sysctl_cqminfo_t;
+
+int xc_domain_pqos_attach(xc_interface *xch, uint32_t domid, uint64_t flags);
+int xc_domain_pqos_detach(xc_interface *xch, uint32_t domid, uint64_t flags);
+int xc_domain_getcqminfolist(xc_interface *xch, sysctl_cqminfo_t *info);
 #endif /* XENCTRL_H */
tools/libxl/Makefile +2 -1
index cf214bb..35f0b97 100644
@@ -74,7 +74,8 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_internal.o libxl_utils.o libxl_uuid.o \
 			libxl_json.o libxl_aoutils.o libxl_numa.o \
 			libxl_save_callout.o _libxl_save_msgs_callout.o \
-			libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y)
+			libxl_qmp.o libxl_event.o libxl_fork.o libxl_pqos.o \
+			$(LIBXL_OBJS-y)
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
 $(LIBXL_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include $(XEN_ROOT)/tools/config.h
tools/libxl/libxl.h +6 -0
index c7dceda..d2da424 100644
@@ -1051,6 +1051,12 @@ int libxl_flask_getenforce(libxl_ctx *ctx);
 int libxl_flask_setenforce(libxl_ctx *ctx, int mode);
 int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
 
+int libxl_pqos_attach(libxl_ctx *ctx, uint32_t domid, const char * qos_type);
+int libxl_pqos_detach(libxl_ctx *ctx, uint32_t domid, const char * qos_type);
+libxl_cqminfo * libxl_get_cqm_info(libxl_ctx *ctx,
+                                   uint32_t first_domain,
+                                   unsigned int num_domains);
+
 /* misc */
 
 /* Each of these sets or clears the flag according to whether the
tools/libxl/libxl_pqos.c new file +163 -0

163 lines not on this page · raw message

tools/libxl/libxl_types.idl +13 -0
index de5bac3..9ecbc2b 100644
@@ -593,3 +593,16 @@ libxl_event = Struct("event",[
                                  ])),
            ("domain_create_console_available", Struct(None, [])),
            ]))])
+
+libxl_cqmdata = Struct("cqmdata",[
+    ("l3c_occupancy",   uint64),
+    ("socket",          uint32),
+    ("domid",           uint16),
+    ("valid",           uint8),
+    ])
+
+libxl_cqminfo = Struct("cqminfo", [
+    ("num_rmids",    uint32),
+    ("num_sockets",  uint32),
+    ("cqmdata",      Array(libxl_cqmdata, "num_items"))
+    ])
tools/libxl/xl.h +3 -0
index e005c39..994d3be 100644
@@ -105,6 +105,9 @@ int main_getenforce(int argc, char **argv);
 int main_setenforce(int argc, char **argv);
 int main_loadpolicy(int argc, char **argv);
 int main_remus(int argc, char **argv);
+int main_pqosattach(int argc, char **argv);
+int main_pqosdetach(int argc, char **argv);
+int main_pqoslist(int argc, char **argv);
 
 void help(const char *command);
 
tools/libxl/xl_cmdimpl.c +133 -0

139 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +15 -0
index 326a660..6ced416 100644
@@ -488,6 +488,21 @@ struct cmd_spec cmd_table[] = {
       "                        of the domain."
 
     },
+    { "pqos-attach",
+      &main_pqosattach, 0, 1,
+      "Allocate and map qos resource",
+      "<Resource> <Domain>",
+    },
+    { "pqos-detach",
+      &main_pqosdetach, 0, 1,
+      "Reliquish qos resource",
+      "<Resource> <Domain>",
+    },
+    { "pqos-list",
+      &main_pqoslist, 0, 0,
+      "List qos information about all/some domains",
+      "<Resource> [Domain]",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
Signature · 1 line
1.7.9.5
#31 lore raw
In reply to Dongxiao Xu
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dongxiao Xu
Sent: Thursday, December 05, 2013 5:39 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Xen-devel] [PATCH v6 0/7] enable Cache QoS Monitoring (CQM) feature

Any more comments about this version?

Thanks,
Dongxiao

Quoted 155 lines

Changes from v5:
- Address comments from Dario Faggioli, including:
* Define a new libxl_cqminfo structure to avoid reference of xc structure in libxl functions.
* Use LOGE() instead of the LIBXL__LOG() functions.

Changes from v4:
- When comparing xl cqm parameter, use strcmp instead of strncmp, otherwise, "xl pqos-attach cqmabcd domid" will be considered as a valid command line.
- Address comments from Andrew Cooper, including:
* Adjust the pqos parameter parsing function.
* Modify the pqos related documentation.
* Add a check for opt_cqm_max_rmid in initialization code.
* Do not IPI CPU that is in same socket with current CPU.
- Address comments from Dario Faggioli, including:
* Fix an typo in export symbols.
* Return correct libxl error code for qos related functions.
* Abstract the error printing logic into a function.
- Address comment from Daniel De Graaf, including:
* Add return value in for pqos related check.
- Address comments from Konrad Rzeszutek Wilk, including:
* Modify the GPLv2 related file header, remove the address.

Changes from v3:
- Use structure to better organize CQM related global variables.
- Address comments from Andrew Cooper, including:
* Remove the domain creation flag for CQM RMID allocation.
* Adjust the boot parameter format, use custom_param().
* Add documentation for the new added boot parameter.
* Change QoS type flag to be uint64_t.
* Initialize the per socket cpu bitmap in system boot time.
* Remove get_cqm_avail() function.
* Misc of format changes.
- Address comment from Daniel De Graaf, including:
* Use avc_current_has_perm() for XEN2__PQOS_OP that belongs to
SECCLASS_XEN2.

Changes from v2:
- Address comments from Andrew Cooper, including:
* Merging tools stack changes into one patch.
* Reduce the IPI number to one per socket.
* Change structures for CQM data exchange between tools and Xen.
* Misc of format/variable/function name changes.
- Address comments from Konrad Rzeszutek Wilk, including:
* Simplify the error printing logic.
* Add xsm check for the new added hypercalls.

Changes from v1:
- Address comments from Andrew Cooper, including:
* Change function names, e.g., alloc_cqm_rmid(), system_supports_cqm(),
etc.
* Change some structure element order to save packing cost.
* Correct some function's return value.
* Some programming styles change.
* ...

Future generations of Intel Xeon processor may offer monitoring capability in each logical processor to measure specific quality-of-service metric, for example, the Cache QoS Monitoring to get L3 cache occupancy. Detailed information please refer to Intel SDM chapter 17.14.

Cache QoS Monitoring provides a layer of abstraction between applications and logical processors through the use of Resource Monitoring IDs (RMIDs). In Xen design, each guest in the system can be assigned an RMID independently, while RMID=0 is reserved for monitoring domains that doesn't enable CQM service.
When any of the domain's vcpu is scheduled on a logical processor, the domain's RMID will be activated by programming the value into one specific MSR, and when
the vcpu is scheduled out, a RMID=0 will be programmed into that MSR. The Cache QoS Hardware tracks cache utilization of memory accesses according to
the RMIDs and reports monitored data via a counter register. With this solution, we can get the knowledge how much L3 cache is used by a certain guest.

To attach CQM service to a certain guest, two approaches are provided:
1) Create the guest with "pqos_cqm=1" set in configuration file.
2) Use "xl pqos-attach cqm domid" for a running guest.

To detached CQM service from a guest, users can:
1) Use "xl pqos-detach cqm domid" for a running guest.
2) Also destroying a guest will detach the CQM service.

To get the L3 cache usage, users can use the command of:

$ xl pqos-list cqm (domid)

The below data is just an example showing how the CQM related data is exposed to
end user.

[root@localhost]# xl pqos-list cqm
Name               ID  SocketID        L3C_Usage       SocketID
L3C_Usage
Domain-0            0         0         20127744              1
25231360
ExampleHVMDomain    1         0          3211264              1
10551296

RMID count 56 RMID available 53

Dongxiao Xu (7):
x86: detect and initialize Cache QoS Monitoring feature
x86: dynamically attach/detach CQM service for a guest
x86: initialize per socket cpu map
x86: collect CQM information from all sockets
x86: enable CQM monitoring for each domain RMID
xsm: add platform QoS related xsm policies
tools: enable Cache QoS Monitoring feature for libxl/libxc

 docs/misc/xen-command-line.markdown          |    7 +
 tools/flask/policy/policy/modules/xen/xen.if |    2 +-
 tools/flask/policy/policy/modules/xen/xen.te |    5 +-
 tools/libxc/xc_domain.c                      |   47 +++++
 tools/libxc/xenctrl.h                        |   11 ++
 tools/libxl/Makefile                         |    3 +-
 tools/libxl/libxl.h                          |    6 +
 tools/libxl/libxl_pqos.c                     |  163 +++++++++++++++++
 tools/libxl/libxl_types.idl                  |   13 ++
 tools/libxl/xl.h                             |    3 +
 tools/libxl/xl_cmdimpl.c                     |  133 ++++++++++++++
 tools/libxl/xl_cmdtable.c                    |   15 ++
 xen/arch/x86/Makefile                        |    1 +
 xen/arch/x86/cpu/intel.c                     |    6 +
 xen/arch/x86/domain.c                        |    8 +
 xen/arch/x86/domctl.c                        |   40 +++++
 xen/arch/x86/pqos.c                          |  242
++++++++++++++++++++++++++
 xen/arch/x86/setup.c                         |    3 +
 xen/arch/x86/smp.c                           |    7 +-
 xen/arch/x86/smpboot.c                       |   19 +-
 xen/arch/x86/sysctl.c                        |   65 +++++++
 xen/include/asm-x86/cpufeature.h             |    1 +
 xen/include/asm-x86/domain.h                 |    2 +
 xen/include/asm-x86/msr-index.h              |    5 +
 xen/include/asm-x86/pqos.h                   |   51 ++++++
 xen/include/asm-x86/smp.h                    |    2 +
 xen/include/public/domctl.h                  |   20 +++
 xen/include/public/sysctl.h                  |   10 ++
 xen/include/xen/cpumask.h                    |    1 +
 xen/xsm/flask/hooks.c                        |    8 +
 xen/xsm/flask/policy/access_vectors          |   17 +-
 31 files changed, 907 insertions(+), 9 deletions(-)
 create mode 100644 tools/libxl/libxl_pqos.c
 create mode 100644 xen/arch/x86/pqos.c
 create mode 100644 xen/include/asm-x86/pqos.h

--
1.7.9.5

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#32 lore raw
Quoted 12 lines
Quoted 11 lines
Quoted 1 line · Dongxiao

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dongxiao Xu
Sent: Thursday, December 05, 2013 5:39 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Xen-devel] [PATCH v6 0/7] enable Cache QoS Monitoring (CQM) feature

Quoted 1 line

Any more comments about this version?

Please allow some more time - the series isn't intended for 4.4, yet our focus ought to be on 4.4 for the moment.

Jan