All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
@ 2017-12-19  0:42 Yi Sun
  2017-12-19  0:42 ` [PATCH v10 01/11] x86: implement get hw info flow for MBA Yi Sun
                   ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel
  Cc: Yi Sun, Andrew Cooper, Ian Jackson, Julien Grall, Jan Beulich,
	Chao Peng, Wei Liu, Daniel De Graaf, Roger Pau Monné

Hi, all,

We plan to bring a new PSR (Platform Shared Resource) feature called
Intel Memory Bandwidth Allocation (MBA) to Xen.

Besides the MBA enabling, we change some interfaces to make them more
general but not only for CAT.

The first 5 patches of V9 haven been merged. To fix a few issues, the
V10 is submitted.

Any comments are welcome!

You can find this series at:
https://github.com/yisun-git/xen_mba mba_v10

BRs,
Sun Yi

CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Daniel De Graaf <dgdegra@tycho.nsa.gov>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>
CC: Julien Grall <julien.grall@arm.com>

---
Acked and Reviewed list before V10:

a - Acked-by
r - Reviewed-by

  ar patch 2  - x86: implement get value interface for MBA
  r  patch 3  - x86: implement set value flow for MBA
  ar patch 4  - tools: create general interfaces to support psr allocation features
  ar patch 5  - tools: implement the new libxc get hw info interface
  ar patch 6  - tools: implement the new libxl get hw info interface
  ar patch 7  - tools: implement the new xl get hw info interface
  ar patch 8  - tools: rename 'xc_psr_cat_type' to 'xc_psr_type'
  ar patch 9  - tools: implement new generic get value interface and MBA get value command
  ar patch 11 - docs: add MBA description in docs

---
V10 change list:

Patch 1:
    - declare data array in top case to avoid gcc 7.2 warning.
      (suggested by Jan Beulich)
Patch 10:
    - move argc check to original place to make per socket setting work.

Yi Sun (11):
  x86: implement get hw info flow for MBA
  x86: implement get value interface for MBA
  x86: implement set value flow for MBA
  tools: create general interfaces to support psr allocation features
  tools: implement the new libxc get hw info interface
  tools: implement the new libxl get hw info interface
  tools: implement the new xl get hw info interface
  tools: rename 'xc_psr_cat_type' to 'xc_psr_type'
  tools: implement new generic get value interface and MBA get value
    command
  tools: implement new generic set value interface and MBA set value
    command
  docs: add MBA description in docs

 Config.mk                     |  20 +--
 docs/man/xl.pod.1.in          |  33 +++++
 docs/misc/xl-psr.markdown     |  62 ++++++++++
 tools/libxc/include/xenctrl.h |  44 +++++--
 tools/libxc/xc_psr.c          |  73 +++++++----
 tools/libxl/libxl.h           |  37 ++++++
 tools/libxl/libxl_psr.c       | 223 +++++++++++++++++++++++++--------
 tools/libxl/libxl_types.idl   |  22 ++++
 tools/xl/xl.h                 |   2 +
 tools/xl/xl_cmdtable.c        |  12 ++
 tools/xl/xl_psr.c             | 279 +++++++++++++++++++++++++++++++++---------
 xen/arch/x86/domctl.c         |  10 ++
 xen/arch/x86/psr.c            |  60 ++++++++-
 xen/arch/x86/sysctl.c         |  27 +++-
 xen/include/asm-x86/psr.h     |   2 +
 xen/include/public/domctl.h   |   2 +
 xen/include/public/sysctl.h   |   8 ++
 17 files changed, 752 insertions(+), 164 deletions(-)

-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v10 01/11] x86: implement get hw info flow for MBA
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-20  8:56   ` Jan Beulich
  2017-12-20 10:32   ` Jan Beulich
  2017-12-19  0:42 ` [PATCH v10 02/11] x86: implement get value interface " Yi Sun
                   ` (10 subsequent siblings)
  11 siblings, 2 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Yi Sun, Andrew Cooper, Jan Beulich, Chao Peng,
	Roger Pau Monné

This patch implements get HW info flow for MBA including its callback
function and sysctl interface.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v10:
    - declare data array in top case to avoid gcc 7.2 warning.
      (suggested by Jan Beulich)
v7:
    - change 'PSR_INFO_IDX_MBA_FLAG' to 'PSR_INFO_IDX_MBA_FLAGS'.
      (suggested by Jan Beulich)
v5:
    - use ASSERT in 'mba_get_feat_info'.
      (suggested by Roger Pau Monné)
    - correct initialization format of 'data[PSR_INFO_ARRAY_SIZE]'.
      (suggested by Roger Pau Monné and Jan Beulich)
v4:
    - remove 'ALLOC_' from macro names.
      (suggested by Roger Pau Monné)
    - initialize 'data[PSR_INFO_ARRAY_SIZE]' to 0 to prevent to leak stack data.
      (suggested by Roger Pau Monné)
v3:
    - replace 'PSR_VAL_TYPE_MBA' to 'PSR_TYPE_MBA_THRTL'.
      (suggested by Roger Pau Monné)
v2:
    - use 'XEN_SYSCTL_PSR_MBA_LINEAR' to set MBA feature HW info.
      (suggested by Chao Peng)
v1:
    - sort 'PSR_INFO_IDX_' macros as feature.
      (suggested by Chao Peng)
    - rename 'PSR_INFO_IDX_MBA_LINEAR' to 'PSR_INFO_IDX_MBA_FLAG'.
    - rename 'linear' in 'struct mba_info' to 'flags' for future extension.
---
 Config.mk                   | 20 ++++++++++----------
 xen/arch/x86/psr.c          | 14 +++++++++++++-
 xen/arch/x86/sysctl.c       | 27 +++++++++++++++++++++------
 xen/include/asm-x86/psr.h   |  2 ++
 xen/include/public/sysctl.h |  8 ++++++++
 5 files changed, 54 insertions(+), 17 deletions(-)

diff --git a/Config.mk b/Config.mk
index 51adc27..18f5c34 100644
--- a/Config.mk
+++ b/Config.mk
@@ -260,17 +260,17 @@ QEMU_TRADITIONAL_REVISION ?= $(QEMU_TAG)
 endif
 
 ifeq ($(GIT_HTTP),y)
-OVMF_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/ovmf.git
-QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-xen.git
-QEMU_TRADITIONAL_URL ?= http://xenbits.xen.org/git-http/qemu-xen-traditional.git
-SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git
-MINIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/mini-os.git
+OVMF_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/ovmf.git
+QEMU_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/qemu-xen.git
+QEMU_TRADITIONAL_URL ?= http://vt-sync.sh.intel.com/git-http/qemu-xen-traditional.git
+SEABIOS_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/seabios.git
+MINIOS_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/mini-os.git
 else
-OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git
-QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-xen.git
-QEMU_TRADITIONAL_URL ?= git://xenbits.xen.org/qemu-xen-traditional.git
-SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git
-MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git
+OVMF_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/ovmf.git
+QEMU_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/qemu-xen.git
+QEMU_TRADITIONAL_URL ?= git://vt-sync.sh.intel.com/qemu-xen-traditional.git
+SEABIOS_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/seabios.git
+MINIOS_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/mini-os.git
 endif
 OVMF_UPSTREAM_REVISION ?= 947f3737abf65fda63f3ffd97fddfa6986986868
 QEMU_UPSTREAM_REVISION ?= master
diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index 872bade..a4901d8 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -263,6 +263,10 @@ static enum psr_feat_type psr_type_to_feat_type(enum psr_type type)
         feat_type = FEAT_TYPE_L2_CAT;
         break;
 
+    case PSR_TYPE_MBA_THRTL:
+        feat_type = FEAT_TYPE_MBA;
+        break;
+
     default:
         ASSERT_UNREACHABLE();
     }
@@ -481,7 +485,15 @@ static const struct feat_props l2_cat_props = {
 static bool mba_get_feat_info(const struct feat_node *feat,
                               uint32_t data[], unsigned int array_len)
 {
-    return false;
+    ASSERT(array_len == PSR_INFO_ARRAY_SIZE);
+
+    data[PSR_INFO_IDX_COS_MAX] = feat->cos_max;
+    data[PSR_INFO_IDX_MBA_THRTL_MAX] = feat->mba.thrtl_max;
+
+    if ( feat->mba.linear )
+        data[PSR_INFO_IDX_MBA_FLAGS] |= XEN_SYSCTL_PSR_MBA_LINEAR;
+
+    return true;
 }
 
 static void mba_write_msr(unsigned int cos, uint32_t val,
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 6d48cac..4d372db 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -172,12 +172,12 @@ long arch_do_sysctl(
         break;
 
     case XEN_SYSCTL_psr_alloc:
+    {
+        uint32_t data[PSR_INFO_ARRAY_SIZE] = { };
+
         switch ( sysctl->u.psr_alloc.cmd )
         {
-            uint32_t data[PSR_INFO_ARRAY_SIZE];
-
         case XEN_SYSCTL_PSR_get_l3_info:
-        {
             ret = psr_get_info(sysctl->u.psr_alloc.target,
                                PSR_TYPE_L3_CBM, data, ARRAY_SIZE(data));
             if ( ret )
@@ -193,10 +193,8 @@ long arch_do_sysctl(
             if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) )
                 ret = -EFAULT;
             break;
-        }
 
         case XEN_SYSCTL_PSR_get_l2_info:
-        {
             ret = psr_get_info(sysctl->u.psr_alloc.target,
                                PSR_TYPE_L2_CBM, data, ARRAY_SIZE(data));
             if ( ret )
@@ -212,13 +210,30 @@ long arch_do_sysctl(
             if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) )
                 ret = -EFAULT;
             break;
-        }
+
+        case XEN_SYSCTL_PSR_get_mba_info:
+            ret = psr_get_info(sysctl->u.psr_alloc.target,
+                               PSR_TYPE_MBA_THRTL, data, ARRAY_SIZE(data));
+            if ( ret )
+                break;
+
+            sysctl->u.psr_alloc.u.mba_info.cos_max =
+                                      data[PSR_INFO_IDX_COS_MAX];
+            sysctl->u.psr_alloc.u.mba_info.thrtl_max =
+                                      data[PSR_INFO_IDX_MBA_THRTL_MAX];
+            sysctl->u.psr_alloc.u.mba_info.flags =
+                                      data[PSR_INFO_IDX_MBA_FLAGS];
+
+            if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) )
+                ret = -EFAULT;
+            break;
 
         default:
             ret = -EOPNOTSUPP;
             break;
         }
         break;
+    }
 
     case XEN_SYSCTL_get_cpu_levelling_caps:
         sysctl->u.cpu_levelling_caps.caps = levelling_caps;
diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h
index 3cf544a..c2257da 100644
--- a/xen/include/asm-x86/psr.h
+++ b/xen/include/asm-x86/psr.h
@@ -39,6 +39,8 @@
 #define PSR_INFO_IDX_COS_MAX            0
 #define PSR_INFO_IDX_CAT_CBM_LEN        1
 #define PSR_INFO_IDX_CAT_FLAGS          2
+#define PSR_INFO_IDX_MBA_THRTL_MAX      1
+#define PSR_INFO_IDX_MBA_FLAGS          2
 #define PSR_INFO_ARRAY_SIZE             3
 
 struct psr_cmt_l3 {
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index a50e345..f7f26c3 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -698,6 +698,7 @@ struct xen_sysctl_pcitopoinfo {
 
 #define XEN_SYSCTL_PSR_get_l3_info               0
 #define XEN_SYSCTL_PSR_get_l2_info               1
+#define XEN_SYSCTL_PSR_get_mba_info              2
 struct xen_sysctl_psr_alloc {
     uint32_t cmd;       /* IN: XEN_SYSCTL_PSR_* */
     uint32_t target;    /* IN */
@@ -708,6 +709,13 @@ struct xen_sysctl_psr_alloc {
 #define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
             uint32_t flags;     /* OUT: CAT flags */
         } cat_info;
+
+        struct {
+            uint32_t thrtl_max; /* OUT: Maximum throttle */
+            uint32_t cos_max;   /* OUT: Maximum COS */
+#define XEN_SYSCTL_PSR_MBA_LINEAR      (1u << 0)
+            uint32_t flags;     /* OUT: MBA flags */
+        } mba_info;
     } u;
 };
 
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 02/11] x86: implement get value interface for MBA
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
  2017-12-19  0:42 ` [PATCH v10 01/11] x86: implement get hw info flow for MBA Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 03/11] x86: implement set value flow " Yi Sun
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Yi Sun, Andrew Cooper, Jan Beulich, Chao Peng,
	Roger Pau Monné

This patch implements get value domctl interface for MBA.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v5:
    - use newly defined macro to get MBA thrtl.
      (suggested by Roger Pau Monné)
v4:
    - remove 'ALLOC_' from macro names.
      (suggested by Roger Pau Monné)
v3:
    - change 'PSR_VAL_TYPE_MBA' to 'PSR_TYPE_MBA_THRTL'.
      (suggested by Roger Pau Monné)
