All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com,
	George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
	Dongxiao Xu <dongxiao.xu@intel.com>,
	JBeulich@suse.com, Chao Peng <chao.p.peng@linux.intel.com>
Subject: [RFC PATCH 5/7] xen: libxc: libxl: allow for attaching and detaching a CPU to CMT
Date: Sat, 04 Apr 2015 04:14:58 +0200	[thread overview]
Message-ID: <20150404021457.22875.13817.stgit@Solace.station> (raw)
In-Reply-To: <20150404020423.22875.23590.stgit@Solace.station>

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
 tools/libxc/include/xenctrl.h |    2 ++
 tools/libxc/xc_psr.c          |   34 ++++++++++++++++++++++++++++++++++
 tools/libxl/libxl.h           |    2 ++
 tools/libxl/libxl_psr.c       |   30 ++++++++++++++++++++++++++++++
 xen/arch/x86/sysctl.c         |   28 ++++++++++++++++++++++++++++
 xen/include/public/sysctl.h   |    2 ++
 6 files changed, 98 insertions(+)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index d038e40..7c17e3e 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2707,6 +2707,8 @@ int xc_psr_cmt_get_cpu_rmid(xc_interface *xch, uint32_t cpu,
 int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid, uint32_t cpu,
                         uint32_t psr_cmt_type, uint64_t *monitor_data,
                         uint64_t *tsc);
+int xc_psr_cmt_cpu_attach(xc_interface *xch, uint32_t cpu);
+int xc_psr_cmt_cpu_detach(xc_interface *xch, uint32_t cpu);
 int xc_psr_cmt_enabled(xc_interface *xch);
 #endif
 
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index 088cf66..3d1b1cb 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -177,6 +177,40 @@ int xc_psr_cmt_get_cpu_rmid(xc_interface *xch, uint32_t cpu,
     return 0;
 }
 
+int xc_psr_cmt_cpu_attach(xc_interface *xch, uint32_t cpu)
+{
+    int rc;
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_psr_cmt_op;
+    sysctl.u.psr_cmt_op.cmd = XEN_SYSCTL_PSR_CMT_cpu_rmid_attach;
+    sysctl.u.psr_cmt_op.u.cpu_rmid.cpu = cpu;
+    sysctl.u.psr_cmt_op.flags = 0;
+
+    rc = xc_sysctl(xch, &sysctl);
+    if ( rc )
+        return -1;
+
+    return 0;
+}
+
+int xc_psr_cmt_cpu_detach(xc_interface *xch, uint32_t cpu)
+{
+    int rc;
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_psr_cmt_op;
+    sysctl.u.psr_cmt_op.cmd = XEN_SYSCTL_PSR_CMT_cpu_rmid_detach;
+    sysctl.u.psr_cmt_op.u.cpu_rmid.cpu = cpu;
+    sysctl.u.psr_cmt_op.flags = 0;
+
+    rc = xc_sysctl(xch, &sysctl);
+    if ( rc )
+        return -1;
+
+    return 0;
+}
+
 int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid, uint32_t cpu,
                         xc_psr_cmt_type type, uint64_t *monitor_data,
                         uint64_t *tsc)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 23e266d..1c1d5f0 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1525,6 +1525,8 @@ int libxl_psr_cmt_cpu_attached(libxl_ctx *ctx, uint32_t cpu);
 int libxl_psr_cmt_get_cpu_cache_occupancy(libxl_ctx *ctx,
                                           uint32_t cpu,
                                           uint32_t *l3_cache_occupancy);
+int libxl_psr_cmt_cpu_attach(libxl_ctx *ctx, uint32_t cpu);
+int libxl_psr_cmt_cpu_detach(libxl_ctx *ctx, uint32_t cpu);
 #endif
 
 #ifdef LIBXL_HAVE_PSR_MBM
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index f5688a3..6b7a7ba 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -306,6 +306,36 @@ int libxl_psr_cmt_get_cpu_cache_occupancy(libxl_ctx *ctx,
     return rc;
 }
 
