Skip to contentSkip to conversation

tools & docs: add L2 CAT support in tools and docs.

PATCH Superseded Yi Sun 2 participants 4 messages Sep 22, 2016 – Sep 28, 2016

v2 of 15 Superseded Latest is v15 →

lore
Share & tools
lore

Yi Sun

author
#0 lore raw

PATCH v2 3/3 tools & docs: add L2 CAT support in tools and docs.

This patch is the xl/xc changes to support Intel L2 CAT (Cache Allocation Technology).

The new level option is introduced to original CAT setting command in order to set CBM for specified level CAT.
- 'xl psr-hwinfo' is updated to show both L3 CAT and L2 CAT info.
- 'xl psr-cat-cbm-set' is updated to set cache capacity bitmasks(CBM) for a domain according to input cache level.
- 'xl psr-cat-show' is updated to show CBM of a domain according to input cache level.

Examples:

root@:~$ xl psr-hwinfo --cat
Cache Allocation Technology (CAT): L2
Socket ID       : 0
Maximum COS     : 3
CBM length      : 8
Default CBM     : 0xff
root@:~$ xl psr-cat-cbm-set -l2 1 0x7f
root@:~$ xl psr-cat-show -l2 1
Socket ID       : 0
Default CBM     : 0xff
   ID                     NAME             CBM
    1                 ubuntu14            0x7f

---
Changed since v1:
* xl_cmdimpl.c
- Add prompt message to input cache level.
* xc_psr.c
- Adjust codes to make it easier to read.

---
 docs/man/xl.pod.1.in          |  25 +++++-
 docs/misc/xl-psr.markdown     |  10 ++-
 tools/libxc/include/xenctrl.h |   7 +-
 tools/libxc/xc_psr.c          |  47 +++++++---
 tools/libxl/libxl.h           |   2 +
 tools/libxl/libxl_psr.c       |  50 ++++++++++-
 tools/libxl/libxl_types.idl   |   1 +
 tools/libxl/xl_cmdimpl.c      | 195 +++++++++++++++++++++++++++++++++++-------
 tools/libxl/xl_cmdtable.c     |   4 +-
 9 files changed, 287 insertions(+), 54 deletions(-)
docs/man/xl.pod.1.in +22 -3
index a2be541..f7887ac 100644
@@ -1696,6 +1696,9 @@ occupancy monitoring share the same set of underlying monitoring service. Once
 a domain is attached to the monitoring service, monitoring data can be shown
 for any of these monitoring types.
 
+There is no cache monitoring and memory bandwidth monitoring on L2 cache so
+far.
+
 =over 4
 
 =item B<psr-cmt-attach> [I<domain-id>]
@@ -1720,7 +1723,7 @@ monitor types are:
 
 Intel Broadwell and later server platforms offer capabilities to configure and
 make use of the Cache Allocation Technology (CAT) mechanisms, which enable more
-cache resources (i.e. L3 cache) to be made available for high priority
+cache resources (i.e. L3/L2 cache) to be made available for high priority
 applications. In the Xen implementation, CAT is used to control cache allocation
 on VM basis. To enforce cache on a specific domain, just set capacity bitmasks
 (CBM) for the domain.
@@ -1730,7 +1733,7 @@ Intel Broadwell and later server platforms also offer Code/Data Prioritization
 applications. CDP is used on a per VM basis in the Xen implementation. To
 specify code or data CBM for the domain, CDP feature must be enabled and CBM
 type options need to be specified when setting CBM, and the type options (code
-and data) are mutually exclusive.
+and data) are mutually exclusive. There is no CDP support on L2 so far.
 
 =over 4
 
@@ -1747,6 +1750,11 @@ B<OPTIONS>
 
 Specify the socket to process, otherwise all sockets are processed.
 
+=item B<-l LEVEL>, B<--level=LEVEL>
+
+Specify the cache level to process, otherwise the last level cache is
+processed.
+
 =item B<-c>, B<--code>
 
 Set code CBM when CDP is enabled.
@@ -1757,10 +1765,21 @@ Set data CBM when CDP is enabled.
 
 =back
 