---
 xen/arch/x86/domctl.c       | 4 ++++
 xen/include/public/domctl.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 628c6b8..75e5e35 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1531,6 +1531,10 @@ long arch_do_domctl(
             ret = domctl_psr_get_val(d, domctl, PSR_TYPE_L2_CBM, copyback);
             break;
 
+        case XEN_DOMCTL_PSR_GET_MBA_THRTL:
+            ret = domctl_psr_get_val(d, domctl, PSR_TYPE_MBA_THRTL, copyback);
+            break;
+
 #undef domctl_psr_get_val
 
         default:
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index eaff9b3..44cf0b5 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -1074,6 +1074,7 @@ struct xen_domctl_psr_alloc {
 #define XEN_DOMCTL_PSR_GET_L3_DATA    5
 #define XEN_DOMCTL_PSR_SET_L2_CBM     6
 #define XEN_DOMCTL_PSR_GET_L2_CBM     7
+#define XEN_DOMCTL_PSR_GET_MBA_THRTL  9
     uint32_t cmd;       /* IN: XEN_DOMCTL_PSR_* */
     uint32_t target;    /* IN */
     uint64_t data;      /* IN/OUT */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 03/11] x86: implement set value flow for MBA
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
  2017-12-19  0:42 ` [PATCH v10 01/11] x86: implement get hw info flow for MBA Yi Sun
  2017-12-19  0:42 ` [PATCH v10 02/11] x86: implement get value interface " Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 04/11] tools: create general interfaces to support psr allocation features Yi Sun
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Yi Sun, Andrew Cooper, Jan Beulich, Chao Peng,
	Roger Pau Monné

This patch implements set value flow for MBA including its callback
function and domctl interface.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v9:
    - adjust codes in 'mba_sanitize_thrtl'.
      (suggested by Jan Beulich)
v8:
    - restore some old codes in 'cat_check_cbm'.
      (suggested by Jan Beulich)
    - use 'fls()' but not 'flsl()'.
      (suggested by Jan Beulich)
    - use plain '=' to assign value for thrtl in 'mba_sanitize_thrtl'.
      (suggested by Jan Beulich)
v7:
    - change name of 'check_val' to 'sanitize'.
      (suggested by Jan Beulich)
    - fix comments.
      (suggested by Jan Beulich)
    - add parentheses and change '== 0' to '!'.
      (suggested by Jan Beulich)
    - remove unnecessary check of 'mba.thrtl_max'.
      (suggested by Jan Beulich)
    - remove unnecessary intermediate variable 'mod'.
      (suggested by Jan Beulich)
    - refine an assignement sentence to use '&='.
      (suggested by Jan Beulich)
    - change type of last parameter of 'sanitize' to 'uint32_t' and
      apply same change to 'cat_check_cbm'.
      (suggested by Jan Beulich)
v6:
    - split co-exist features' values setting flow to a new patch.
      (suggested by Jan Beulich)
    - restore codes related to 'mba_check_thrtl' and 'check_value'.
      (suggested by Jan Beulich)
v5:
    - adjust position of 'cat_check_cbm' to not to make changes so big.
      (suggested by Roger Pau Monné)
    - remove 'props' from 'struct cos_write_info'.
      (suggested by Roger Pau Monné)
    - make a single return statement in 'mba_check_thrtl'.
      (suggested by Jan Beulich)
v4:
    - remove 'ALLOC_' from macro names.
      (suggested by Roger Pau Monné)
    - join two checks into a single if.
      (suggested by Roger Pau Monné)
    - remove redundant local variable 'array_len'.
      (suggested by Roger Pau Monné)
v3:
    - modify commit message to make it clear.
      (suggested by Roger Pau Monné)
    - modify functionality of 'check_val' to make it simple to only check value.
      Change the last parameter type from 'unsigned long *' to 'unsigned long'.
      (suggested by Roger Pau Monné)
    - call rdmsrl to get value just written into MSR for MBA. Because HW can
      automatically change input value to what it wants.
      (suggested by Roger Pau Monné)
    - change type of 'write_msr' to 'uint32_t' to return the value actually
      written into MSR. Then, change 'do_write_psr_msrs' to set the returned
      value into 'cos_reg_val[]'
    - move the declaration of 'j' into loop in 'do_write_psr_msrs'.
      (suggested by Roger Pau Monné)
    - change 'mba_info' to 'mba'.
      (suggested by Roger Pau Monné)
    - change 'cat_info' to 'cat'.
      (suggested by Roger Pau Monné)
    - rename 'psr_cat/PSR_CAT' to 'psr_alloc/PSR_ALLOC' and remove 'op/OP'
      from name.
      (suggested by Roger Pau Monné)
    - change 'PSR_VAL_TYPE_MBA' to 'PSR_TYPE_MBA_THRTL'.
      (suggested by Roger Pau Monné)
v2:
    - remove linear mode 'thrtl_max' check in 'mba_check_thrtl' because it has
      been checked in 'mba_init_feature'.
      (suggested by Chao Peng)
    - for non-linear mode, check if '*thrtl' is not 0 in 'mba_check_thrtl'. If
      it is 0, we do not need to change it.
      (suggested by Chao Peng)
    - move comments to explain changes of 'cos_write_info' from psr.c to commit
      message.
      (suggested by Chao Peng)
---
 xen/arch/x86/domctl.c       |  6 ++++++
 xen/arch/x86/psr.c          | 46 +++++++++++++++++++++++++++++++++++++++++----
 xen/include/public/domctl.h |  1 +
 3 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 75e5e35..36ab235 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1505,6 +1505,12 @@ long arch_do_domctl(
                               PSR_TYPE_L2_CBM);
             break;
 
+        case XEN_DOMCTL_PSR_SET_MBA_THRTL:
+            ret = psr_set_val(d, domctl->u.psr_alloc.target,
+                              domctl->u.psr_alloc.data,
+                              PSR_TYPE_MBA_THRTL);
+            break;
+
 #define domctl_psr_get_val(d, domctl, type, copyback) ({    \
     uint32_t v_;                                            \
     int r_ = psr_get_val((d), (domctl)->u.psr_alloc.target, \
diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index a4901d8..0ba8ef8 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -138,6 +138,12 @@ static const struct feat_props {
 
     /* write_msr is used to write out feature MSR register. */
     void (*write_msr)(unsigned int cos, uint32_t val, enum psr_type type);
+
+    /*
+     * sanitize is used to check if input val fulfills SDM requirement.
+     * And change it to valid value if SDM allows.
+     */
+    bool (*sanitize)(const struct feat_node *feat, uint32_t *val);
 } *feat_props[FEAT_TYPE_NUM];
 
 /*
@@ -274,11 +280,14 @@ static enum psr_feat_type psr_type_to_feat_type(enum psr_type type)
     return feat_type;
 }
 
-static bool psr_check_cbm(unsigned int cbm_len, unsigned long cbm)
+/* Implementation of allocation features' functions. */
+static bool cat_check_cbm(const struct feat_node *feat, uint32_t *val)
 {
     unsigned int first_bit, zero_bit;
+    unsigned int cbm_len = feat->cat.cbm_len;
+    unsigned long cbm = *val;
 
-    /* Set bits should only in the range of [0, cbm_len]. */
+    /* Set bits should only in the range of [0, cbm_len). */
     if ( cbm & (~0ul << cbm_len) )
         return false;
 
@@ -297,7 +306,6 @@ static bool psr_check_cbm(unsigned int cbm_len, unsigned long cbm)
     return true;
 }
 
-/* Implementation of allocation features' functions. */
 static bool cat_init_feature(const struct cpuid_leaf *regs,
                              struct feat_node *feat,
                              struct psr_socket_info *info,
@@ -434,6 +442,7 @@ static const struct feat_props l3_cat_props = {
     .alt_type = PSR_TYPE_UNKNOWN,
     .get_feat_info = cat_get_feat_info,
     .write_msr = l3_cat_write_msr,
+    .sanitize = cat_check_cbm,
 };
 
 /* L3 CDP props */
@@ -464,6 +473,7 @@ static const struct feat_props l3_cdp_props = {
     .alt_type = PSR_TYPE_L3_CBM,
     .get_feat_info = l3_cdp_get_feat_info,
     .write_msr = l3_cdp_write_msr,
+    .sanitize = cat_check_cbm,
 };
 
 /* L2 CAT props */
@@ -479,6 +489,7 @@ static const struct feat_props l2_cat_props = {
     .alt_type = PSR_TYPE_UNKNOWN,
     .get_feat_info = cat_get_feat_info,
     .write_msr = l2_cat_write_msr,
+    .sanitize = cat_check_cbm,
 };
 
 /* MBA props */
@@ -499,6 +510,32 @@ static bool mba_get_feat_info(const struct feat_node *feat,
 static void mba_write_msr(unsigned int cos, uint32_t val,
                           enum psr_type type)
 {
+    wrmsrl(MSR_IA32_PSR_MBA_MASK(cos), val);
+}
+
+static bool mba_sanitize_thrtl(const struct feat_node *feat, uint32_t *thrtl)
+{
+    /*
+     * Per SDM (chapter "Memory Bandwidth Allocation Configuration"):
+     * 1. Linear mode: In the linear mode the input precision is defined
+     *    as 100-(MBA_MAX). For instance, if the MBA_MAX value is 90, the
+     *    input precision is 10%. Values not an even multiple of the
+     *    precision (e.g., 12%) will be rounded down (e.g., to 10% delay
+     *    applied).
+     * 2. Non-linear mode: Input delay values are powers-of-two from zero
+     *    to the MBA_MAX value from CPUID. In this case any values not a
+     *    power of two will be rounded down the next nearest power of two.
+     */
+    if ( feat->mba.linear )
+        *thrtl -= *thrtl % (100 - feat->mba.thrtl_max);
+    else
+    {
+        /* Not power of 2. */
+        if ( *thrtl & (*thrtl - 1) )
+            *thrtl = 1 << (fls(*thrtl) - 1);
+    }
+
+    return *thrtl <= feat->mba.thrtl_max;
 }
 
 static const struct feat_props mba_props = {
@@ -507,6 +544,7 @@ static const struct feat_props mba_props = {
     .alt_type = PSR_TYPE_UNKNOWN,
     .get_feat_info = mba_get_feat_info,
     .write_msr = mba_write_msr,
+    .sanitize = mba_sanitize_thrtl,
 };
 
 static bool __init parse_psr_bool(const char *s, const char *delim,
@@ -972,7 +1010,7 @@ static int insert_val_into_array(uint32_t val[],
     if ( array_len < props->cos_num )
         return -ENOSPC;
 
-    if ( !psr_check_cbm(feat->cat.cbm_len, new_val) )
+    if ( !props->sanitize(feat, &new_val) )
         return -EINVAL;
 
     /*
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 44cf0b5..6d5396f 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -1074,6 +1074,7 @@ struct xen_domctl_psr_alloc {
 #define XEN_DOMCTL_PSR_GET_L3_DATA    5
 #define XEN_DOMCTL_PSR_SET_L2_CBM     6
 #define XEN_DOMCTL_PSR_GET_L2_CBM     7
+#define XEN_DOMCTL_PSR_SET_MBA_THRTL  8
 #define XEN_DOMCTL_PSR_GET_MBA_THRTL  9
     uint32_t cmd;       /* IN: XEN_DOMCTL_PSR_* */
     uint32_t target;    /* IN */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 04/11] tools: create general interfaces to support psr allocation features
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (2 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 03/11] x86: implement set value flow " Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 05/11] tools: implement the new libxc get hw info interface Yi Sun
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Chao Peng, Yi Sun, Ian Jackson, Roger Pau Monné

This patch creates general interfaces in libxl to support all psr
allocation features.

Add 'LIBXL_HAVE_PSR_GENERIC' to indicate interface change.

Please note, the functionality cannot work until later patches
are applied.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v5:
    - adjust parameters position in 'libxl_psr_get_hw_info'.
      (suggested by Roger Pau Monné)
v4:
    - add description for LIBXL_HAVE_PSR_GENERIC to mention newly added
      public functions.
      (suggested by Roger Pau Monné)
v3:
    - change 'LIBXL_HAVE_PSR_MBA' to 'LIBXL_HAVE_PSR_GENERIC'.
      (suggested by Roger Pau Monné)
    - 'typedef enum libxl_psr_cbm_type libxl_psr_type;' in libxl.h.
      (suggested by Roger Pau Monné and Wei Liu)
    - change 'libxl_psr_cbm_type' to 'libxl_psr_type' in newly defined
      interfaces.
      (suggested by Roger Pau Monné)
v2:
    - remove '_INFO' in 'libxl_psr_feat_type' and make corresponding
      changes in 'libxl_psr_hw_info'.
      (suggested by Chao Peng)
---
 tools/libxl/libxl.h         | 37 +++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_psr.c     | 25 +++++++++++++++++++++++++
 tools/libxl/libxl_types.idl | 22 ++++++++++++++++++++++
 3 files changed, 84 insertions(+)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 5e9aed7..da8af81 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -982,6 +982,17 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);
 #define LIBXL_HAVE_PSR_L2_CAT 1
 
 /*
+ * LIBXL_HAVE_PSR_GENERIC
+ *
+ * If this is defined, the Memory Bandwidth Allocation feature is supported.
+ * The following public functions are available:
+ *   libxl_psr_{set/get}_val
+ *   libxl_psr_get_hw_info
+ *   libxl_psr_hw_info_list_free
+ */
+#define LIBXL_HAVE_PSR_GENERIC 1
+
+/*
  * LIBXL_HAVE_MCA_CAPS
  *
  * If this is defined, setting MCA capabilities for HVM domain is supported.
@@ -2302,6 +2313,32 @@ int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
 int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
                               int *nr);
 void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr);
+
+typedef enum libxl_psr_cbm_type libxl_psr_type;
+
+/*
+ * Function to set a domain's value. It operates on a single or multiple
+ * target(s) defined in 'target_map'. 'target_map' specifies all the sockets
+ * to be operated on.
+ */
+int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
+                      libxl_psr_type type, libxl_bitmap *target_map,
+                      uint64_t val);
+/*
+ * Function to get a domain's cbm. It operates on a single 'target'.
+ * 'target' specifies which socket to be operated on.
+ */
+int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
+                      libxl_psr_type type, unsigned int target,
+                      uint64_t *val);
+/*
+ * On success, the function returns an array of elements in 'info',
+ * and the length in 'nr'.
+ */
+int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_feat_type type,
+                          unsigned int lvl, unsigned int *nr,
+                          libxl_psr_hw_info **info);
+void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr);
 #endif
 
 /* misc */
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 197505a..d4f5f67 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -428,6 +428,31 @@ void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr)
     free(list);
 }
 