+int libxl_psr_cmt_cpu_attach(libxl_ctx *ctx, uint32_t cpu)
+{
+    GC_INIT(ctx);
+    int rc;
+
+    rc = xc_psr_cmt_cpu_attach(ctx->xch, cpu);
+    if (rc) {
+        libxl__psr_cmt_log_err_msg(gc, errno);
+        rc = ERROR_FAIL;
+    }
+
+    GC_FREE;
+    return rc;
+}
+
+int libxl_psr_cmt_cpu_detach(libxl_ctx *ctx, uint32_t cpu)
+{
+    GC_INIT(ctx);
+    int rc;
+
+    rc = xc_psr_cmt_cpu_detach(ctx->xch, cpu);
+    if (rc) {
+        libxl__psr_cmt_log_err_msg(gc, errno);
+        rc = ERROR_FAIL;
+    }
+
+    GC_FREE;
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index fc9838c..93837e5 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -174,6 +174,34 @@ long arch_do_sysctl(
             sysctl->u.psr_cmt_op.u.data = per_cpu(pcpu_rmid, cpu);
             break;
         }
+        case XEN_SYSCTL_PSR_CMT_cpu_rmid_attach:
+        {
+            unsigned int cpu = sysctl->u.psr_cmt_op.u.cpu_rmid.cpu;
+
+            if ( (cpu >= nr_cpu_ids) || !cpu_online(cpu) )
+            {
+                ret = -ENODEV;
+                break;
+            }
+            ret = psr_alloc_pcpu_rmid(cpu);
+            break;
+        }
+        case XEN_SYSCTL_PSR_CMT_cpu_rmid_detach:
+        {
+            unsigned int cpu = sysctl->u.psr_cmt_op.u.cpu_rmid.cpu;
+
+            if ( (cpu >= nr_cpu_ids) || !cpu_online(cpu) )
+            {
+                ret = -ENODEV;
+                break;
+            }
+
+            if ( per_cpu(pcpu_rmid, cpu) )
+                psr_free_pcpu_rmid(cpu);
+            else
+                return -ENOENT;
+            break;
+        }
         default:
             sysctl->u.psr_cmt_op.u.data = 0;
             ret = -ENOSYS;
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 11c26c6..0ae8758 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -648,6 +648,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_coverage_op_t);
 #define XEN_SYSCTL_PSR_CMT_enabled                   3
 #define XEN_SYSCTL_PSR_CMT_get_l3_event_mask         4
 #define XEN_SYSCTL_PSR_CMT_get_cpu_rmid              5
+#define XEN_SYSCTL_PSR_CMT_cpu_rmid_attach           6
+#define XEN_SYSCTL_PSR_CMT_cpu_rmid_detach           7
 struct xen_sysctl_psr_cmt_op {
     uint32_t cmd;       /* IN: XEN_SYSCTL_PSR_CMT_* */
     uint32_t flags;     /* padding variable, may be extended for future use */

  parent reply	other threads:[~2015-04-04  2:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-04  2:14 [RFC PATCH 0/7] Intel Cache Monitoring: Current Status and Future Opportunities Dario Faggioli
2015-04-04  2:14 ` [RFC PATCH 1/7] x86: improve psr scheduling code Dario Faggioli
2015-04-06 13:48   ` Konrad Rzeszutek Wilk
2015-04-04  2:14 ` [RFC PATCH 2/7] Xen: x86: print max usable RMID during init Dario Faggioli
2015-04-06 13:48   ` Konrad Rzeszutek Wilk
2015-04-07 10:11     ` Dario Faggioli
2015-04-04  2:14 ` [RFC PATCH 3/7] xen: psr: reserve an RMID for each core Dario Faggioli
2015-04-06 13:59   ` Konrad Rzeszutek Wilk
2015-04-07 10:19     ` Dario Faggioli
2015-04-07 13:57       ` Konrad Rzeszutek Wilk
2015-04-07  8:24   ` Chao Peng
2015-04-07 10:07     ` Dario Faggioli
2015-04-08 13:28   ` George Dunlap
2015-04-08 14:03     ` Dario Faggioli
2015-04-04  2:14 ` [RFC PATCH 4/7] xen: libxc: libxl: report per-CPU cache occupancy up to libxl Dario Faggioli
2015-04-04  2:14 ` Dario Faggioli [this message]
2015-04-04  2:15 ` [RFC PATCH 6/7] xl: " Dario Faggioli
2015-04-04  2:15 ` [RFC PATCH 7/7] xl: allow for attaching and detaching a CPU to CMT Dario Faggioli
2015-04-07  8:19 ` [RFC PATCH 0/7] Intel Cache Monitoring: Current Status and Future Opportunities Chao Peng
2015-04-07  9:51   ` Dario Faggioli
2015-04-07 10:27 ` Andrew Cooper
2015-04-07 13:10   ` Dario Faggioli
2015-04-08  5:59     ` Chao Peng
2015-04-08  8:23       ` Dario Faggioli
2015-04-08  8:53         ` Andrew Cooper
2015-04-08  8:55         ` Chao Peng
2015-04-09 15:44     ` Meng Xu
2015-04-08 11:27   ` George Dunlap
2015-04-08 13:29     ` Dario Faggioli
2015-04-08 11:30 ` George Dunlap
2015-04-08 13:16   ` Dario Faggioli
2015-04-09 15:37 ` Meng Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150404021457.22875.13817.stgit@Solace.station \
    --to=dario.faggioli@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=dongxiao.xu@intel.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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.