Skip to contentSkip to conversation

x86: add support for L2 CAT in hypervisor.

PATCH Superseded Yi Sun 2 participants 5 messages Aug 25, 2016 – Sep 8, 2016

v1 of 15 Superseded Latest is v15 →

lore
Share & tools
lore

Yi Sun

author
#0 lore raw

PATCH 2/3 x86: add support for L2 CAT in hypervisor.

Add L2 CAT (Cache Allocation Technology) feature support in hypervisor:
- Implement 'struct feat_ops' callback functions for L2 CAT and initialize L2 CAT feature and add it into feature list.
- Add new sysctl to get L2 CAT information.
- Add new domctl to set/get L2 CAT CBM.

---
 xen/arch/x86/domctl.c           |  13 +++
 xen/arch/x86/psr.c              | 226 +++++++++++++++++++++++++++++++++++++++-
 xen/arch/x86/sysctl.c           |  16 ++-
 xen/include/asm-x86/msr-index.h |   1 +
 xen/include/asm-x86/psr.h       |   2 +
 xen/include/public/domctl.h     |   2 +
 xen/include/public/sysctl.h     |   3 +-
 7 files changed, 258 insertions(+), 5 deletions(-)
xen/arch/x86/domctl.c +13 -0
index a51ed2c..604d202 100644
@@ -1396,6 +1396,19 @@ long arch_do_domctl(
             copyback = 1;
             break;
 
+        case XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM:
+            ret = psr_set_val(d, domctl->u.psr_cat_op.target,
+                              domctl->u.psr_cat_op.data,
+                              PSR_MASK_TYPE_L2_CBM);
+            break;
+
+        case XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM:
+            ret = psr_get_val(d, domctl->u.psr_cat_op.target,
+                              &domctl->u.psr_cat_op.data,
+                              PSR_MASK_TYPE_L2_CBM);
+            copyback = 1;
+            break;
+
         default:
             ret = -EOPNOTSUPP;
             break;
xen/arch/x86/psr.c +225 -1

264 lines not on this page · raw message

xen/arch/x86/sysctl.c +13 -3
index a143e7a..3a1d80b 100644
@@ -178,14 +178,24 @@ long arch_do_sysctl(
         case XEN_SYSCTL_PSR_CAT_get_l3_info:
             ret = psr_get_info(sysctl->u.psr_cat_op.target,
                                PSR_MASK_TYPE_L3_CBM,
-                               &sysctl->u.psr_cat_op.u.l3_info.cbm_len,
-                               &sysctl->u.psr_cat_op.u.l3_info.cos_max,
-                               &sysctl->u.psr_cat_op.u.l3_info.flags);
+                               &sysctl->u.psr_cat_op.u.info.cbm_len,
+                               &sysctl->u.psr_cat_op.u.info.cos_max,
+                               &sysctl->u.psr_cat_op.u.info.flags);
 
             if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) )
                 ret = -EFAULT;
             break;
 
+        case XEN_SYSCTL_PSR_CAT_get_l2_info:
+            ret = psr_get_info(sysctl->u.psr_cat_op.target,
+                               PSR_MASK_TYPE_L2_CBM,
+                               &sysctl->u.psr_cat_op.u.info.cbm_len,
+                               &sysctl->u.psr_cat_op.u.info.cos_max,
+                               &sysctl->u.psr_cat_op.u.info.flags);
+            if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) )
+                ret = -EFAULT;
+            break;
+
         default:
             ret = -EOPNOTSUPP;
             break;
xen/include/asm-x86/msr-index.h +1 -0
index 1095c81..e276f8a 100644
@@ -339,6 +339,7 @@
 #define MSR_IA32_PSR_L3_MASK(n)	(0x00000c90 + (n))
 #define MSR_IA32_PSR_L3_MASK_CODE(n)	(0x00000c90 + (n) * 2 + 1)
 #define MSR_IA32_PSR_L3_MASK_DATA(n)	(0x00000c90 + (n) * 2)
+#define MSR_IA32_PSR_L2_MASK(n)		(0x00000d10 + (n))
 
 /* Intel Model 6 */
 #define MSR_P6_PERFCTR(n)		(0x000000c1 + (n))
xen/include/asm-x86/psr.h +2 -0
index 0993863..de9a5b5 100644
@@ -23,6 +23,7 @@
 
 /* Resource Type Enumeration */
 #define PSR_RESOURCE_TYPE_L3            0x2
+#define PSR_RESOURCE_TYPE_L2            0x4
 
 /* L3 Monitoring Features */
 #define PSR_CMT_L3_OCCUPANCY           0x1
@@ -50,6 +51,7 @@ enum mask_type {
     PSR_MASK_TYPE_L3_CBM,
     PSR_MASK_TYPE_L3_CODE,
     PSR_MASK_TYPE_L3_DATA,
+    PSR_MASK_TYPE_L2_CBM,
 };
 
 extern struct psr_cmt *psr_cmt;
xen/include/public/domctl.h +2 -0
index ddd3de4..8a30299 100644
@@ -1136,6 +1136,8 @@ struct xen_domctl_psr_cat_op {
 #define XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA    3
 #define XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE    4
 #define XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA    5
+#define XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM     6
+#define XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM     7
     uint32_t cmd;       /* IN: XEN_DOMCTL_PSR_CAT_OP_* */
     uint32_t target;    /* IN */
     uint64_t data;      /* IN/OUT */
xen/include/public/sysctl.h +2 -1
index 8197c14..e2542fa 100644
@@ -734,6 +734,7 @@ typedef struct xen_sysctl_pcitopoinfo xen_sysctl_pcitopoinfo_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t);
 
 #define XEN_SYSCTL_PSR_CAT_get_l3_info               0