+int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
+                      libxl_psr_type type, libxl_bitmap *target_map,
+                      uint64_t val)
+{
+    return ERROR_FAIL;
+}
+
+int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
+                      libxl_psr_type type, unsigned int target,
+                      uint64_t *val)
+{
+    return ERROR_FAIL;
+}
+
+int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_feat_type type,
+                          unsigned int lvl, unsigned int *nr,
+                          libxl_psr_hw_info **info)
+{
+    return ERROR_FAIL;
+}
+
+void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr)
+{
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index a239324..ff75a8f 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -1033,6 +1033,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
     (2, "L3_CBM_CODE"),
     (3, "L3_CBM_DATA"),
     (4, "L2_CBM"),
+    (5, "MBA_THRTL"),
     ])
 
 libxl_psr_cat_info = Struct("psr_cat_info", [
@@ -1041,3 +1042,24 @@ libxl_psr_cat_info = Struct("psr_cat_info", [
     ("cbm_len", uint32),
     ("cdp_enabled", bool),
     ])
+
+libxl_psr_feat_type = Enumeration("psr_feat_type", [
+    (1, "CAT"),
+    (2, "MBA"),
+    ])
+
+libxl_psr_hw_info = Struct("psr_hw_info", [
+    ("id", uint32),
+    ("u", KeyedUnion(None, libxl_psr_feat_type, "type",
+          [("cat", Struct(None, [
+                                    ("cos_max",     uint32),
+                                    ("cbm_len",     uint32),
+                                    ("cdp_enabled", bool),
+                               ])),
+           ("mba", Struct(None, [
+                                    ("cos_max",     uint32),
+                                    ("thrtl_max",   uint32),
+                                    ("linear",      bool),
+                               ])),
+          ]))
+    ], dir=DIR_OUT)
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 05/11] tools: implement the new libxc get hw info interface
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (3 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 04/11] tools: create general interfaces to support psr allocation features Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 06/11] tools: implement the new libxl " Yi Sun
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Chao Peng, Yi Sun, Ian Jackson, Roger Pau Monné

This patch implements a new libxc get hw info interface and corresponding
data structures. It also changes libxl_psr.c to call this new interface.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v6:
    - remove unnecessary spaces in brackets.
      (suggested by Wei Liu)
    - use assert to check input lvl.
      (suggested by Roger Pau Monné)
v5:
    - directly define 'xc_psr_hw_info' as union type.
      (suggested by Roger Pau Monné)
    - converge L2 and L3 cases in 'xc_psr_get_hw_info'.
      (suggested by Roger Pau Monné)
v4:
    - remove 'ALLOC_' from macro names.
      (suggested by Roger Pau Monné)
    - remove 'XC_PSR_FEAT_UNKNOWN' which is not necessary.
      (suggested by Roger Pau Monné)
    - remove 'FEAT_' from enum item names.
      (suggested by Roger Pau Monné)
    - remove 'xc_' from struct name.
      (suggested by Roger Pau Monné)
    - adjust codes to reduce indentation.
      (suggested by Roger Pau Monné)
    - assert for not happened case.
      (suggested by Roger Pau Monné)
    - add LOGE to show errno.
      (suggested by Roger Pau Monné)
v3:
    - rename 'psr_cat/PSR_CAT' to 'psr_alloc/PSR_ALLOC' and remove 'op/OP'
      from name.
      (suggested by Roger Pau Monné)
    - remove 'info' from 'xc_cat_info' and 'xc_mba_info'.
      (suggested by Roger Pau Monné)
    - set errno in 'xc_psr_get_hw_info'.
      (suggested by Roger Pau Monné)
    - remove 'inline'.
      (suggested by Roger Pau Monné)
    - remove 'psr' from 'libxl__psr_feat_type_to_libxc_psr_feat_type' to make
      function name shorter.
      (suggested by Roger Pau Monné)
    - check 'xc_type' in 'libxl_psr_cat_get_info'.
      (suggested by Roger Pau Monné)
v2:
    - split this patch out from a big patch in v1.
      (suggested by Wei Liu)
    - change 'CAT_INFO' and 'MBA_INFO' to 'CAT' and 'MBA'.
      (suggested by Chao Peng)
---
 tools/libxc/include/xenctrl.h | 27 ++++++++++++++++++---
 tools/libxc/xc_psr.c          | 55 +++++++++++++++++++++++++++----------------
 tools/libxl/libxl_psr.c       | 38 ++++++++++++++++++++++++++++--
 3 files changed, 95 insertions(+), 25 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 666db0b..9fc3348 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2494,6 +2494,28 @@ enum xc_psr_cat_type {
 };
 typedef enum xc_psr_cat_type xc_psr_cat_type;
 
+enum xc_psr_feat_type {
+    XC_PSR_CAT_L3,
+    XC_PSR_CAT_L2,
+    XC_PSR_MBA,
+};
+typedef enum xc_psr_feat_type xc_psr_feat_type;
+
+union xc_psr_hw_info {
+    struct {
+        uint32_t cos_max;
+        uint32_t cbm_len;
+        bool     cdp_enabled;
+    } cat;
+
+    struct {
+        uint32_t cos_max;
+        uint32_t thrtl_max;
+        bool     linear;
+    } mba;
+};
+typedef union xc_psr_hw_info xc_psr_hw_info;
+
 int xc_psr_cmt_attach(xc_interface *xch, uint32_t domid);
 int xc_psr_cmt_detach(xc_interface *xch, uint32_t domid);
 int xc_psr_cmt_get_domain_rmid(xc_interface *xch, uint32_t domid,
@@ -2515,9 +2537,8 @@ 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_info(xc_interface *xch, uint32_t socket, unsigned int lvl,
-                        uint32_t *cos_max, uint32_t *cbm_len,
-                        bool *cdp_enabled);
+int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
+                       xc_psr_feat_type type, xc_psr_hw_info *hw_info);
 
 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
 int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index 78deba0..2335842 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -323,37 +323,52 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
     return rc;
 }
 
-int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, unsigned int lvl,
-                        uint32_t *cos_max, uint32_t *cbm_len, bool *cdp_enabled)
+int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
+                       xc_psr_feat_type type, xc_psr_hw_info *hw_info)
 {
     int rc = -1;
     DECLARE_SYSCTL;
 
+    if ( !hw_info )
+    {
+        errno = EINVAL;
+        return rc;
+    }
+
     sysctl.cmd = XEN_SYSCTL_psr_alloc;
     sysctl.u.psr_alloc.target = socket;
 
-    switch ( lvl )
+    switch ( type )
     {
-    case 2:
-        sysctl.u.psr_alloc.cmd = XEN_SYSCTL_PSR_get_l2_info;
+    case XC_PSR_CAT_L2:
+    case XC_PSR_CAT_L3:
+        sysctl.u.psr_alloc.cmd = (type == XC_PSR_CAT_L2) ?
+                                 XEN_SYSCTL_PSR_get_l2_info :
+                                 XEN_SYSCTL_PSR_get_l3_info;
+
         rc = xc_sysctl(xch, &sysctl);
-        if ( !rc )
-        {
-            *cos_max = sysctl.u.psr_alloc.u.cat_info.cos_max;
-            *cbm_len = sysctl.u.psr_alloc.u.cat_info.cbm_len;
-            *cdp_enabled = false;
-        }
+        if ( rc )
+            break;
+
+        hw_info->cat.cos_max = sysctl.u.psr_alloc.u.cat_info.cos_max;
+        hw_info->cat.cbm_len = sysctl.u.psr_alloc.u.cat_info.cbm_len;
+        hw_info->cat.cdp_enabled = (type == XC_PSR_CAT_L2) ?
+                                   false :
+                                   (sysctl.u.psr_alloc.u.cat_info.flags &
+                                    XEN_SYSCTL_PSR_CAT_L3_CDP);
+
         break;
-    case 3:
-        sysctl.u.psr_alloc.cmd = XEN_SYSCTL_PSR_get_l3_info;
+    case XC_PSR_MBA:
+        sysctl.u.psr_alloc.cmd = XEN_SYSCTL_PSR_get_mba_info;
         rc = xc_sysctl(xch, &sysctl);
-        if ( !rc )
-        {
-            *cos_max = sysctl.u.psr_alloc.u.cat_info.cos_max;
-            *cbm_len = sysctl.u.psr_alloc.u.cat_info.cbm_len;
-            *cdp_enabled = sysctl.u.psr_alloc.u.cat_info.flags &
-                           XEN_SYSCTL_PSR_CAT_L3_CDP;
-        }
+        if ( rc )
+            break;
+
+        hw_info->mba.cos_max = sysctl.u.psr_alloc.u.mba_info.cos_max;
+        hw_info->mba.thrtl_max = sysctl.u.psr_alloc.u.mba_info.thrtl_max;
+        hw_info->mba.linear = sysctl.u.psr_alloc.u.mba_info.flags &
+                              XEN_SYSCTL_PSR_MBA_LINEAR;
+
         break;
     default:
         errno = EOPNOTSUPP;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index d4f5f67..e1cc250 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -361,6 +361,31 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
     return rc;
 }
 
+static xc_psr_feat_type libxl__feat_type_to_libxc_feat_type(
+                            libxl_psr_feat_type type, unsigned int lvl)
+{
+    xc_psr_feat_type xc_type;
+
+    switch (type) {
+    case LIBXL_PSR_FEAT_TYPE_CAT:
+        assert(lvl == 3 || lvl == 2);
+
+        if (lvl == 3)
+            xc_type = XC_PSR_CAT_L3;
+        if (lvl == 2)
+            xc_type = XC_PSR_CAT_L2;
+        break;
+    case LIBXL_PSR_FEAT_TYPE_MBA:
+        xc_type = XC_PSR_MBA;
+        break;
+    default:
+        /* Could not happen */
+        assert(0);
+    }
+
+    return xc_type;
+}
+
 int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
                            unsigned int *nr, unsigned int lvl)
 {
@@ -369,6 +394,8 @@ int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
     int i = 0, socketid, nr_sockets;
     libxl_bitmap socketmap;
     libxl_psr_cat_info *ptr;
+    xc_psr_hw_info hw_info;
+    xc_psr_feat_type xc_type;
 
     libxl_bitmap_init(&socketmap);
 
@@ -385,16 +412,23 @@ int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
         goto out;
     }
 
+    xc_type = libxl__feat_type_to_libxc_feat_type(LIBXL_PSR_FEAT_TYPE_CAT, lvl);
+
     ptr = libxl__malloc(NOGC, nr_sockets * sizeof(libxl_psr_cat_info));
 
     libxl_for_each_set_bit(socketid, socketmap) {
         ptr[i].id = socketid;
-        if (xc_psr_cat_get_info(ctx->xch, socketid, lvl, &ptr[i].cos_max,
-                                &ptr[i].cbm_len, &ptr[i].cdp_enabled)) {
+        if (xc_psr_get_hw_info(ctx->xch, socketid, xc_type, &hw_info)) {
+            LOGE(ERROR, "failed to get hw info");
             rc = ERROR_FAIL;
             free(ptr);
             goto out;
         }
+
+        ptr[i].cos_max = hw_info.cat.cos_max;
+        ptr[i].cbm_len = hw_info.cat.cbm_len;
+        ptr[i].cdp_enabled = hw_info.cat.cdp_enabled;
+
         i++;
     }
 
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 06/11] tools: implement the new libxl get hw info interface
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (4 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 05/11] tools: implement the new libxc get hw info interface Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 07/11] tools: implement the new xl " Yi Sun
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Chao Peng, Yi Sun, Ian Jackson, Roger Pau Monné

This patch implements the new libxl get hw info interface,
'libxl_psr_get_hw_info', which is suitable to all psr allocation
features. It also implements corresponding list free function,
'libxl_psr_hw_info_list_free' and makes 'libxl_psr_cat_get_info' call
'libxl_psr_get_hw_info' to avoid redundant code in libxl_psr.c.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v5:
    - change 'if (rc < 0)' to 'if (rc)'.
      (suggested by Roger Pau Monné)
v4:
    - remove 'xc_' from struct name.
      (suggested by Roger Pau Monné)
    - fix words in commit message.
      (suggested by Roger Pau Monné)
    - change type of 'libxl__hw_info_to_libxl_cat_info' to void and use
      assert to check invalid type. Then, remove check for
      'libxl__hw_info_to_libxl_cat_info'.
      (suggested by Roger Pau Monné)
    - change type of 'libxl__xc_hw_info_to_libxl_hw_info' to void and use
      assert to check invalid type. Then, remove check for
      'libxl__xc_hw_info_to_libxl_hw_info'.
      (suggested by Roger Pau Monné)
v3:
    - remove casting.
      (suggested by Roger Pau Monné)
    - remove inline.
      (suggested by Roger Pau Monné)
    - change 'libxc__psr_hw_info_to_libxl_psr_hw_info' to
      'libxl__xc_hw_info_to_libxl_hw_info'.
      (suggested by Roger Pau Monné)
    - remove '_hw' from parameter names.
      (suggested by Roger Pau Monné)
    - change some 'LOGE' to 'LOG'.
      (suggested by Roger Pau Monné)
    - check returned 'xc_type' and remove redundant 'lvl' check.
      (suggested by Roger Pau Monné)