-=item B<psr-cat-show> [I<domain-id>]
+=item B<psr-cat-show> [I<OPTIONS>] [I<domain-id>]
 
 Show CAT settings for a certain domain or all domains.
 
+B<OPTIONS>
+
+=over 4
+
+=item B<-l LEVEL>, B<--level=LEVEL>
+
+Specify the cache level to process, otherwise the last level cache is
+processed.
+
+=back
+
 =back
 
 =head1 IGNORED FOR COMPATIBILITY WITH XM
docs/misc/xl-psr.markdown +8 -2
index c3c1e8e..bd2b6bd 100644
@@ -70,7 +70,7 @@ total-mem-bandwidth instead of cache-occupancy). E.g. after a `xl psr-cmt-attach
 
 Cache Allocation Technology (CAT) is a new feature available on Intel
 Broadwell and later server platforms that allows an OS or Hypervisor/VMM to
-partition cache allocation (i.e. L3 cache) based on application priority or
+partition cache allocation (i.e. L3/L2 cache) based on application priority or
 Class of Service (COS). Each COS is configured using capacity bitmasks (CBM)
 which represent cache capacity and indicate the degree of overlap and
 isolation between classes. System cache resource is divided into numbers of
@@ -119,13 +119,19 @@ A cbm is valid only when:
 In a multi-socket system, the same cbm will be set on each socket by default.
 Per socket cbm can be specified with the `--socket SOCKET` option.
 
+In different systems, the different cache level is supported, e.g. L3 cache or
+L2 cache. Per cache level cbm can be specified with the `--level LEVEL` option.
+
 Setting the CBM may not be successful if insufficient COS is available. In
 such case unused COS(es) may be freed by setting CBM of all related domains to
 its default value(all-ones).
 
 Per domain CBM settings can be shown by:
 
-`xl psr-cat-show`
+`xl psr-cat-show [OPTIONS] <domid>`
+
+In different systems, the different cache level is supported, e.g. L3 cache or
+L2 cache. Per cache level cbm can be specified with the `--level LEVEL` option.
 
 ## Code and Data Prioritization (CDP)
 
tools/libxc/include/xenctrl.h +4 -3
index 560ce7b..d70e8a8 100644
@@ -2585,6 +2585,7 @@ enum xc_psr_cat_type {
     XC_PSR_CAT_L3_CBM      = 1,
     XC_PSR_CAT_L3_CBM_CODE = 2,
     XC_PSR_CAT_L3_CBM_DATA = 3,
+    XC_PSR_CAT_L2_CBM      = 4,
 };
 typedef enum xc_psr_cat_type xc_psr_cat_type;
 
@@ -2609,9 +2610,9 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
 int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
                                xc_psr_cat_type type, uint32_t target,
                                uint64_t *data);
-int xc_psr_cat_get_l3_info(xc_interface *xch, uint32_t socket,
-                           uint32_t *cos_max, uint32_t *cbm_len,
-                           bool *cdp_enabled);
+int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, int lvl,
+                        uint32_t *cos_max, uint32_t *cbm_len,
+                        bool *cdp_enabled);
 
 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
 int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
tools/libxc/xc_psr.c +35 -12

71 lines not on this page · raw message

tools/libxl/libxl.h +2 -0
index 7cfa540..b154267 100644
@@ -2147,6 +2147,8 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
  */
 int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
                               int *nr);
+int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
+                           int *nr, int lvl);
 void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr);
 #endif
 
tools/libxl/libxl_psr.c +48 -2

56 lines not on this page · raw message

tools/libxl/libxl_types.idl +1 -0
index 98bfc3a..4503a8b 100644
@@ -890,6 +890,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
     (1, "L3_CBM"),
     (2, "L3_CBM_CODE"),
     (3, "L3_CBM_DATA"),
+    (4, "L2_CBM"),
     ])
 
 libxl_psr_cat_info = Struct("psr_cat_info", [
tools/libxl/xl_cmdimpl.c +164 -31

268 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +3 -1
index 78786fe..5a2676e 100644
@@ -549,13 +549,15 @@ struct cmd_spec cmd_table[] = {
       "Set cache capacity bitmasks(CBM) for a domain",
       "[options] <Domain> <CBM>",
       "-s <socket>       Specify the socket to process, otherwise all sockets are processed\n"
+      "-l <level>        Specify the cache level to process, otherwise L3 cache is processed\n"
       "-c                Set code CBM if CDP is supported\n"
       "-d                Set data CBM if CDP is supported\n"
     },
     { "psr-cat-show",
       &main_psr_cat_show, 0, 1,
       "Show Cache Allocation Technology information",
-      "<Domain>",
+      "[options] <Domain>",
+      "-l <level>        Specify the cache level to process, otherwise L3 cache is processed\n"
     },
 
 #endif
Signature · 7 lines
2.7.4


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

Yi Sun writes ("[v2 3/3] tools & docs: add L2 CAT support in tools and docs."):

Quoted 5 lines

This patch is the xl/xc changes to support Intel L2 CAT (Cache Allocation Technology).

The new level option is introduced to original CAT setting command in order to set CBM for specified level CAT.

Thanks for this. I have some comments about the libxl API and xl.

You'll see that I'm somewhat confused. Please help enlighten me :-).

tools/libxc/xc_psr.c int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid, · line 330

Quoted 5 lines
tools/libxc/xc_psr.c +5 -0
+#define L3_CAT 3
+#define L2_CAT 2
+int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, int lvl,
+                        uint32_t *cos_max, uint32_t *cbm_len,
+                        bool *cdp_enabled)

I find these defines rather odd. You have chosen to use an integer "level" to specify which cache to affect. It probably wouldn't be desirable to decouple these integer values from the names, but the names are just integers with a funny hat on.

If these names are really useful they should be in the IDL.

tools/libxc/include/xenctrl.h int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid, · line 2615

Quoted 6 lines
tools/libxc/include/xenctrl.h +3 -3
-int xc_psr_cat_get_l3_info(xc_interface *xch, uint32_t socket,
-                           uint32_t *cos_max, uint32_t *cbm_len,
-                           bool *cdp_enabled);
+int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, int lvl,
+                        uint32_t *cos_max, uint32_t *cbm_len,
+                        bool *cdp_enabled);

This needs a new HAVE #define.

Quoted 4 lines
tools/libxl/libxl_psr.c +0 -0
index 99733f6..861d5a8 100644

..

Quoted 5 lines
tools/libxl/libxl_psr.c +5 -0
+static int psr_l2_cat_hwinfo(void)
+{
+    int rc;
+    int i, nr;
+    libxl_psr_cat_info *info;

...

tools/libxl/libxl_psr.c

Quoted 7 lines
tools/libxl/libxl_psr.c +7 -0
+    for (i = 0; i < nr; i++) {
+        /* There is no CMT on L2 cache so far. */
+        printf("%-16s: %u\n", "Socket ID", info[i].id);
+        printf("%-16s: %u\n", "Maximum COS", info[i].cos_max);
+        printf("%-16s: %u\n", "CBM length", info[i].cbm_len);
+        printf("%-16s: %#llx\n", "Default CBM",
+               (1ull << info[i].cbm_len) - 1);

I find this code confusing.

I don't understand why libxl needs to know about the properties of L2 vs L3 CAT. If it does need to know these properties then probably the IDL needs to know about them too, but the IDL is completely agnostic.

Perhaps libxl ought probably to be "thinner", and simply present whats in the IDL ?

For example:

tools/libxl/libxl_psr.c

Quoted 4 lines
tools/libxl/libxl_psr.c +4 -0
+    if (lvl == 2) {
+        if (opt_data || opt_code) {
+            fprintf(stderr, "L2 CAT does not support CDP yet.\n");
+            return -1;

This should perhaps be done by calling libxl and getting a notimplemented error ?

tools/libxl/libxl_psr.c

Quoted 11 lines
tools/libxl/libxl_psr.c +11 -0
+    } else if (lvl == 3) {
+        if (opt_data && opt_code) {
+            fprintf(stderr, "Cannot handle -c and -d at the same time\n");
+            return -1;
+        } else if (opt_data) {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM_DATA;
+        } else if (opt_code) {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM_CODE;
+        } else {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM;
+        }

Is this inability to do -c and -d really contingent on the cache level ?

tools/libxl/libxl_psr.c

Quoted 4 lines
     } else {
tools/libxl/libxl_psr.c +2 -1
-        type = LIBXL_PSR_CBM_TYPE_L3_CBM;
+        fprintf(stderr, "'xl %s' requires to input cache level -l%d or -l%d.\n",
+                "psr-cat-cbm-set", 2, 3);

I think you have made the old calling pattern break, here: that is, if you pass no -l, it takes this branch and bombs out.

Ie, a non-backwards-compatible change to the xl command line interface. I'm afraid that's not allowed.

tools/libxl/libxl_psr.c int main_psr_cat_show(int argc, char **argv) · line 9630

Quoted 9 lines
tools/libxl/libxl_psr.c +4 -1
@@ -9503,7 +9624,15 @@ int main_psr_cat_show(int argc, char **argv)
         return 2;
     }
 
-    return psr_cat_show(domid);
+    if (3 == lvl)
+        rc = psr_cat_show(domid);
+    else if (2 == lvl)
+        rc = psr_l2_cat_show(domid);

This code is confusing to me. Surely psr_cat_show should be changed to take a level argument ? Or if psr_cat_show can only show L3, why does it not have l3 in its name ?

Quoted 4 lines
tools/libxl/xl_cmdtable.c +0 -0
index 78786fe..5a2676e 100644

...

Quoted 1 line

+ "-l <level> Specify the cache level to process, otherwise L3 cache is processed\n"

Maybe I have misread the option parsing but is this actually true that it defaults to L3 ? (See above.)

Thanks,
Ian.

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

author
#2 lore raw
Quoted 4 lines · Ian Jackson

Yi Sun writes ("[v2 3/3] tools & docs: add L2 CAT support in tools and docs."):

Quoted 3 lines

This patch is the xl/xc changes to support Intel L2 CAT (Cache Allocation Technology).

Quoted 8 lines
Quoted 2 lines

The new level option is introduced to original CAT setting command in order to set CBM for specified level CAT.

Thanks for this. I have some comments about the libxl API and xl.

You'll see that I'm somewhat confused. Please help enlighten me :-).

Thank you very much for reviewing my patches and provide your comments!

Sorry to make you confused. I will try best to explain my intention ;-).

Quoted 11 lines

tools/libxc/xc_psr.c int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid, · line 330

Quoted 5 lines
tools/libxc/xc_psr.c +5 -0
+#define L3_CAT 3
+#define L2_CAT 2
+int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, int lvl,
+                        uint32_t *cos_max, uint32_t *cbm_len,
+                        bool *cdp_enabled)

I find these defines rather odd. You have chosen to use an integer "level" to specify which cache to affect. It probably wouldn't be desirable to decouple these integer values from the names, but the names are just integers with a funny hat on.

Quoted 3 lines

If these names are really useful they should be in the IDL.

Thanks! I will remove the macros and just use integer.

Quoted 10 lines

tools/libxc/include/xenctrl.h int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid, · line 2615

Quoted 6 lines
tools/libxc/include/xenctrl.h +3 -3
-int xc_psr_cat_get_l3_info(xc_interface *xch, uint32_t socket,
-                           uint32_t *cos_max, uint32_t *cbm_len,
-                           bool *cdp_enabled);
+int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, int lvl,
+                        uint32_t *cos_max, uint32_t *cbm_len,
+                        bool *cdp_enabled);

This needs a new HAVE #define.

Thanks! I will add one more HAVE #define in xl.h.

Quoted 19 lines
Quoted 4 lines
tools/libxl/libxl_psr.c +0 -0
index 99733f6..861d5a8 100644

..

Quoted 5 lines
tools/libxl/libxl_psr.c +5 -0
+static int psr_l2_cat_hwinfo(void)
+{
+    int rc;
+    int i, nr;
+    libxl_psr_cat_info *info;

...

tools/libxl/libxl_psr.c

Quoted 7 lines
tools/libxl/libxl_psr.c +7 -0
+    for (i = 0; i < nr; i++) {
+        /* There is no CMT on L2 cache so far. */
+        printf("%-16s: %u\n", "Socket ID", info[i].id);
+        printf("%-16s: %u\n", "Maximum COS", info[i].cos_max);
+        printf("%-16s: %u\n", "CBM length", info[i].cbm_len);
+        printf("%-16s: %#llx\n", "Default CBM",
+               (1ull << info[i].cbm_len) - 1);
Quoted 6 lines

I find this code confusing.

I don't understand why libxl needs to know about the properties of L2 vs L3 CAT. If it does need to know these properties then probably the IDL needs to know about them too, but the IDL is completely agnostic.

psr_l2_cat_hwinfo() is implemented to get L2 CAT HW info back. Because this HW info is almost same as L3 CAT, I reuse the libxl_psr_cat_info defined in libxl_types.idl. If you think this is not good enough, I think I may add 'lvl' in libxl_psr_cat_info to express the level to handle?

Quoted 5 lines

Perhaps libxl ought probably to be "thinner", and simply present whats in the IDL ?

For example:

Quoted 8 lines

tools/libxl/libxl_psr.c

Quoted 4 lines
tools/libxl/libxl_psr.c +4 -0
+    if (lvl == 2) {
+        if (opt_data || opt_code) {
+            fprintf(stderr, "L2 CAT does not support CDP yet.\n");
+            return -1;

This should perhaps be done by calling libxl and getting a notimplemented error ?

I think your intention is to put more feature details into libxl_psr.c then the developer of other app will be easy to implement the app, right?

My concerns are below:
1. The application needs user to input the lvl option to know which lvl to operate anyway. Of course, we can use L3 as default option to be backward compatible. But to get/set L2, we still need user to input level. That means the application knows the level concept.
2. From the functional view, print what information out and how to operate should be decided by application but not the library.

So, I think it is acceptable to let xl know some L2 and L3 details and operate differently on different levels.

If my thought is not right, please correct me. Thank you!

Quoted 12 lines

tools/libxl/libxl_psr.c

Quoted 11 lines
tools/libxl/libxl_psr.c +11 -0
+    } else if (lvl == 3) {
+        if (opt_data && opt_code) {
+            fprintf(stderr, "Cannot handle -c and -d at the same time\n");
+            return -1;
+        } else if (opt_data) {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM_DATA;
+        } else if (opt_code) {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM_CODE;
+        } else {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM;
+        }
Quoted 3 lines

Is this inability to do -c and -d really contingent on the cache level ?

Because '-c'(code) and '-d'(data) are used for CDP and L2 CAT does not support CDP, they are handled only at L3 level now.

Quoted 11 lines

tools/libxl/libxl_psr.c

Quoted 4 lines
     } else {
tools/libxl/libxl_psr.c +2 -1
-        type = LIBXL_PSR_CBM_TYPE_L3_CBM;
+        fprintf(stderr, "'xl %s' requires to input cache level -l%d or -l%d.\n",
+                "psr-cat-cbm-set", 2, 3);

I think you have made the old calling pattern break, here: that is, if you pass no -l, it takes this branch and bombs out.

Ie, a non-backwards-compatible change to the xl command line interface. I'm afraid that's not allowed.

Thank you! I will remove this and handle L3 by default because L3 is the only choice in old interface.

Quoted 4 lines
Quoted 4 lines
tools/libxl/libxl_psr.c +0 -0
@@ -9503,7 +9624,15 @@ int main_psr_cat_show(int argc, char **argv)
         return 2;
     }
 
Quoted 10 lines

tools/libxl/libxl_psr.c int main_psr_cat_show(int argc, char **argv) · line 9630

Quoted 5 lines
tools/libxl/libxl_psr.c +4 -1
-    return psr_cat_show(domid);
+    if (3 == lvl)
+        rc = psr_cat_show(domid);
+    else if (2 == lvl)
+        rc = psr_l2_cat_show(domid);

This code is confusing to me. Surely psr_cat_show should be changed to take a level argument ? Or if psr_cat_show can only show L3, why does it not have l3 in its name ?

Sorry for the confusion.

psr_cat_show() was implemented for L3 CAT before. To support L2, I implement psr_l2_cat_show(). But I don't want to modify the old function so psr_cat_show is remained.

If you think this is not good, I can change psr_cat_show to psr_l3_cat_show to make it clearer.

Quoted 10 lines
Quoted 4 lines
tools/libxl/xl_cmdtable.c +0 -0
index 78786fe..5a2676e 100644

...

Quoted 1 line

+ "-l <level> Specify the cache level to process, otherwise L3 cache is processed\n"

Maybe I have misread the option parsing but is this actually true that it defaults to L3 ? (See above.)

Sorry for this. I missed to modify this sentence.

If L3 is the default behavior as above comment, this sentence will be kept.

Quoted 3 lines

Thanks,
Ian.

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

author
#3 lore raw

Hi, Ian,

Any comments? That would be very appreciated. Thanks!

BRs,
Sun Yi

Quoted 174 lines · Yi Sun
Quoted 4 lines · Ian Jackson

Yi Sun writes ("[v2 3/3] tools & docs: add L2 CAT support in tools and docs."):

Quoted 3 lines

This patch is the xl/xc changes to support Intel L2 CAT (Cache Allocation Technology).

Quoted 8 lines
Quoted 2 lines

The new level option is introduced to original CAT setting command in order to set CBM for specified level CAT.

Thanks for this. I have some comments about the libxl API and xl.

You'll see that I'm somewhat confused. Please help enlighten me :-).

Thank you very much for reviewing my patches and provide your comments!

Sorry to make you confused. I will try best to explain my intention ;-).

Quoted 11 lines

tools/libxc/xc_psr.c int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid, · line 330

Quoted 5 lines
tools/libxc/xc_psr.c +5 -0
+#define L3_CAT 3
+#define L2_CAT 2
+int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, int lvl,
+                        uint32_t *cos_max, uint32_t *cbm_len,
+                        bool *cdp_enabled)

I find these defines rather odd. You have chosen to use an integer "level" to specify which cache to affect. It probably wouldn't be desirable to decouple these integer values from the names, but the names are just integers with a funny hat on.

Quoted 3 lines

If these names are really useful they should be in the IDL.

Thanks! I will remove the macros and just use integer.

Quoted 10 lines

tools/libxc/include/xenctrl.h int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid, · line 2615

Quoted 6 lines
tools/libxc/include/xenctrl.h +3 -3
-int xc_psr_cat_get_l3_info(xc_interface *xch, uint32_t socket,
-                           uint32_t *cos_max, uint32_t *cbm_len,
-                           bool *cdp_enabled);
+int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, int lvl,
+                        uint32_t *cos_max, uint32_t *cbm_len,
+                        bool *cdp_enabled);

This needs a new HAVE #define.

Thanks! I will add one more HAVE #define in xl.h.

Quoted 19 lines
Quoted 4 lines
tools/libxl/libxl_psr.c +0 -0
index 99733f6..861d5a8 100644

..

Quoted 5 lines
tools/libxl/libxl_psr.c +5 -0
+static int psr_l2_cat_hwinfo(void)
+{
+    int rc;
+    int i, nr;
+    libxl_psr_cat_info *info;

...

tools/libxl/libxl_psr.c

Quoted 7 lines
tools/libxl/libxl_psr.c +7 -0
+    for (i = 0; i < nr; i++) {
+        /* There is no CMT on L2 cache so far. */
+        printf("%-16s: %u\n", "Socket ID", info[i].id);
+        printf("%-16s: %u\n", "Maximum COS", info[i].cos_max);
+        printf("%-16s: %u\n", "CBM length", info[i].cbm_len);
+        printf("%-16s: %#llx\n", "Default CBM",
+               (1ull << info[i].cbm_len) - 1);
Quoted 6 lines

I find this code confusing.

I don't understand why libxl needs to know about the properties of L2 vs L3 CAT. If it does need to know these properties then probably the IDL needs to know about them too, but the IDL is completely agnostic.

psr_l2_cat_hwinfo() is implemented to get L2 CAT HW info back. Because this HW info is almost same as L3 CAT, I reuse the libxl_psr_cat_info defined in libxl_types.idl. If you think this is not good enough, I think I may add 'lvl' in libxl_psr_cat_info to express the level to handle?

Quoted 5 lines

Perhaps libxl ought probably to be "thinner", and simply present whats in the IDL ?

For example:

Quoted 8 lines

tools/libxl/libxl_psr.c

Quoted 4 lines
tools/libxl/libxl_psr.c +4 -0
+    if (lvl == 2) {
+        if (opt_data || opt_code) {
+            fprintf(stderr, "L2 CAT does not support CDP yet.\n");
+            return -1;

This should perhaps be done by calling libxl and getting a notimplemented error ?

I think your intention is to put more feature details into libxl_psr.c then the developer of other app will be easy to implement the app, right?

My concerns are below:
1. The application needs user to input the lvl option to know which lvl to operate anyway. Of course, we can use L3 as default option to be backward compatible. But to get/set L2, we still need user to input level. That means the application knows the level concept.
2. From the functional view, print what information out and how to operate should be decided by application but not the library.

So, I think it is acceptable to let xl know some L2 and L3 details and operate differently on different levels.

If my thought is not right, please correct me. Thank you!

Quoted 12 lines

tools/libxl/libxl_psr.c

Quoted 11 lines
tools/libxl/libxl_psr.c +11 -0
+    } else if (lvl == 3) {
+        if (opt_data && opt_code) {
+            fprintf(stderr, "Cannot handle -c and -d at the same time\n");
+            return -1;
+        } else if (opt_data) {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM_DATA;
+        } else if (opt_code) {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM_CODE;
+        } else {
+            type = LIBXL_PSR_CBM_TYPE_L3_CBM;
+        }
Quoted 3 lines

Is this inability to do -c and -d really contingent on the cache level ?

Because '-c'(code) and '-d'(data) are used for CDP and L2 CAT does not support CDP, they are handled only at L3 level now.

Quoted 11 lines

tools/libxl/libxl_psr.c

Quoted 4 lines
     } else {
tools/libxl/libxl_psr.c +2 -1
-        type = LIBXL_PSR_CBM_TYPE_L3_CBM;
+        fprintf(stderr, "'xl %s' requires to input cache level -l%d or -l%d.\n",
+                "psr-cat-cbm-set", 2, 3);

I think you have made the old calling pattern break, here: that is, if you pass no -l, it takes this branch and bombs out.

Ie, a non-backwards-compatible change to the xl command line interface. I'm afraid that's not allowed.

Thank you! I will remove this and handle L3 by default because L3 is the only choice in old interface.

Quoted 4 lines
Quoted 4 lines
tools/libxl/libxl_psr.c +0 -0
@@ -9503,7 +9624,15 @@ int main_psr_cat_show(int argc, char **argv)
         return 2;
     }
 
Quoted 10 lines

tools/libxl/libxl_psr.c int main_psr_cat_show(int argc, char **argv) · line 9630

Quoted 5 lines
tools/libxl/libxl_psr.c +4 -1
-    return psr_cat_show(domid);
+    if (3 == lvl)
+        rc = psr_cat_show(domid);
+    else if (2 == lvl)
+        rc = psr_l2_cat_show(domid);

This code is confusing to me. Surely psr_cat_show should be changed to take a level argument ? Or if psr_cat_show can only show L3, why does it not have l3 in its name ?

Sorry for the confusion.

psr_cat_show() was implemented for L3 CAT before. To support L2, I implement psr_l2_cat_show(). But I don't want to modify the old function so psr_cat_show is remained.

If you think this is not good, I can change psr_cat_show to psr_l3_cat_show to make it clearer.

Quoted 10 lines
Quoted 4 lines
tools/libxl/xl_cmdtable.c +0 -0
index 78786fe..5a2676e 100644

...

Quoted 1 line

+ "-l <level> Specify the cache level to process, otherwise L3 cache is processed\n"

Maybe I have misread the option parsing but is this actually true that it defaults to L3 ? (See above.)

Sorry for this. I missed to modify this sentence.

If L3 is the default behavior as above comment, this sentence will be kept.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Thanks,
Ian.

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

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