+#define XEN_SYSCTL_PSR_CAT_get_l2_info               1
 struct xen_sysctl_psr_cat_op {
     uint32_t cmd;       /* IN: XEN_SYSCTL_PSR_CAT_* */
     uint32_t target;    /* IN */
@@ -743,7 +744,7 @@ struct xen_sysctl_psr_cat_op {
             uint32_t cos_max;   /* OUT: Maximum COS */
 #define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
             uint32_t flags;     /* OUT: CAT flags */
-        } l3_info;
+        } info;
     } u;
 };
 typedef struct xen_sysctl_psr_cat_op xen_sysctl_psr_cat_op_t;
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 25.08.16 at 07:22, <[email protected]> wrote:

Please extend the comments given for patch 1 to this one. Just one extra thing:

xen/include/public/sysctl.h struct xen_sysctl_psr_cat_op { · line 747

Quoted 6 lines
xen/include/public/sysctl.h +1 -1
@@ -743,7 +744,7 @@ struct xen_sysctl_psr_cat_op {
             uint32_t cos_max;   /* OUT: Maximum COS */
 #define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
             uint32_t flags;     /* OUT: CAT flags */
-        } l3_info;
+        } info;

Such an adjustment breaks the tools build, i.e. can't come without also minimally adjusting libxc.

Jan

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

author
#2 lore raw
Quoted 15 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 25.08.16 at 07:22, <[email protected]> wrote:

Please extend the comments given for patch 1 to this one. Just one extra thing:

xen/include/public/sysctl.h struct xen_sysctl_psr_cat_op { · line 747

Quoted 6 lines
xen/include/public/sysctl.h +1 -1
@@ -743,7 +744,7 @@ struct xen_sysctl_psr_cat_op {
             uint32_t cos_max;   /* OUT: Maximum COS */
 #define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
             uint32_t flags;     /* OUT: CAT flags */
-        } l3_info;
+        } info;

Such an adjustment breaks the tools build, i.e. can't come without also minimally adjusting libxc.

Quoted 1 line

Jan

I thought 4.8 will also make tools version upgrade but not considered to be compatible with old tools. Sorry for that.

Considering the compatibility and to support future feature, I want to add a general structure in union, like below. How do you think? Thanks!

union {
struct {
uint32_t cbm_len; /* OUT: CBM length */
uint32_t cos_max; /* OUT: Maximum COS */

#define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
            uint32_t flags;     /* OUT: CAT flags */
        } l3_info;

        struct {
            uint32_t cbm_len;
            uint32_t cos_max;
            uint32_t data;     /* Specific data of feature */
        } psr_info;
    } u;

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

#3 lore raw
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 09:13, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 25.08.16 at 07:22, <[email protected]> wrote:

Please extend the comments given for patch 1 to this one. Just one extra thing:

xen/include/public/sysctl.h struct xen_sysctl_psr_cat_op { · line 747

Quoted 6 lines
xen/include/public/sysctl.h +1 -1
@@ -743,7 +744,7 @@ struct xen_sysctl_psr_cat_op {
             uint32_t cos_max;   /* OUT: Maximum COS */
 #define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
             uint32_t flags;     /* OUT: CAT flags */
-        } l3_info;
+        } info;

Such an adjustment breaks the tools build, i.e. can't come without also minimally adjusting libxc.

Quoted 6 lines
Quoted 1 line

Jan

I thought 4.8 will also make tools version upgrade but not considered to be compatible with old tools. Sorry for that.

Considering the compatibility and to support future feature, I want to add a general structure in union, like below. How do you think? Thanks!

No, you don't need to be compatible with old tools. But you need to avoid build breakage between patches 2 and 3. Please always remember that (a) patch series may not get applied in one go and
(b) even if they do any intermediate build breakage will hinder bisection attempts.

Jan

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

author
#4 lore raw
Quoted 24 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 09:13, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 25.08.16 at 07:22, <[email protected]> wrote:

Please extend the comments given for patch 1 to this one. Just one extra thing:

xen/include/public/sysctl.h struct xen_sysctl_psr_cat_op { · line 747

Quoted 6 lines
xen/include/public/sysctl.h +1 -1
@@ -743,7 +744,7 @@ struct xen_sysctl_psr_cat_op {
             uint32_t cos_max;   /* OUT: Maximum COS */
 #define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
             uint32_t flags;     /* OUT: CAT flags */
-        } l3_info;
+        } info;

Such an adjustment breaks the tools build, i.e. can't come without also minimally adjusting libxc.

Quoted 6 lines
Quoted 1 line

Jan

I thought 4.8 will also make tools version upgrade but not considered to be compatible with old tools. Sorry for that.

Considering the compatibility and to support future feature, I want to add a general structure in union, like below. How do you think? Thanks!

Quoted 7 lines

No, you don't need to be compatible with old tools. But you need to avoid build breakage between patches 2 and 3. Please always remember that (a) patch series may not get applied in one go and
(b) even if they do any intermediate build breakage will hinder bisection attempts.

Jan

Got it. Thanks a lot for your explanation!

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