v2:
    - split this patch out from a big patch in v1.
      (suggested by Wei Liu)
    - change 'CAT_INFO'/'MBA_INFO' to 'CAT' and 'MBA. Also the libxl structure
      name 'cat_info'/'mba_info' is changed to 'cat'/'mba'.
      (suggested by Chao Peng)
    - call 'libxl_psr_hw_info_list_free' in 'libxl_psr_cat_get_info' to free
      allocated resources.
      (suggested by Chao Peng)
---
 tools/libxl/libxl_psr.c | 131 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 93 insertions(+), 38 deletions(-)

diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index e1cc250..b053abd 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -386,56 +386,41 @@ static xc_psr_feat_type libxl__feat_type_to_libxc_feat_type(
     return xc_type;
 }
 
+static void libxl__hw_info_to_libxl_cat_info(
+                libxl_psr_feat_type type, libxl_psr_hw_info *hw_info,
+                libxl_psr_cat_info *cat_info)
+{
+    assert(type == LIBXL_PSR_FEAT_TYPE_CAT);
+
+    cat_info->id = hw_info->id;
+    cat_info->cos_max = hw_info->u.cat.cos_max;
+    cat_info->cbm_len = hw_info->u.cat.cbm_len;
+    cat_info->cdp_enabled = hw_info->u.cat.cdp_enabled;
+}
+
 int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
                            unsigned int *nr, unsigned int lvl)
 {
     GC_INIT(ctx);
     int rc;
-    int i = 0, socketid, nr_sockets;
-    libxl_bitmap socketmap;
+    unsigned int i;
+    libxl_psr_hw_info *hw_info;
     libxl_psr_cat_info *ptr;
-    xc_psr_hw_info hw_info;
-    xc_psr_feat_type xc_type;
-
-    libxl_bitmap_init(&socketmap);
-
-    rc = libxl__count_physical_sockets(gc, &nr_sockets);
-    if (rc) {
-        LOGE(ERROR, "failed to get system socket count");
-        goto out;
-    }
 
-    libxl_socket_bitmap_alloc(ctx, &socketmap, nr_sockets);
-    rc = libxl_get_online_socketmap(ctx, &socketmap);
-    if (rc < 0) {
-        LOGE(ERROR, "failed to get available sockets");
+    rc = libxl_psr_get_hw_info(ctx, LIBXL_PSR_FEAT_TYPE_CAT, lvl, nr, &hw_info);
+    if (rc)
         goto out;
-    }
-
-    xc_type = libxl__feat_type_to_libxc_feat_type(LIBXL_PSR_FEAT_TYPE_CAT, lvl);
-
-    ptr = libxl__malloc(NOGC, nr_sockets * sizeof(libxl_psr_cat_info));
-
-    libxl_for_each_set_bit(socketid, socketmap) {
-        ptr[i].id = socketid;
-        if (xc_psr_get_hw_info(ctx->xch, socketid, xc_type, &hw_info)) {
-            LOGE(ERROR, "failed to get hw info");
-            rc = ERROR_FAIL;
-            free(ptr);
-            goto out;
-        }
 
-        ptr[i].cos_max = hw_info.cat.cos_max;
-        ptr[i].cbm_len = hw_info.cat.cbm_len;
-        ptr[i].cdp_enabled = hw_info.cat.cdp_enabled;
+    ptr = libxl__malloc(NOGC, *nr * sizeof(libxl_psr_cat_info));
 
-        i++;
-    }
+    for (i = 0; i < *nr; i++)
+        libxl__hw_info_to_libxl_cat_info(LIBXL_PSR_FEAT_TYPE_CAT,
+                                         &hw_info[i],
+                                         &ptr[i]);
 
     *info = ptr;
-    *nr = i;
+    libxl_psr_hw_info_list_free(hw_info, *nr);
 out:
-    libxl_bitmap_dispose(&socketmap);
     GC_FREE;
     return rc;
 }
@@ -476,15 +461,85 @@ int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
     return ERROR_FAIL;
 }
 
+static void libxl__xc_hw_info_to_libxl_hw_info(
+                libxl_psr_feat_type type, xc_psr_hw_info *xc_info,
+                libxl_psr_hw_info *xl_info)
+{
+    switch (type) {
+    case LIBXL_PSR_FEAT_TYPE_CAT:
+        xl_info->u.cat.cos_max = xc_info->cat.cos_max;
+        xl_info->u.cat.cbm_len = xc_info->cat.cbm_len;
+        xl_info->u.cat.cdp_enabled = xc_info->cat.cdp_enabled;
+        break;
+    case LIBXL_PSR_FEAT_TYPE_MBA:
+        xl_info->u.mba.cos_max = xc_info->mba.cos_max;
+        xl_info->u.mba.thrtl_max = xc_info->mba.thrtl_max;
+        xl_info->u.mba.linear = xc_info->mba.linear;
+        break;
+    default:
+        assert(0);
+    }
+}
+
 int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_feat_type type,
                           unsigned int lvl, unsigned int *nr,
                           libxl_psr_hw_info **info)
 {
-    return ERROR_FAIL;
+    GC_INIT(ctx);
+    int rc, nr_sockets;
+    unsigned int i = 0, socketid;
+    libxl_bitmap socketmap;
+    libxl_psr_hw_info *ptr;
+    xc_psr_feat_type xc_type;
+    xc_psr_hw_info hw_info;
+
+    libxl_bitmap_init(&socketmap);
+
+    xc_type = libxl__feat_type_to_libxc_feat_type(type, lvl);
+
+    rc = libxl__count_physical_sockets(gc, &nr_sockets);
+    if (rc) {
+        LOG(ERROR, "failed to get system socket count");
+        goto out;
+    }
+
+    libxl_socket_bitmap_alloc(ctx, &socketmap, nr_sockets);
+    rc = libxl_get_online_socketmap(ctx, &socketmap);
+    if (rc) {
+        LOGE(ERROR, "failed to get available sockets");
+        goto out;
+    }
+
+    ptr = libxl__malloc(NOGC, nr_sockets * sizeof(libxl_psr_hw_info));
+
+    libxl_for_each_set_bit(socketid, socketmap) {
+        ptr[i].id = socketid;
+        if (xc_psr_get_hw_info(ctx->xch, socketid, xc_type, &hw_info)) {
+            rc = ERROR_FAIL;
+            free(ptr);
+            goto out;
+        }
+
+        libxl__xc_hw_info_to_libxl_hw_info(type, &hw_info, &ptr[i]);
+
+        i++;
+    }
+
+    *info = ptr;
+    *nr = i;
+out:
+    libxl_bitmap_dispose(&socketmap);
+    GC_FREE;
+    return rc;
 }
 
 void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr)
 {
+    unsigned int i;
+
+    for (i = 0; i < nr; i++)
+        libxl_psr_hw_info_dispose(&list[i]);
+    free(list);
 }
 
 /*
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 07/11] tools: implement the new xl get hw info interface
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (5 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 06/11] tools: implement the new libxl " Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 08/11] tools: rename 'xc_psr_cat_type' to 'xc_psr_type' Yi Sun
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Chao Peng, Yi Sun, Ian Jackson, Roger Pau Monné

This patch implements a new xl get HW info interface. A new argument
is added for psr-hwinfo command to get and show MBA HW info.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v3:
    - change the format string of printf in 'psr_mba_hwinfo'.
      (suggested by Roger Pau Monné)
    - add 'const' for 'opts[]' in 'main_psr_hwinfo'.
      (suggested by Roger Pau Monné)
v2:
    - split out this patch from a big patch in v1.
      (suggested by Wei Liu)
    - change 'MBA_INFO' to 'MBA'. Also, change 'mba_info' to 'mba'.
      (suggested by Chao Peng)
---
 tools/xl/xl_cmdtable.c |  1 +
 tools/xl/xl_psr.c      | 39 ++++++++++++++++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 5546cf6..249eb92 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -550,6 +550,7 @@ struct cmd_spec cmd_table[] = {
       "[options]",
       "-m, --cmt       Show Cache Monitoring Technology (CMT) hardware info\n"
       "-a, --cat       Show Cache Allocation Technology (CAT) hardware info\n"
+      "-b, --mba       Show Memory Bandwidth Allocation (MBA) hardware info\n"
     },
     { "psr-cmt-attach",
       &main_psr_cmt_attach, 0, 1,
diff --git a/tools/xl/xl_psr.c b/tools/xl/xl_psr.c
index ef00048..ab47d96 100644
--- a/tools/xl/xl_psr.c
+++ b/tools/xl/xl_psr.c
@@ -475,6 +475,31 @@ static int psr_l2_cat_hwinfo(void)
     return rc;
 }
 
+static int psr_mba_hwinfo(void)
+{
+    int rc;
+    unsigned int i, nr;
+    libxl_psr_hw_info *info;
+
+    rc = libxl_psr_get_hw_info(ctx, LIBXL_PSR_FEAT_TYPE_MBA, 0, &nr, &info);
+    if (rc)
+        return rc;
+
+    printf("Memory Bandwidth Allocation (MBA):\n");
+
+    for (i = 0; i < nr; i++) {
+        printf("Socket ID               : %u\n", info[i].id);
+        printf("Linear Mode             : %s\n",
+               info[i].u.mba.linear ? "Enabled" : "Disabled");
+        printf("Maximum COS             : %u\n", info[i].u.mba.cos_max);
+        printf("Maximum Throttling Value: %u\n", info[i].u.mba.thrtl_max);
+        printf("Default Throttling Value: %u\n", 0);
+    }
+
+    libxl_psr_hw_info_list_free(info, nr);
+    return rc;
+}
+
 int main_psr_cat_cbm_set(int argc, char **argv)
 {
     uint32_t domid;
@@ -593,20 +618,24 @@ int main_psr_cat_show(int argc, char **argv)
 int main_psr_hwinfo(int argc, char **argv)
 {
     int opt, ret = 0;
-    bool all = true, cmt = false, cat = false;
-    static struct option opts[] = {
+    bool all = true, cmt = false, cat = false, mba = false;
+    static const struct option opts[] = {
         {"cmt", 0, 0, 'm'},
         {"cat", 0, 0, 'a'},
+        {"mba", 0, 0, 'b'},
         COMMON_LONG_OPTS
     };
 
-    SWITCH_FOREACH_OPT(opt, "ma", opts, "psr-hwinfo", 0) {
+    SWITCH_FOREACH_OPT(opt, "mab", opts, "psr-hwinfo", 0) {
     case 'm':
         all = false; cmt = true;
         break;
     case 'a':
         all = false; cat = true;
         break;
+    case 'b':
+        all = false; mba = true;
+        break;
     }
 
     if (!ret && (all || cmt))
@@ -619,6 +648,10 @@ int main_psr_hwinfo(int argc, char **argv)
     if (all || cat)
         ret = psr_l2_cat_hwinfo();
 
+    /* MBA is independent of CMT and CAT */
+    if (all || mba)
+        ret = psr_mba_hwinfo();
+
     return ret;
 }
 
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 08/11] tools: rename 'xc_psr_cat_type' to 'xc_psr_type'
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (6 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 07/11] tools: implement the new xl " Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 09/11] tools: implement new generic get value interface and MBA get value command Yi Sun
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Chao Peng, Yi Sun, Wei Liu, Roger Pau Monné

This patch renames 'xc_psr_cat_type' to 'xc_psr_type' so that
the structure name is common for all allocation features.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Chao Peng <chao.p.peng@linux.intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v5:
    - remove a duplicated ';'.
      (suggested by Roger Pau Monné)
v4:
    - move assignment of xc_type to its declaration place.
      (suggested by Roger Pau Monné)
v3:
    - change 'xc_psr_val_type' to 'xc_psr_type'.
      (suggested by Roger Pau Monné)
---
 tools/libxc/include/xenctrl.h |  8 ++++----
 tools/libxc/xc_psr.c          |  4 ++--
 tools/libxl/libxl_psr.c       | 11 +++++------
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 9fc3348..8451f6d 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2486,13 +2486,13 @@ enum xc_psr_cmt_type {
 };
 typedef enum xc_psr_cmt_type xc_psr_cmt_type;
 
-enum xc_psr_cat_type {
+enum xc_psr_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;
+typedef enum xc_psr_type xc_psr_type;
 
 enum xc_psr_feat_type {
     XC_PSR_CAT_L3,
@@ -2532,10 +2532,10 @@ int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid, uint32_t cpu,
 int xc_psr_cmt_enabled(xc_interface *xch);
 
 int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-                               xc_psr_cat_type type, uint32_t target,
+                               xc_psr_type type, uint32_t target,
                                uint64_t data);
 int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-                               xc_psr_cat_type type, uint32_t target,
+                               xc_psr_type type, uint32_t target,
                                uint64_t *data);
 int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
                        xc_psr_feat_type type, xc_psr_hw_info *hw_info);
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index 2335842..aa07fe0 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -249,7 +249,7 @@ int xc_psr_cmt_enabled(xc_interface *xch)
     return 0;
 }
 int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-                               xc_psr_cat_type type, uint32_t target,
+                               xc_psr_type type, uint32_t target,
                                uint64_t data)
 {
     DECLARE_DOMCTL;
@@ -284,7 +284,7 @@ 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,
+                               xc_psr_type type, uint32_t target,
                                uint64_t *data)
 {
     int rc;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index b053abd..c54cb6f 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -303,11 +303,11 @@ out:
     return rc;
 }
 
-static inline xc_psr_cat_type libxl__psr_cbm_type_to_libxc_psr_cat_type(
+static inline xc_psr_type libxl__psr_cbm_type_to_libxc_psr_type(
     libxl_psr_cbm_type type)
 {
-    BUILD_BUG_ON(sizeof(libxl_psr_cbm_type) != sizeof(xc_psr_cat_type));
-    return (xc_psr_cat_type)type;
+    BUILD_BUG_ON(sizeof(libxl_psr_cbm_type) != sizeof(xc_psr_type));
+    return (xc_psr_type)type;
 }
 
 int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
@@ -325,12 +325,11 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
     }
 
     libxl_for_each_set_bit(socketid, *target_map) {
-        xc_psr_cat_type xc_type;
+        xc_psr_type xc_type = libxl__psr_cbm_type_to_libxc_psr_type(type);
 
         if (socketid >= nr_sockets)
             break;
 
-        xc_type = libxl__psr_cbm_type_to_libxc_psr_cat_type(type);
         if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
                                        socketid, cbm)) {
             libxl__psr_cat_log_err_msg(gc, errno);
@@ -349,7 +348,7 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
 {
     GC_INIT(ctx);
     int rc = 0;
-    xc_psr_cat_type xc_type = libxl__psr_cbm_type_to_libxc_psr_cat_type(type);
+    xc_psr_type xc_type = libxl__psr_cbm_type_to_libxc_psr_type(type);
 
     if (xc_psr_cat_get_domain_data(ctx->xch, domid, xc_type,
                                    target, cbm_r)) {
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 09/11] tools: implement new generic get value interface and MBA get value command
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (7 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 08/11] tools: rename 'xc_psr_cat_type' to 'xc_psr_type' Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-19  0:42 ` [PATCH v10 10/11] tools: implement new generic set value interface and MBA set " Yi Sun
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Chao Peng, Yi Sun, Wei Liu, Roger Pau Monné

This patch implements generic get value interfaces in libxc and libxl.
It also refactors the get value flow in xl to make it be suitable for all
allocation features. Based on that, a new MBA get value command is added in xl.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v6:
    - fix one coding style issue.
      (suggested by Roger Pau Monné)
v5:
    - start a newline for "CDP" because it exceeds 80 characters.
      (suggested by Roger Pau Monné)
    - remove a duplicated ';'.
      (suggested by Roger Pau Monné)
    - remove a extra newline.
      (suggested by Roger Pau Monné)
    - correct words in log message.
      (suggested by Roger Pau Monné)
v4:
    - use designated initializers for 'feat_name[]'.
      (suggested by Roger Pau Monné)
    - use LOG in 'libxl__psr_alloc_log_err_msg'.
      (suggested by Roger Pau Monné)
v3:
    - replace 'libxl_psr_cbm_type' to 'libxl_psr_type' in newly defined
      interfaces.
      (suggested by Roger Pau Monné)
v2:
    - change 'CAT_INFO'/'MBA_INFO' to 'CAT'/'MBA'. The related structure names
      are changed too.
      (suggested by Chao Peng)
---
 tools/libxc/include/xenctrl.h |   7 +-
 tools/libxc/xc_psr.c          |   9 +-
 tools/libxl/libxl_psr.c       |  58 ++++++++-----
 tools/xl/xl.h                 |   1 +
 tools/xl/xl_cmdtable.c        |   5 ++
 tools/xl/xl_psr.c             | 185 ++++++++++++++++++++++++++++++------------
 6 files changed, 183 insertions(+), 82 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 8451f6d..fc0d4d2 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2491,6 +2491,7 @@ enum xc_psr_type {
     XC_PSR_CAT_L3_CBM_CODE = 2,
     XC_PSR_CAT_L3_CBM_DATA = 3,
     XC_PSR_CAT_L2_CBM      = 4,
+    XC_PSR_MBA_THRTL       = 5,
 };
 typedef enum xc_psr_type xc_psr_type;
 
@@ -2534,9 +2535,9 @@ int xc_psr_cmt_enabled(xc_interface *xch);
 int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
                                xc_psr_type type, uint32_t target,
                                uint64_t data);
-int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-                               xc_psr_type type, uint32_t target,
-                               uint64_t *data);
+int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
+                           xc_psr_type type, uint32_t target,
+                           uint64_t *data);
 int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
                        xc_psr_feat_type type, xc_psr_hw_info *hw_info);
 
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index aa07fe0..37a6feb 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -283,9 +283,9 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
     return do_domctl(xch, &domctl);
 }
 
-int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-                               xc_psr_type type, uint32_t target,
-                               uint64_t *data)
+int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
+                           xc_psr_type type, uint32_t target,
+                           uint64_t *data)
 {
     int rc;
     DECLARE_DOMCTL;
@@ -305,6 +305,9 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
     case XC_PSR_CAT_L2_CBM:
         cmd = XEN_DOMCTL_PSR_GET_L2_CBM;
         break;
+    case XC_PSR_MBA_THRTL:
+        cmd = XEN_DOMCTL_PSR_GET_MBA_THRTL;
+        break;
     default:
         errno = EINVAL;
         return -1;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index c54cb6f..7c560bc 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -71,16 +71,30 @@ static void libxl__psr_cmt_log_err_msg(libxl__gc *gc, int err)
     LOGE(ERROR, "%s", msg);
 }
 
-static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
+static void libxl__psr_alloc_log_err_msg(libxl__gc *gc,
+                                         int err,
+                                         libxl_psr_type type)
 {
+    /*
+     * Index is 'libxl_psr_type' so we set two 'CDP' to correspond to
+     * DATA and CODE.
+     */
+    const char * const feat_name[] = {
+        [LIBXL_PSR_CBM_TYPE_UNKNOWN] = "UNKNOWN",
+        [LIBXL_PSR_CBM_TYPE_L3_CBM] = "L3 CAT",
+        [LIBXL_PSR_CBM_TYPE_L3_CBM_CODE...LIBXL_PSR_CBM_TYPE_L3_CBM_DATA] =
+                                      "CDP",
+        [LIBXL_PSR_CBM_TYPE_L2_CBM] = "L2 CAT",
+        [LIBXL_PSR_CBM_TYPE_MBA_THRTL] = "MBA",
+    };
     char *msg;
 
     switch (err) {
     case ENODEV:
-        msg = "CAT is not supported in this system";
+        msg = "is not supported in this system";
         break;
     case ENOENT:
-        msg = "CAT is not enabled on the socket";
+        msg = "is not enabled on the socket";
         break;
     case EOVERFLOW:
         msg = "no free COS available";
@@ -106,7 +120,7 @@ static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
         return;
     }
 
-    LOGE(ERROR, "%s", msg);
+    LOG(ERROR, "%s: %s", feat_name[type], msg);
 }
 
 static int libxl__pick_socket_cpu(libxl__gc *gc, uint32_t socketid)
@@ -303,10 +317,10 @@ out:
     return rc;
 }
 
-static inline xc_psr_type libxl__psr_cbm_type_to_libxc_psr_type(
-    libxl_psr_cbm_type type)
+static inline xc_psr_type libxl__psr_type_to_libxc_psr_type(
+    libxl_psr_type type)
 {
-    BUILD_BUG_ON(sizeof(libxl_psr_cbm_type) != sizeof(xc_psr_type));
+    BUILD_BUG_ON(sizeof(libxl_psr_type) != sizeof(xc_psr_type));
     return (xc_psr_type)type;
 }
 
@@ -325,14 +339,14 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
     }
 
     libxl_for_each_set_bit(socketid, *target_map) {
-        xc_psr_type xc_type = libxl__psr_cbm_type_to_libxc_psr_type(type);
+        xc_psr_type xc_type = libxl__psr_type_to_libxc_psr_type(type);
 
         if (socketid >= nr_sockets)
             break;
 
         if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
                                        socketid, cbm)) {
-            libxl__psr_cat_log_err_msg(gc, errno);
+            libxl__psr_alloc_log_err_msg(gc, errno, type);
             rc = ERROR_FAIL;
         }
     }
@@ -346,18 +360,7 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
                           libxl_psr_cbm_type type, uint32_t target,
                           uint64_t *cbm_r)
 {
-    GC_INIT(ctx);
-    int rc = 0;
-    xc_psr_type xc_type = libxl__psr_cbm_type_to_libxc_psr_type(type);
-
-    if (xc_psr_cat_get_domain_data(ctx->xch, domid, xc_type,
-                                   target, cbm_r)) {
-        libxl__psr_cat_log_err_msg(gc, errno);
-        rc = ERROR_FAIL;
-    }
-
-    GC_FREE;
-    return rc;
+    return libxl_psr_get_val(ctx, domid, type, target, cbm_r);
 }
 
 static xc_psr_feat_type libxl__feat_type_to_libxc_feat_type(
@@ -457,7 +460,18 @@ int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
                       libxl_psr_type type, unsigned int target,
                       uint64_t *val)
 {
-    return ERROR_FAIL;
+    GC_INIT(ctx);
+    int rc = 0;
+    xc_psr_type xc_type = libxl__psr_type_to_libxc_psr_type(type);
+
+    if (xc_psr_get_domain_data(ctx->xch, domid, xc_type,
+                               target, val)) {
+        libxl__psr_alloc_log_err_msg(gc, errno, type);
+        rc = ERROR_FAIL;
+    }
+
+    GC_FREE;
+    return rc;
 }
 
 static void libxl__xc_hw_info_to_libxl_hw_info(
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 6b60d1d..a72458b 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -208,6 +208,7 @@ int main_psr_cmt_detach(int argc, char **argv);
 int main_psr_cmt_show(int argc, char **argv);
 int main_psr_cat_cbm_set(int argc, char **argv);
 int main_psr_cat_show(int argc, char **argv);
+int main_psr_mba_show(int argc, char **argv);
 #endif
 int main_qemu_monitor_command(int argc, char **argv);
 
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 249eb92..fb9e918 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -586,6 +586,11 @@ struct cmd_spec cmd_table[] = {
       "[options] <Domain>",
       "-l <level>        Specify the cache level to process, otherwise L3 cache is processed\n"
     },
+    { "psr-mba-show",
+      &main_psr_mba_show, 0, 1,
+      "Show Memory Bandwidth Allocation information",
+      "<Domain>",
+    },
 #endif
     { "usbctrl-attach",
       &main_usbctrl_attach, 0, 1,
diff --git a/tools/xl/xl_psr.c b/tools/xl/xl_psr.c
index ab47d96..0eedbc7 100644
--- a/tools/xl/xl_psr.c
+++ b/tools/xl/xl_psr.c
@@ -327,19 +327,26 @@ out:
     return rc;
 }
 
-static void psr_cat_print_one_domain_cbm_type(uint32_t domid, uint32_t socketid,
-                                              libxl_psr_cbm_type type)
+static void psr_print_one_domain_val_type(uint32_t domid,
+                                          libxl_psr_hw_info *info,
+                                          libxl_psr_type type)
 {
-    uint64_t cbm;
+    uint64_t val;
 
-    if (!libxl_psr_cat_get_cbm(ctx, domid, type, socketid, &cbm))
-        printf("%#16"PRIx64, cbm);
+    if (!libxl_psr_get_val(ctx, domid, type, info->id, &val)) {
+        if (type == LIBXL_PSR_CBM_TYPE_MBA_THRTL && info->u.mba.linear)
+            printf("%16"PRIu64, val);
+        else
+            printf("%#16"PRIx64, val);
+    }
     else
         printf("%16s", "error");
 }
 
-static void psr_cat_print_one_domain_cbm(uint32_t domid, uint32_t socketid,
-                                         bool cdp_enabled, unsigned int lvl)
+static void psr_print_one_domain_val(uint32_t domid,
+                                     libxl_psr_hw_info *info,
+                                     libxl_psr_feat_type type,
+                                     unsigned int lvl)
 {
     char *domain_name;
 
@@ -347,106 +354,155 @@ static void psr_cat_print_one_domain_cbm(uint32_t domid, uint32_t socketid,
     printf("%5d%25s", domid, domain_name);
     free(domain_name);
 
-    switch (lvl) {
-    case 3:
-        if (!cdp_enabled) {
-            psr_cat_print_one_domain_cbm_type(domid, socketid,
+    switch (type) {
+    case LIBXL_PSR_FEAT_TYPE_CAT:
+        switch (lvl) {
+        case 3:
+            if (!info->u.cat.cdp_enabled) {
+                psr_print_one_domain_val_type(domid, info,
                                               LIBXL_PSR_CBM_TYPE_L3_CBM);
-        } else {
-            psr_cat_print_one_domain_cbm_type(domid, socketid,
+            } else {
+                psr_print_one_domain_val_type(domid, info,
                                               LIBXL_PSR_CBM_TYPE_L3_CBM_CODE);
-            psr_cat_print_one_domain_cbm_type(domid, socketid,
+                psr_print_one_domain_val_type(domid, info,
                                               LIBXL_PSR_CBM_TYPE_L3_CBM_DATA);
-        }
-        break;
-    case 2:
-        psr_cat_print_one_domain_cbm_type(domid, socketid,
+            }
+            break;
+
+        case 2:
+            psr_print_one_domain_val_type(domid, info,
                                           LIBXL_PSR_CBM_TYPE_L2_CBM);
+            break;
+
+        default:
+            printf("Input lvl %d is wrong!", lvl);
+        }
         break;
-    default:
-        printf("Input lvl %d is wrong!", lvl);
+
+    case LIBXL_PSR_FEAT_TYPE_MBA:
+        psr_print_one_domain_val_type(domid, info,
+                                      LIBXL_PSR_CBM_TYPE_MBA_THRTL);
         break;
     }
 
     printf("\n");
 }
 
-static int psr_cat_print_domain_cbm(uint32_t domid, uint32_t socketid,
-                                    bool cdp_enabled, unsigned int lvl)
+static int psr_print_domain_val(uint32_t domid,
+                                libxl_psr_hw_info *info,
+                                libxl_psr_feat_type type,
+                                unsigned int lvl)
 {
     int i, nr_domains;
     libxl_dominfo *list;
 
     if (domid != INVALID_DOMID) {
-        psr_cat_print_one_domain_cbm(domid, socketid, cdp_enabled, lvl);
+        psr_print_one_domain_val(domid, info, type, lvl);
         return 0;
     }
 
     if (!(list = libxl_list_domain(ctx, &nr_domains))) {
-        fprintf(stderr, "Failed to get domain list for cbm display\n");
-        return -1;
+        fprintf(stderr, "Failed to get domain list for value display\n");
+        return EXIT_FAILURE;
     }
 
     for (i = 0; i < nr_domains; i++)
-        psr_cat_print_one_domain_cbm(list[i].domid, socketid, cdp_enabled, lvl);
+        psr_print_one_domain_val(list[i].domid, info, type, lvl);
     libxl_dominfo_list_free(list, nr_domains);
 
     return 0;
 }
 
-static int psr_cat_print_socket(uint32_t domid, libxl_psr_cat_info *info,
-                                unsigned int lvl)
+static int psr_print_socket(uint32_t domid,
+                            libxl_psr_hw_info *info,
+                            libxl_psr_feat_type type,
+                            unsigned int lvl)
 {
-    int rc;
-    uint32_t l3_cache_size;
-
     printf("%-16s: %u\n", "Socket ID", info->id);
 
-    /* So far, CMT only supports L3 cache. */
-    if (lvl == 3) {
-        rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->id, &l3_cache_size);
-        if (rc) {
-            fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
-                    info->id);
-            return -1;
+    switch (type) {
+    case LIBXL_PSR_FEAT_TYPE_CAT:
+    {
+        int rc;
+        uint32_t l3_cache_size;
+
+        /* So far, CMT only supports L3 cache. */
+        if (lvl == 3) {
+            rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->id, &l3_cache_size);
+            if (rc) {
+                fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
+                        info->id);
+                return -1;
+            }
+            printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
         }
-        printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
+
+        printf("%-16s: %#llx\n", "Default CBM",
+               (1ull << info->u.cat.cbm_len) - 1);
+        if (info->u.cat.cdp_enabled)
+            printf("%5s%25s%16s%16s\n", "ID", "NAME", "CBM (code)", "CBM (data)");
+        else
+            printf("%5s%25s%16s\n", "ID", "NAME", "CBM");
+
+        break;
     }
 
-    printf("%-16s: %#llx\n", "Default CBM", (1ull << info->cbm_len) - 1);
-    if (info->cdp_enabled)
-        printf("%5s%25s%16s%16s\n", "ID", "NAME", "CBM (code)", "CBM (data)");
-    else
-        printf("%5s%25s%16s\n", "ID", "NAME", "CBM");
+    case LIBXL_PSR_FEAT_TYPE_MBA:
+        printf("%-16s: %u\n", "Default THRTL", 0);
+        printf("%5s%25s%16s\n", "ID", "NAME", "THRTL");
+        break;
 
-    return psr_cat_print_domain_cbm(domid, info->id, info->cdp_enabled, lvl);
+    default:
+        fprintf(stderr, "Input feature type %d is wrong\n", type);
+        return EXIT_FAILURE;
+    }
+
+    return psr_print_domain_val(domid, info, type, lvl);
 }
 
-static int psr_cat_show(uint32_t domid, unsigned int lvl)
+static int psr_val_show(uint32_t domid,
+                        libxl_psr_feat_type type,
+                        unsigned int lvl)
 {
     unsigned int i, nr;
     int rc;
-    libxl_psr_cat_info *info;
+    libxl_psr_hw_info *info;
 
-    if (lvl != 2 && lvl != 3) {
-        fprintf(stderr, "Input lvl %d is wrong\n", lvl);
+    switch (type) {
+    case LIBXL_PSR_FEAT_TYPE_CAT:
+        if (lvl != 2 && lvl != 3) {
+            fprintf(stderr, "Input lvl %d is wrong\n", lvl);
+            return EXIT_FAILURE;
+        }
+        break;
+
+    case LIBXL_PSR_FEAT_TYPE_MBA:
+        if (lvl) {
+            fprintf(stderr,
+                    "Unexpected lvl parameter %d for MBA feature\n", lvl);
+            return EXIT_FAILURE;
+        }
+        break;
+
+    default:
+        fprintf(stderr, "Input feature type %d is wrong\n", type);
         return EXIT_FAILURE;
     }
 
-    rc = libxl_psr_cat_get_info(ctx, &info, &nr, lvl);
+    rc = libxl_psr_get_hw_info(ctx, type, lvl, &nr, &info);
     if (rc) {
-        fprintf(stderr, "Failed to get %s cat info\n", (lvl == 3)?"L3":"L2");
+        fprintf(stderr, "Failed to get info\n");
         return rc;
     }
 
     for (i = 0; i < nr; i++) {
-        rc = psr_cat_print_socket(domid, info + i, lvl);
+        rc = psr_print_socket(domid, info + i, type, lvl);
         if (rc)
             goto out;
     }
 
 out:
-    libxl_psr_cat_info_list_free(info, nr);
+    libxl_psr_hw_info_list_free(info, nr);
     return rc;
 }
 
@@ -475,6 +531,27 @@ static int psr_l2_cat_hwinfo(void)
     return rc;
 }
 
+int main_psr_mba_show(int argc, char **argv)
+{
+    int opt;
+    uint32_t domid;
+
+    SWITCH_FOREACH_OPT(opt, "", NULL, "psr-mba-show", 0) {
+        /* No options */
+    }
+
+    if (optind >= argc)
+        domid = INVALID_DOMID;
+    else if (optind == argc - 1)
+        domid = find_domain(argv[optind]);
+    else {
+        help("psr-mba-show");
+        return 2;
+    }
+
+    return psr_val_show(domid, LIBXL_PSR_FEAT_TYPE_MBA, 0);
+}
+
 static int psr_mba_hwinfo(void)
 {
     int rc;
@@ -612,7 +689,7 @@ int main_psr_cat_show(int argc, char **argv)
         return 2;
     }
 
-    return psr_cat_show(domid, lvl);
+    return psr_val_show(domid, LIBXL_PSR_FEAT_TYPE_CAT, lvl);
 }
 
 int main_psr_hwinfo(int argc, char **argv)
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 10/11] tools: implement new generic set value interface and MBA set value command
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (8 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 09/11] tools: implement new generic get value interface and MBA get value command Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2018-01-08 12:23   ` Wei Liu
  2017-12-19  0:42 ` [PATCH v10 11/11] docs: add MBA description in docs Yi Sun
  2017-12-20  9:11 ` [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Jan Beulich
  11 siblings, 1 reply; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Chao Peng, Yi Sun, Ian Jackson, Roger Pau Monné

This patch implements new generic set value interfaces in libxc and libxl.
These interfaces are suitable for all allocation features. It also adds a
new MBA set value command in xl.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v10:
    - move argc check to original place to make per socket setting work.
v5:
    - move xc_type definition and value get out of the loop.
      (suggested by Roger Pau Monné)
v4:
    - remove 'ALLOC_' from macro name.
      (suggested by Roger Pau Monné)
    - adjust place of argc check and return EXIT_FAILURE.
      (suggested by Roger Pau Monné)
    - fix indentation issue.
      (suggested by Roger Pau Monné)
    - move same type local variables declaration to a single line.
      (suggested by Roger Pau Monné)
v3:
    - add 'const' for 'opts[]' in 'main_psr_mba_set'.
      (suggested by Roger Pau Monné)
    - replace 'libxl_psr_cbm_type' to 'libxl_psr_type' for newly defined
      interfaces.
      (suggested by Roger Pau Monné)
---
 tools/libxc/include/xenctrl.h |  6 ++---
 tools/libxc/xc_psr.c          |  9 ++++---
 tools/libxl/libxl_psr.c       | 52 ++++++++++++++++++++--------------------
 tools/xl/xl.h                 |  1 +
 tools/xl/xl_cmdtable.c        |  6 +++++
 tools/xl/xl_psr.c             | 55 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 96 insertions(+), 33 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index fc0d4d2..90bee20 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2532,9 +2532,9 @@ int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid, uint32_t cpu,
                         uint64_t *tsc);
 int xc_psr_cmt_enabled(xc_interface *xch);
 
-int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-                               xc_psr_type type, uint32_t target,
-                               uint64_t data);
+int xc_psr_set_domain_data(xc_interface *xch, uint32_t domid,
+                           xc_psr_type type, uint32_t target,
+                           uint64_t data);
 int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
                            xc_psr_type type, uint32_t target,
                            uint64_t *data);
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index 37a6feb..1a0ab63 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -248,9 +248,9 @@ int xc_psr_cmt_enabled(xc_interface *xch)
 
     return 0;
 }
-int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-                               xc_psr_type type, uint32_t target,
-                               uint64_t data)
+int xc_psr_set_domain_data(xc_interface *xch, uint32_t domid,
+                           xc_psr_type type, uint32_t target,
+                           uint64_t data)
 {
     DECLARE_DOMCTL;
     uint32_t cmd;
@@ -269,6 +269,9 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
     case XC_PSR_CAT_L2_CBM:
         cmd = XEN_DOMCTL_PSR_SET_L2_CBM;
         break;
+    case XC_PSR_MBA_THRTL:
+        cmd = XEN_DOMCTL_PSR_SET_MBA_THRTL;
+        break;
     default:
         errno = EINVAL;
         return -1;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 7c560bc..9ced7d1 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -328,32 +328,7 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
                           libxl_psr_cbm_type type, libxl_bitmap *target_map,
                           uint64_t cbm)
 {
-    GC_INIT(ctx);
-    int rc;
-    int socketid, nr_sockets;
-
-    rc = libxl__count_physical_sockets(gc, &nr_sockets);
-    if (rc) {
-        LOGED(ERROR, domid, "failed to get system socket count");
-        goto out;
-    }
-
-    libxl_for_each_set_bit(socketid, *target_map) {
-        xc_psr_type xc_type = libxl__psr_type_to_libxc_psr_type(type);
-
-        if (socketid >= nr_sockets)
-            break;
-
-        if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
-                                       socketid, cbm)) {
-            libxl__psr_alloc_log_err_msg(gc, errno, type);
-            rc = ERROR_FAIL;
-        }
-    }
-
-out:
-    GC_FREE;
-    return rc;
+    return libxl_psr_set_val(ctx, domid, type, target_map, cbm);
 }
 
 int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
@@ -453,7 +428,30 @@ int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
                       libxl_psr_type type, libxl_bitmap *target_map,
                       uint64_t val)
 {
-    return ERROR_FAIL;
+    GC_INIT(ctx);
+    int rc, socketid, nr_sockets;
+    xc_psr_type xc_type = libxl__psr_type_to_libxc_psr_type(type);
+
+    rc = libxl__count_physical_sockets(gc, &nr_sockets);
+    if (rc) {
+        LOG(ERROR, "failed to get system socket count");
+        goto out;
+    }
+
+    libxl_for_each_set_bit(socketid, *target_map) {
+        if (socketid >= nr_sockets)
+            break;
+
+        if (xc_psr_set_domain_data(ctx->xch, domid, xc_type,
+                                   socketid, val)) {
+            libxl__psr_alloc_log_err_msg(gc, errno, type);
+            rc = ERROR_FAIL;
+        }
+    }
+
+out:
+    GC_FREE;
+    return rc;
 }
 
 int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index a72458b..4e784ff 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -208,6 +208,7 @@ int main_psr_cmt_detach(int argc, char **argv);
 int main_psr_cmt_show(int argc, char **argv);
 int main_psr_cat_cbm_set(int argc, char **argv);
 int main_psr_cat_show(int argc, char **argv);
+int main_psr_mba_set(int argc, char **argv);
 int main_psr_mba_show(int argc, char **argv);
 #endif
 int main_qemu_monitor_command(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index fb9e918..6d89439 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -586,6 +586,12 @@ struct cmd_spec cmd_table[] = {
       "[options] <Domain>",
       "-l <level>        Specify the cache level to process, otherwise L3 cache is processed\n"
     },
+    { "psr-mba-set",
+      &main_psr_mba_set, 0, 1,
+      "Set throttling value (THRTL) for a domain",
+      "[options] <Domain> <THRTL>",
+      "-s <socket>       Specify the socket to process, otherwise all sockets are processed\n"
+    },
     { "psr-mba-show",
       &main_psr_mba_show, 0, 1,
       "Show Memory Bandwidth Allocation information",
diff --git a/tools/xl/xl_psr.c b/tools/xl/xl_psr.c
index 0eedbc7..7aff474 100644
--- a/tools/xl/xl_psr.c
+++ b/tools/xl/xl_psr.c
@@ -552,6 +552,61 @@ int main_psr_mba_show(int argc, char **argv)
     return psr_val_show(domid, LIBXL_PSR_FEAT_TYPE_MBA, 0);
 }
 
+int main_psr_mba_set(int argc, char **argv)
+{
+    uint32_t domid;
+    libxl_psr_type type;
+    uint64_t thrtl;
+    int ret, opt = 0;
+    libxl_bitmap target_map;
+    char *value;
+    libxl_string_list socket_list;
+    unsigned long start, end;
+    unsigned int i, j, len;
+
+    static const struct option opts[] = {
+        {"socket", 1, 0, 's'},
+        COMMON_LONG_OPTS
+    };
+
+    libxl_socket_bitmap_alloc(ctx, &target_map, 0);
+    libxl_bitmap_set_none(&target_map);
+
+    SWITCH_FOREACH_OPT(opt, "s:", opts, "psr-mba-set", 0) {
+    case 's':
+        trim(isspace, optarg, &value);
+        split_string_into_string_list(value, ",", &socket_list);
+        len = libxl_string_list_length(&socket_list);
+        for (i = 0; i < len; i++) {
+            parse_range(socket_list[i], &start, &end);
+            for (j = start; j <= end; j++)
+                libxl_bitmap_set(&target_map, j);
+        }
+
+        libxl_string_list_dispose(&socket_list);
+        free(value);
+        break;
+    }
+
+    type = LIBXL_PSR_CBM_TYPE_MBA_THRTL;
+
+    if (libxl_bitmap_is_empty(&target_map))
+        libxl_bitmap_set_any(&target_map);
+
+    if (argc != optind + 2) {
+        help("psr-mba-set");
+        return EXIT_FAILURE;
+    }
+
+    domid = find_domain(argv[optind]);
+    thrtl = strtoll(argv[optind + 1], NULL , 0);
+
+    ret = libxl_psr_set_val(ctx, domid, type, &target_map, thrtl);
+
+    libxl_bitmap_dispose(&target_map);
+    return ret;
+}
+
 static int psr_mba_hwinfo(void)
 {
     int rc;
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v10 11/11] docs: add MBA description in docs
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (9 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 10/11] tools: implement new generic set value interface and MBA set " Yi Sun
@ 2017-12-19  0:42 ` Yi Sun
  2017-12-20  9:11 ` [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Jan Beulich
  11 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-19  0:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Chao Peng, Yi Sun, Wei Liu, Roger Pau Monné

This patch adds MBA description in related documents.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>

v5:
    - remove 'closed-loop' in 'xl-psr.markdown'
      (suggested by Roger Pau Monné)
v4:
    - modify description of MBA in 'xl.pod.1.in' to be same as feature doc.
      (suggested by Roger Pau Monné)
    - fix words issue.
      (suggested by Roger Pau Monné)
v2:
    - state the value type shown by 'psr-mba-show'. For linear mode,
      it shows decimal value. For non-linear mode, it shows hexadecimal
      value.
      (suggested by Chao Peng)
---
 docs/man/xl.pod.1.in      | 33 +++++++++++++++++++++++++
 docs/misc/xl-psr.markdown | 62 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 486a24f..7fd35c9 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1850,6 +1850,39 @@ processed.
 
 =back
 
+=head2 Memory Bandwidth Allocation
+
+Intel Skylake and later server platforms offer capabilities to configure and
+make use of the Memory Bandwidth Allocation (MBA) mechanisms, which provides
+OS/VMMs the ability to slow misbehaving apps/VMs by using a credit-based
+throttling mechanism. In the Xen implementation, MBA is used to control memory
+bandwidth on VM basis. To enforce bandwidth on a specific domain, just set
+throttling value (THRTL) for the domain.
+
+=over 4
+
+=item B<psr-mba-set> [I<OPTIONS>] I<domain-id> I<thrtl>
+
+Set throttling value (THRTL) for a domain. For how to specify I<thrtl>
+please refer to L<http://xenbits.xen.org/docs/unstable/misc/xl-psr.html>.
+
+B<OPTIONS>
+
+=over 4
+
+=item B<-s SOCKET>, B<--socket=SOCKET>
+
+Specify the socket to process, otherwise all sockets are processed.
+
+=back
+
+=item B<psr-mba-show> [I<domain-id>]
+
+Show MBA settings for a certain domain or all domains. For linear mode, it
+shows the decimal value. For non-linear mode, it shows hexadecimal value.
+
+=back
+
 =head1 IGNORED FOR COMPATIBILITY WITH XM
 
 xl is mostly command-line compatible with the old xm utility used with
diff --git a/docs/misc/xl-psr.markdown b/docs/misc/xl-psr.markdown
index 04dd957..3d196ed 100644
--- a/docs/misc/xl-psr.markdown
+++ b/docs/misc/xl-psr.markdown
@@ -186,6 +186,68 @@ Setting data CBM for a domain:
 Setting the same code and data CBM for a domain:
 `xl psr-cat-set <domid> <cbm>`
 
+## Memory Bandwidth Allocation (MBA)
+
+Memory Bandwidth Allocation (MBA) is a new feature available on Intel
+Skylake and later server platforms that allows an OS or Hypervisor/VMM to
+slow misbehaving apps/VMs by using a credit-based throttling mechanism. To
+enforce bandwidth on a specific domain, just set throttling value (THRTL)
+into Class of Service (COS). MBA provides two THRTL mode. One is linear mode
+and the other is non-linear mode.
+
+In the linear mode the input precision is defined as 100-(THRTL_MAX). Values
+not an even multiple of the precision (e.g., 12%) will be rounded down (e.g.,
+to 10% delay by the hardware).
+
+If linear values are not supported then input delay values are powers-of-two
+from zero to the THRTL_MAX value from CPUID. In this case any values not a power
+of two will be rounded down the next nearest power of two.
+
+For example, assuming a system with 2 domains:
+
+ * A THRTL of 0x0 for every domain means each domain can access the whole cache
+   without any delay. This is the default.
+
+ * Linear mode: Giving one domain a THRTL of 0xC and the other domain's 0 means
+   that the first domain gets 10% delay to access the cache and the other one
+   without any delay.
+
+ * Non-linear mode: Giving one domain a THRTL of 0xC and the other domain's 0
+   means that the first domain gets 8% delay to access the cache and the other
+   one without any delay.
+
+For more detailed information please refer to Intel SDM chapter
+"Introduction to Memory Bandwidth Allocation".
+
+In Xen's implementation, THRTL can be configured with libxl/xl interfaces but
+COS is maintained in hypervisor only. The cache partition granularity is per
+domain, each domain has COS=0 assigned by default, the corresponding THRTL is
+0, which means all the cache resource can be accessed without delay.
+
+### xl interfaces
+
+System MBA information such as maximum COS and maximum THRTL can be obtained by:
+
+`xl psr-hwinfo --mba`
+
+The simplest way to change a domain's THRTL from its default is running:
+
+`xl psr-mba-set  [OPTIONS] <domid> <thrtl>`
+
+In a multi-socket system, the same thrtl will be set on each socket by default.
+Per socket thrtl can be specified with the `--socket SOCKET` option.
+
+Setting the THRTL may not be successful if insufficient COS is available. In
+such case unused COS(es) may be freed by setting THRTL of all related domains to
+its default value(0).
+
+Per domain THRTL settings can be shown by:
+
+`xl psr-mba-show [OPTIONS] <domid>`
+
+For linear mode, it shows the decimal value. For non-linear mode, it shows
+hexadecimal value.
+
 ## Reference
 
 [1] Intel SDM
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 01/11] x86: implement get hw info flow for MBA
  2017-12-19  0:42 ` [PATCH v10 01/11] x86: implement get hw info flow for MBA Yi Sun
@ 2017-12-20  8:56   ` Jan Beulich
  2017-12-20 10:32   ` Jan Beulich
  1 sibling, 0 replies; 23+ messages in thread
From: Jan Beulich @ 2017-12-20  8:56 UTC (permalink / raw)
  To: Yi Sun; +Cc: Andrew Cooper, xen-devel, Wei Liu, Chao Peng, Roger Pau Monné

>>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> This patch implements get HW info flow for MBA including its callback
> function and sysctl interface.
> 
> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
  2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
                   ` (10 preceding siblings ...)
  2017-12-19  0:42 ` [PATCH v10 11/11] docs: add MBA description in docs Yi Sun
@ 2017-12-20  9:11 ` Jan Beulich
  2018-01-08  4:28   ` Yi Sun
  11 siblings, 1 reply; 23+ messages in thread
From: Jan Beulich @ 2017-12-20  9:11 UTC (permalink / raw)
  To: Wei Liu, Ian Jackson
  Cc: Yi Sun, Andrew Cooper, Julien Grall, xen-devel, Chao Peng,
	Daniel De Graaf, Roger Pau Monné

>>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> We plan to bring a new PSR (Platform Shared Resource) feature called
> Intel Memory Bandwidth Allocation (MBA) to Xen.
> 
> Besides the MBA enabling, we change some interfaces to make them more
> general but not only for CAT.
> 
> The first 5 patches of V9 haven been merged. To fix a few issues, the
> V10 is submitted.

I've committed the three hypervisor patches; I've not done anything
with the eight tools ones, as one of them needs to be (re-)acked. I'll
leave that part to one of you.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 01/11] x86: implement get hw info flow for MBA
  2017-12-19  0:42 ` [PATCH v10 01/11] x86: implement get hw info flow for MBA Yi Sun
  2017-12-20  8:56   ` Jan Beulich
@ 2017-12-20 10:32   ` Jan Beulich
  2017-12-21  2:30     ` Yi Sun
  1 sibling, 1 reply; 23+ messages in thread
From: Jan Beulich @ 2017-12-20 10:32 UTC (permalink / raw)
  To: Yi Sun; +Cc: Andrew Cooper, xen-devel, Wei Liu, Chao Peng, Roger Pau Monné

>>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> --- a/Config.mk
> +++ b/Config.mk
> @@ -260,17 +260,17 @@ QEMU_TRADITIONAL_REVISION ?= $(QEMU_TAG)
>  endif
>  
>  ifeq ($(GIT_HTTP),y)
> -OVMF_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/ovmf.git 
> -QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-xen.git 
> -QEMU_TRADITIONAL_URL ?= http://xenbits.xen.org/git-http/qemu-xen-traditional.git 
> -SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git 
> -MINIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/mini-os.git 
> +OVMF_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/ovmf.git 
> +QEMU_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/qemu-xen.git 
> +QEMU_TRADITIONAL_URL ?= http://vt-sync.sh.intel.com/git-http/qemu-xen-traditional.git 
> +SEABIOS_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/seabios.git 
> +MINIOS_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/mini-os.git 
>  else
> -OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git
> -QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-xen.git
> -QEMU_TRADITIONAL_URL ?= git://xenbits.xen.org/qemu-xen-traditional.git
> -SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git
> -MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git
> +OVMF_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/ovmf.git
> +QEMU_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/qemu-xen.git
> +QEMU_TRADITIONAL_URL ?= git://vt-sync.sh.intel.com/qemu-xen-traditional.git
> +SEABIOS_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/seabios.git
> +MINIOS_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/mini-os.git
>  endif
>  OVMF_UPSTREAM_REVISION ?= 947f3737abf65fda63f3ffd97fddfa6986986868
>  QEMU_UPSTREAM_REVISION ?= master

This is rather annoying: I ended up overlooking these changes
(it was Andrew who has noticed them), attributing them to be
part of the post description comments (they clearly didn't look
like valid code changes). Please can you pay more attention to
what you actually submit?

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 01/11] x86: implement get hw info flow for MBA
  2017-12-20 10:32   ` Jan Beulich
@ 2017-12-21  2:30     ` Yi Sun
  0 siblings, 0 replies; 23+ messages in thread
From: Yi Sun @ 2017-12-21  2:30 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, xen-devel, Wei Liu, Chao Peng, Roger Pau Monné

On 17-12-20 03:32:23, Jan Beulich wrote:
> >>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> > --- a/Config.mk
> > +++ b/Config.mk
> > @@ -260,17 +260,17 @@ QEMU_TRADITIONAL_REVISION ?= $(QEMU_TAG)
> >  endif
> >  
> >  ifeq ($(GIT_HTTP),y)
> > -OVMF_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/ovmf.git 
> > -QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-xen.git 
> > -QEMU_TRADITIONAL_URL ?= http://xenbits.xen.org/git-http/qemu-xen-traditional.git 
> > -SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git 
> > -MINIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/mini-os.git 
> > +OVMF_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/ovmf.git 
> > +QEMU_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/qemu-xen.git 
> > +QEMU_TRADITIONAL_URL ?= http://vt-sync.sh.intel.com/git-http/qemu-xen-traditional.git 
> > +SEABIOS_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/seabios.git 
> > +MINIOS_UPSTREAM_URL ?= http://vt-sync.sh.intel.com/git-http/mini-os.git 
> >  else
> > -OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git
> > -QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-xen.git
> > -QEMU_TRADITIONAL_URL ?= git://xenbits.xen.org/qemu-xen-traditional.git
> > -SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git
> > -MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git
> > +OVMF_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/ovmf.git
> > +QEMU_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/qemu-xen.git
> > +QEMU_TRADITIONAL_URL ?= git://vt-sync.sh.intel.com/qemu-xen-traditional.git
> > +SEABIOS_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/seabios.git
> > +MINIOS_UPSTREAM_URL ?= git://vt-sync.sh.intel.com/mini-os.git
> >  endif
> >  OVMF_UPSTREAM_REVISION ?= 947f3737abf65fda63f3ffd97fddfa6986986868
> >  QEMU_UPSTREAM_REVISION ?= master
> 
> This is rather annoying: I ended up overlooking these changes
> (it was Andrew who has noticed them), attributing them to be
> part of the post description comments (they clearly didn't look
> like valid code changes). Please can you pay more attention to
> what you actually submit?
> 
Oh, that is my fault! Very sorry for this. :(

> Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
  2017-12-20  9:11 ` [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Jan Beulich
@ 2018-01-08  4:28   ` Yi Sun
  2018-01-08 12:25     ` Wei Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Yi Sun @ 2018-01-08  4:28 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, Andrew Cooper, Ian Jackson, Julien Grall, xen-devel,
	Chao Peng, Daniel De Graaf, Roger Pau Monné

On 17-12-20 02:11:32, Jan Beulich wrote:
> >>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> > We plan to bring a new PSR (Platform Shared Resource) feature called
> > Intel Memory Bandwidth Allocation (MBA) to Xen.
> > 
> > Besides the MBA enabling, we change some interfaces to make them more
> > general but not only for CAT.
> > 
> > The first 5 patches of V9 haven been merged. To fix a few issues, the
> > V10 is submitted.
> 
> I've committed the three hypervisor patches; I've not done anything
> with the eight tools ones, as one of them needs to be (re-)acked. I'll
> leave that part to one of you.
> 
> Jan

Hi, Ian and Wei,

Could you please help to check tools/ patches? Thanks!

BRs,
Sun Yi

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 10/11] tools: implement new generic set value interface and MBA set value command
  2017-12-19  0:42 ` [PATCH v10 10/11] tools: implement new generic set value interface and MBA set " Yi Sun
@ 2018-01-08 12:23   ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2018-01-08 12:23 UTC (permalink / raw)
  To: Yi Sun; +Cc: xen-devel, Chao Peng, Wei Liu, Ian Jackson, Roger Pau Monné

On Tue, Dec 19, 2017 at 08:42:21AM +0800, Yi Sun wrote:
> This patch implements new generic set value interfaces in libxc and libxl.
> These interfaces are suitable for all allocation features. It also adds a
> new MBA set value command in xl.
> 
> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
  2018-01-08  4:28   ` Yi Sun
@ 2018-01-08 12:25     ` Wei Liu
  2018-01-09  0:31       ` Yi Sun
  0 siblings, 1 reply; 23+ messages in thread
From: Wei Liu @ 2018-01-08 12:25 UTC (permalink / raw)
  To: Yi Sun
  Cc: Wei Liu, Andrew Cooper, Ian Jackson, Julien Grall, Jan Beulich,
	xen-devel, Chao Peng, Daniel De Graaf, Roger Pau Monné

On Mon, Jan 08, 2018 at 12:28:58PM +0800, Yi Sun wrote:
> On 17-12-20 02:11:32, Jan Beulich wrote:
> > >>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> > > We plan to bring a new PSR (Platform Shared Resource) feature called
> > > Intel Memory Bandwidth Allocation (MBA) to Xen.
> > > 
> > > Besides the MBA enabling, we change some interfaces to make them more
> > > general but not only for CAT.
> > > 
> > > The first 5 patches of V9 haven been merged. To fix a few issues, the
> > > V10 is submitted.
> > 
> > I've committed the three hypervisor patches; I've not done anything
> > with the eight tools ones, as one of them needs to be (re-)acked. I'll
> > leave that part to one of you.
> > 
> > Jan
> 
> Hi, Ian and Wei,
> 
> Could you please help to check tools/ patches? Thanks!
> 

I just acked the one patch that missed an ack. I will try to get around
to commit them later this week.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
  2018-01-08 12:25     ` Wei Liu
@ 2018-01-09  0:31       ` Yi Sun
  2018-01-18 11:10         ` Wei Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Yi Sun @ 2018-01-09  0:31 UTC (permalink / raw)
  To: Wei Liu
  Cc: Andrew Cooper, Ian Jackson, Julien Grall, Jan Beulich, xen-devel,
	Chao Peng, Daniel De Graaf, Roger Pau Monn�

On 18-01-08 12:25:02, Wei Liu wrote:
> On Mon, Jan 08, 2018 at 12:28:58PM +0800, Yi Sun wrote:
> > On 17-12-20 02:11:32, Jan Beulich wrote:
> > > >>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> > > > We plan to bring a new PSR (Platform Shared Resource) feature called
> > > > Intel Memory Bandwidth Allocation (MBA) to Xen.
> > > > 
> > > > Besides the MBA enabling, we change some interfaces to make them more
> > > > general but not only for CAT.
> > > > 
> > > > The first 5 patches of V9 haven been merged. To fix a few issues, the
> > > > V10 is submitted.
> > > 
> > > I've committed the three hypervisor patches; I've not done anything
> > > with the eight tools ones, as one of them needs to be (re-)acked. I'll
> > > leave that part to one of you.
> > > 
> > > Jan
> > 
> > Hi, Ian and Wei,
> > 
> > Could you please help to check tools/ patches? Thanks!
> > 
> 
> I just acked the one patch that missed an ack. I will try to get around
> to commit them later this week.
> 
Thank you! :)

> Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
  2018-01-09  0:31       ` Yi Sun
@ 2018-01-18 11:10         ` Wei Liu
  2018-01-18 11:31           ` Wei Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Wei Liu @ 2018-01-18 11:10 UTC (permalink / raw)
  To: Yi Sun
  Cc: Wei Liu, Andrew Cooper, Ian Jackson, Julien Grall, Jan Beulich,
	xen-devel, Chao Peng, Daniel De Graaf, Roger Pau Monn�

On Tue, Jan 09, 2018 at 08:31:52AM +0800, Yi Sun wrote:
> On 18-01-08 12:25:02, Wei Liu wrote:
> > On Mon, Jan 08, 2018 at 12:28:58PM +0800, Yi Sun wrote:
> > > On 17-12-20 02:11:32, Jan Beulich wrote:
> > > > >>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> > > > > We plan to bring a new PSR (Platform Shared Resource) feature called
> > > > > Intel Memory Bandwidth Allocation (MBA) to Xen.
> > > > > 
> > > > > Besides the MBA enabling, we change some interfaces to make them more
> > > > > general but not only for CAT.
> > > > > 
> > > > > The first 5 patches of V9 haven been merged. To fix a few issues, the
> > > > > V10 is submitted.
> > > > 
> > > > I've committed the three hypervisor patches; I've not done anything
> > > > with the eight tools ones, as one of them needs to be (re-)acked. I'll
> > > > leave that part to one of you.
> > > > 
> > > > Jan
> > > 
> > > Hi, Ian and Wei,
> > > 
> > > Could you please help to check tools/ patches? Thanks!
> > > 
> > 
> > I just acked the one patch that missed an ack. I will try to get around
> > to commit them later this week.
> > 
> Thank you! :)

Hi Yi

I tried to apply patch 4 to 11 today but there were conflicts. Can you
rebase your series on top of staging?

Sorry for the inconvenience. We've mostly been dealing with security
issues and the tree seemed to have changed a bit with all the recent
fixes applied.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
  2018-01-18 11:10         ` Wei Liu
@ 2018-01-18 11:31           ` Wei Liu
  2018-01-18 11:50             ` Wei Liu
  0 siblings, 1 reply; 23+ messages in thread
From: Wei Liu @ 2018-01-18 11:31 UTC (permalink / raw)
  To: Yi Sun
  Cc: Wei Liu, Andrew Cooper, Ian Jackson, Julien Grall, Jan Beulich,
	xen-devel, Chao Peng, Daniel De Graaf, Roger Pau Monn�

On Thu, Jan 18, 2018 at 11:10:50AM +0000, Wei Liu wrote:
> On Tue, Jan 09, 2018 at 08:31:52AM +0800, Yi Sun wrote:
> > On 18-01-08 12:25:02, Wei Liu wrote:
> > > On Mon, Jan 08, 2018 at 12:28:58PM +0800, Yi Sun wrote:
> > > > On 17-12-20 02:11:32, Jan Beulich wrote:
> > > > > >>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> > > > > > We plan to bring a new PSR (Platform Shared Resource) feature called
> > > > > > Intel Memory Bandwidth Allocation (MBA) to Xen.
> > > > > > 
> > > > > > Besides the MBA enabling, we change some interfaces to make them more
> > > > > > general but not only for CAT.
> > > > > > 
> > > > > > The first 5 patches of V9 haven been merged. To fix a few issues, the
> > > > > > V10 is submitted.
> > > > > 
> > > > > I've committed the three hypervisor patches; I've not done anything
> > > > > with the eight tools ones, as one of them needs to be (re-)acked. I'll
> > > > > leave that part to one of you.
> > > > > 
> > > > > Jan
> > > > 
> > > > Hi, Ian and Wei,
> > > > 
> > > > Could you please help to check tools/ patches? Thanks!
> > > > 
> > > 
> > > I just acked the one patch that missed an ack. I will try to get around
> > > to commit them later this week.
> > > 
> > Thank you! :)
> 
> Hi Yi
> 
> I tried to apply patch 4 to 11 today but there were conflicts. Can you
> rebase your series on top of staging?
> 
> Sorry for the inconvenience. We've mostly been dealing with security
> issues and the tree seemed to have changed a bit with all the recent
> fixes applied.
> 

Actually, before you set off to do anything, let me try again. There
could a problem with my email client. I will let you know the result.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen
  2018-01-18 11:31           ` Wei Liu
@ 2018-01-18 11:50             ` Wei Liu
  0 siblings, 0 replies; 23+ messages in thread
From: Wei Liu @ 2018-01-18 11:50 UTC (permalink / raw)
  To: Yi Sun
  Cc: Wei Liu, Andrew Cooper, Ian Jackson, Julien Grall, Jan Beulich,
	xen-devel, Chao Peng, Daniel De Graaf, Roger Pau Monn�

On Thu, Jan 18, 2018 at 11:31:51AM +0000, Wei Liu wrote:
> On Thu, Jan 18, 2018 at 11:10:50AM +0000, Wei Liu wrote:
> > On Tue, Jan 09, 2018 at 08:31:52AM +0800, Yi Sun wrote:
> > > On 18-01-08 12:25:02, Wei Liu wrote:
> > > > On Mon, Jan 08, 2018 at 12:28:58PM +0800, Yi Sun wrote:
> > > > > On 17-12-20 02:11:32, Jan Beulich wrote:
> > > > > > >>> On 19.12.17 at 01:42, <yi.y.sun@linux.intel.com> wrote:
> > > > > > > We plan to bring a new PSR (Platform Shared Resource) feature called
> > > > > > > Intel Memory Bandwidth Allocation (MBA) to Xen.
> > > > > > > 
> > > > > > > Besides the MBA enabling, we change some interfaces to make them more
> > > > > > > general but not only for CAT.
> > > > > > > 
> > > > > > > The first 5 patches of V9 haven been merged. To fix a few issues, the
> > > > > > > V10 is submitted.
> > > > > > 
> > > > > > I've committed the three hypervisor patches; I've not done anything
> > > > > > with the eight tools ones, as one of them needs to be (re-)acked. I'll
> > > > > > leave that part to one of you.
> > > > > > 
> > > > > > Jan
> > > > > 
> > > > > Hi, Ian and Wei,
> > > > > 
> > > > > Could you please help to check tools/ patches? Thanks!
> > > > > 
> > > > 
> > > > I just acked the one patch that missed an ack. I will try to get around
> > > > to commit them later this week.
> > > > 
> > > Thank you! :)
> > 
> > Hi Yi
> > 
> > I tried to apply patch 4 to 11 today but there were conflicts. Can you
> > rebase your series on top of staging?
> > 
> > Sorry for the inconvenience. We've mostly been dealing with security
> > issues and the tree seemed to have changed a bit with all the recent
> > fixes applied.
> > 
> 
> Actually, before you set off to do anything, let me try again. There
> could a problem with my email client. I will let you know the result.

Alright, it is done. Your patches are now in staging. Please let me know
if there is any problem.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2018-01-18 11:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19  0:42 [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Yi Sun
2017-12-19  0:42 ` [PATCH v10 01/11] x86: implement get hw info flow for MBA Yi Sun
2017-12-20  8:56   ` Jan Beulich
2017-12-20 10:32   ` Jan Beulich
2017-12-21  2:30     ` Yi Sun
2017-12-19  0:42 ` [PATCH v10 02/11] x86: implement get value interface " Yi Sun
2017-12-19  0:42 ` [PATCH v10 03/11] x86: implement set value flow " Yi Sun
2017-12-19  0:42 ` [PATCH v10 04/11] tools: create general interfaces to support psr allocation features Yi Sun
2017-12-19  0:42 ` [PATCH v10 05/11] tools: implement the new libxc get hw info interface Yi Sun
2017-12-19  0:42 ` [PATCH v10 06/11] tools: implement the new libxl " Yi Sun
2017-12-19  0:42 ` [PATCH v10 07/11] tools: implement the new xl " Yi Sun
2017-12-19  0:42 ` [PATCH v10 08/11] tools: rename 'xc_psr_cat_type' to 'xc_psr_type' Yi Sun
2017-12-19  0:42 ` [PATCH v10 09/11] tools: implement new generic get value interface and MBA get value command Yi Sun
2017-12-19  0:42 ` [PATCH v10 10/11] tools: implement new generic set value interface and MBA set " Yi Sun
2018-01-08 12:23   ` Wei Liu
2017-12-19  0:42 ` [PATCH v10 11/11] docs: add MBA description in docs Yi Sun
2017-12-20  9:11 ` [PATCH v10 00/11] Enable Memory Bandwidth Allocation in Xen Jan Beulich
2018-01-08  4:28   ` Yi Sun
2018-01-08 12:25     ` Wei Liu
2018-01-09  0:31       ` Yi Sun
2018-01-18 11:10         ` Wei Liu
2018-01-18 11:31           ` Wei Liu
2018-01-18 11:50             ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.